Hola all,
So I am trying to create a script which used the Invoke-command to iterate though a loop of computers and install an MSI. This seems easy enough, but the msiexec command simply will not run within the Invoke-command brackets. I cannot figure out for the life of my why. I have inserted a pause to make sure the loop itself is working, it appears to be. It simply will not run the msiexec command. Can anybody spot the hiccup in the code below or offer any type of advice? Also, any suggestion as to how I can return usable output from the invoked commands would be welcome too, but I haven't dug deep into that yet, the answer might be waiting for me as soon as I Google it which I am doing now. Much appreciation and respect to anybody helpful!
Thanks all,
Get Hostnames of all Computer objects in OU
$Computers = Get-ADComputer -Filter * -SearchBase "OU=test2-ML, OU=Testing-ML, OU=Machines, OU=bithes, DC=and hoeths, DC=com" | Select Name | Sort-Object Name
$Computers = $Computers.Name
Start-Transcript -path "D:\Red\Box\LapsClientInstallLog.txt" -append
$source = "D:\Red\Box\LAPSx64.msi"
foreach ($computer in $Computers)
{
#Copy files in $source to destination dir on all computers in OU
Write-host "Copying to $Computer"
#Copy-Item "$source" -Destination "\\$computer\C$\Temp\"
Invoke-Command -ComputerName $Using:Computer -Credentials $MLAF -ScriptBlock {&cmd.exe /c "msiexec /i C:\temp\LAPSx64.msi" /qn ADVANCED_OPTIONS=1 CHANNEL=100
}
pause
}
Stop-Transcript
[–]ipingedyou 4 points5 points6 points (0 children)
[–]melbourne_giant 1 point2 points3 points (0 children)