Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $computers = Get-ADComputer -filter *
- #or
- $computers = get-content computerlist.txt
- #Run 'Enable-WSManCredSSP -Role Server' on the server where the UNC share where your MSI is located
- ForEach ($computer in $computers)
- {
- Enable-WSManCredSSP -Role Client -DelegateComputer $computer.$env:USERDNSDOMAIN
- $session = New-PSSession -ComputerName $computer -Authentication Credssp
- 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}
- Remove-PSSession $session
- }
Advertisement
Add Comment
Please, Sign In to add comment