So, I'm trying to push some software out (McAfee installer) via powershell and WinRM. I've pulled all my hostname from VMware and am just looping through them. I've enabled WinRM via GPO, disabled UAC, and firewall hole is either open or totally off; temporarily.
So, I do this:
#loop through machines file ForEach ($machine In $objMachines) { #a '#' or leading space is a comment; skip line if( ($machine -match "^#.*") -or ($machine -match "^\s.*") -or ($machine -match "^\s*$") ) { #next loop object; ie: next line continue; } #VMs are powered on; run command (powershell) write-host 'Running command on ' -NoNewLine write-host $machine -foregroundcolor 'Red' #create PS session $session = New-PSSession -ComputerName $machine -Credential $objCred -Authentication CredSSP #run remote or local script Invoke-Command -Session $session -FilePath $strCmd #run local command / installer Invoke-Command -Session $session -ScriptBlock $strLocalBlock #cleanup session Remove-PSSession -Session $session }
The $strCmd is just a UNC path to a PS1 script and it works fine. I've tried including the last piece in the PS1 or the ScriptBlock and it doesn't work either way.
The final command, $strLocalBlock, is: 'c:\temp\mcafee\mcafee.exe /install=agent /silent /forceinstall';
I can log in via RDP and from a none "run as admin" admin PS shell I able to run that and it installs. However, from a PSSession it just silently fails.
The c:\temp\mcafee\ is local on the remote machine and the PS1 script from the first command is just checking / creating the path, setting permissions and copy the EXE over to be local on the server.
Thoughts?