Skip to content

Instantly share code, notes, and snippets.

@tomtorggler
Created March 4, 2016 16:17
Show Gist options
  • Save tomtorggler/c045d8c9da7b74fb84e0 to your computer and use it in GitHub Desktop.
Save tomtorggler/c045d8c9da7b74fb84e0 to your computer and use it in GitHub Desktop.
# create CimSessions to each of the servers to be configured
$cimSessions = New-CimSession -ComputerName n01,n02,n03,n04
# foreach CimSession configure an IPv4 Address on the interface with Alias Ethernet 2
# the IP Address is derived from the ComputerName property of the CimSession
$cimSessions | ForEach-Object {
$params = @{
IPAddress = "192.168.1."+$PSItem.ComputerName.Substring(2,1);
InterfaceAlias = 'Ethernet 2';
PrefixLength = '24';
AddressFamily = 'IPv4';
CimSession = $PSItem
}
New-NetIPAddress @params
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment