Its a tiny script to find the IP address, DNS and WINS server of a windows VM. Its an example for invoking guest scripts through PowerCLI.
[crayon lang=”powershell”]
Connect-VIServer vcenterserver1
get-vm -Name vmname | %{
$_.Name; $_ | Invoke-VMScript -GuestUser “test” -GuestPassword “test” -ScriptType Bat -ScriptText “netsh interface ipv4 show addresses” -HostUser “test1” -hostpassword “test1”
$_.Name; $_ | Invoke-VMScript -GuestUser “test” -GuestPassword “test” -ScriptType Bat -ScriptText “netsh interface ipv4 show dnsservers” -HostUser “test1” -hostpassword “test1”
$_.Name; $_ | Invoke-VMScript -GuestUser “test” -GuestPassword “test” -ScriptType Bat -ScriptText “netsh interface ipv4 show winsservers” -HostUser “test1” -hostpassword “test1”
}
[/crayon]