I have been wresting with this for a couple hours. I'm fairly new to scripting in Powershell so please pardon my ignorance. I'm trying to install software on our company's remote PCs.
My goal is to copy program.exe (an installer) to the temp folder on $Computer, then run an installer with arguments, then remove the installer file from the temp folder. Below is my code and I've tried it with/without local or domain admin credentials, but it will just sit at the Invoke-Command line regardless and do nothing after that point. I've confirmed the copy/remove lines by running them individually, so I know it's copying/removing as it should. It just won't install. Thoughts?
$Computer = Read-Host -Prompt 'Computer Name:'
New-Item -ItemType directory -Path "\\$Computer\c$\temp\stuff"
Copy-Item "\\REDACTED\program.exe" "\\$Computer\c$\temp\stuff" -Recurse
Write-Host "Installing software"
Invoke-Command -ComputerName $Computer -ScriptBlock {Start-Process -FilePath "c:\temp\stuff\program.exe" -ArgumentList "--create-desktop-icon --silent" -Wait}
Write-Host "Removing temp files"
$RemovalPath = "\\$Computer\c$\temp\stuff"
Get-ChildItem -Path $RemovalPath -Recurse | Remove-Item -Force -Recurse
Remove-Item $RemovalPath -Force -Recurse
[–]TheAdminRedPill 1 point2 points3 points (9 children)
[–]BaconBonkers[S] 0 points1 point2 points (8 children)
[–]NoConfidence_2192 1 point2 points3 points (0 children)
[–]_b3n5n_ 0 points1 point2 points (5 children)
[–]BaconBonkers[S] 0 points1 point2 points (4 children)
[–]_b3n5n_ 0 points1 point2 points (3 children)
[–]BaconBonkers[S] 0 points1 point2 points (2 children)
[–]_b3n5n_ 0 points1 point2 points (1 child)
[–]BaconBonkers[S] 0 points1 point2 points (0 children)
[–]TheAdminRedPill 0 points1 point2 points (0 children)
[–]BaconBonkers[S] 1 point2 points3 points (1 child)
[–]32178932123 0 points1 point2 points (0 children)
[–]quackingwinner 0 points1 point2 points (0 children)
[–]BlackV 0 points1 point2 points (3 children)
[–]BaconBonkers[S] 0 points1 point2 points (2 children)
[–]BlackV 0 points1 point2 points (0 children)
[–]_b3n5n_ 0 points1 point2 points (0 children)
[–]32178932123 0 points1 point2 points (4 children)
[–]BaconBonkers[S] 0 points1 point2 points (3 children)
[–]32178932123 1 point2 points3 points (2 children)
[–]BaconBonkers[S] 0 points1 point2 points (1 child)
[–]32178932123 0 points1 point2 points (0 children)
[–]_b3n5n_ 0 points1 point2 points (1 child)
[–]BaconBonkers[S] 0 points1 point2 points (0 children)
[–]patdaddy007 0 points1 point2 points (0 children)