Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Using Put() method failing for some reason

$
0
0

Hey everybody, fairly new to the forums and I have a question wondering if someone is able to help out.  I built this script for changing the Network adapter name based on IP address (lots of help from google to figure it out)  and it worked no problem.  Now when I go to run it I get an error.

Exception calling "Put" with "0" argument(s): ""

Here is my code.

$wmi = Get-WmiObject -Computername $VMName Win32_NetworkAdapterConfiguration -Filter "IPEnabled = True" | Where-Object { $_.IPAddress -match '^10.158\.' }

$index = $wmi.index

$nam = Get-WmiObject -Computername $VMName Win32_NetworkAdapter -Filter "Index = $index"

$nam.NetconnectionID = 'External'

$nam.Put()

Now I ran this before with now issues.  I've also changed the $nam.NetconnectionID = 'External'  to $nam.NetconnectionID += 'External'  and it runs fine but just appends the External to the name and doesn't replace it.

I also saw some threads saying you need to run powershell in administrative mode, and I always run it that way.  So any help would be great.


Viewing all articles
Browse latest Browse all 6937

Latest Images

Trending Articles



Latest Images