smartguy5000

MSI with args

Apr 29th, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $computers = Get-ADComputer -filter *
  2.     #or
  3. $computers = get-content computerlist.txt
  4. #Run 'Enable-WSManCredSSP -Role Server' on the server where the UNC share where your MSI is located
  5.  
  6. ForEach ($computer in $computers)
  7. {
  8. Enable-WSManCredSSP -Role Client -DelegateComputer $computer.$env:USERDNSDOMAIN
  9. $session = New-PSSession -ComputerName $computer -Authentication Credssp
  10. Invoke-Command -SessionName $session.Name -ScriptBlock {copy-item -Path '\\UNCShare\fakepath\remote msi' -Destination 'c:\fakepath\msipath' ; $msi = Start-Process -FilePath msiexec.exe -ArgumentList 'c:\fakepath\msipath.msi Arguments' -wait -PassThru; Write-Output $msi;Disable-WSManCredSSP -Role Client}
  11. Remove-PSSession $session
  12. }
Advertisement
Add Comment
Please, Sign In to add comment