I have this script that I would like to push to 15 servers in my lab to save a lot of time. When I go to server manager and select multiple servers and select powershell it just gives me 15 different windows. I would like to send the script below to all
15 servers. How can I go about doing this? I saw something about the invoke command, however, I don't completely understand it. It seems good for "get" data but not so much for sending it? Could someone please help me understand this a little better.
I have lots of powershell scripts I am excited to try but sending it to one server at a time still seems to defeat the purpose.
Servers are named NTASRV-01,NTASRV-02,NTASRV-03... and so on
$env = $env:computername
$a = $env.Substring($env.length -2, 2)
$vhdname = "VHDD"
$parent = "GoldenImage"
$vhd1 = $vhdname + ($a + 1)
$vhd2 = $vhdname + ($a + 2)
$vhd3 = $vhdname + ($a + 3)
$vhd4 = $vhdname + ($a + 4)
New-VHD -ParentPath C:\VHD\$parent.vhd -Differencing -Path C:\vhd\$vhd1.vhd
New-VHD -ParentPath C:\VHD\$parent.vhd -Differencing -Path C:\vhd\$vhd2.vhd
New-VHD -ParentPath C:\VHD\$parent.vhd -Differencing -Path C:\vhd\$vhd3.vhd
New-VHD -ParentPath C:\VHD\$parent.vhd -Differencing -Path C:\vhd\$vhd4.vhd
$VMname = "VM"
$SWname = "Primary"
$VM1 = $VMname + ($a + 1)
$VM2 = $VMname + ($a + 2)
$VM3 = $VMname + ($a + 3)
$VM4 = $VMname + ($a + 4)
New-VM -Name $VM1 -VHDPath c:\vhd\$vhd1.vhd -SwitchName $SWname -MemoryStartupBytes 1GB
New-VM -Name $VM2 -VHDPath c:\vhd\$vhd2.vhd -SwitchName $SWname -MemoryStartupBytes 1GB
New-VM -Name $VM3 -VHDPath c:\vhd\$vhd3.vhd -SwitchName $SWname -MemoryStartupBytes 1GB
New-VM -Name $VM4 -VHDPath c:\vhd\$vhd4.vhd -SwitchName $SWname -MemoryStartupBytes 1GB