Error --- 'Get-WmiObject' is not recognized as an internal or external command,operable program or batch file. is the current IP Address Changing IP to 'Get-WmiObject' is not recognized as an in...
See more...
Error --- 'Get-WmiObject' is not recognized as an internal or external command,operable program or batch file. is the current IP Address Changing IP to 'Get-WmiObject' is not recognized as an internal or external command,operable program or batch file. Working on WIN2K_SAMOJIT The interface name is 'Get-WmiObject' is not recognized as an internal or external command,operable program or batch file. Changing IP Address of WIN2K_SAMOJIT interface 'Get-WmiObject' is not recognized as an internal or external command,operable program or batch file. from 'Get-WmiObject' is not recognized as a n internal or external command,operable program or batch file. to 'Get-WmiObject' is not recognized as an internal or external command,operable program or batch file. Script That I'm trying is $VMs = (get-vm | where {$_.Name -match $computer -and $_.PowerState -eq "PoweredOn"}).Name foreach ($vm in $VMs) { if ($os -match "Microsoft Windows Server 2000" ) { #PowerShell used by Invoke-VMScript to retrieve current IP Addres $ipscript = '(Get-WmiObject Win32_NetworkAdapterConfiguration | where-object {$_.IPAddress -match "' + $origIp + '" -and $_.AddressFamily -eq "IPv4"})' $currentIp = invoke-vmscript -ScriptText $ipscript -ScriptType Bat -VM $vm -GuestUser $UserName -GuestPassword $Password $currentIp = $currentIp -replace "`t|`n|`r","" write-host "$currentIp is the current IP Address" #Adjust Original IP to Replacement IP $changeIp = $currentIp.replace("$origIp", "$Ip") $changeIp = $changeIp -replace "`t|`n|`r","" Write-Host "Changing IP to $changeIp" Write-Host "Working on $vm" #Get the Interface Name (Alias) $aliasscript = '(Get-WmiObject Win32_NetworkAdapterConfiguration| where-object {$_.IPAddress -match "' + $origIp + '" -and $_.AddressFamily -eq "IPv4"})' $getIntAlias = invoke-vmscript -ScriptText $aliasscript -ScriptType Bat -VM $vm -GuestUser $UserName -GuestPassword $Password $getIntAlias = $getIntAlias -replace "`t|`n|`r","" write-host "The interface name is $getIntAlias" #Change the IP Address $changingIp = "c:\windows\system32\netsh.exe interface ip set address ""Local Area Connection"" static $IP $SM $GW 1" Write-host "Changing IP Address of $vm interface $getIntAlias from $currentIp to $changeIp" $setIp = invoke-vmscript -ScriptText $changingIp -ScriptType bat -VM $vm -GuestUser $UserName -GuestPassword $Password } } }