Created
November 3, 2017 17:22
-
-
Save nshores/115f39ab294bfe62439bfb4f1eb67992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach ($machine in $iplist){ | |
$network = get-vm $machine.Parent | Invoke-VMScript -GuestUser $guestuser -GuestPassword $guestpassword -ScriptText "(gwmi Win32_NetworkAdapter -filter 'netconnectionid is not null').netconnectionid" | |
$NetworkName = $Network.ScriptOutput | |
$NetworkName = $NetworkName.Trim() | |
$machineipvalue = $machine.ip | |
$machinemaskvalue = $machine.mask | |
$machinegatewayvalue = $machine.GATEWAY | |
$machinedns1value = $machine.dns1 | |
$machinedns2value = $machine.dns2 | |
$ip = "netsh interface ip set address ""$NetworkName"" static $machineipvalue $machinemaskvalue $machinegatewayvalue" | |
$dns1 = "netsh interface ip set dnsservers ""$NetworkName"" static $machinedns1value" | |
$dns2 = "netsh interface ip add dnsservers ""$NetworkName"" $machinedns2value" | |
$ip | |
$dns1 | |
$dns | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment