Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $servers = Get-Content -Path C:\servers.txt
- $folder = 'C:\Foo'
- $user = 'foo'
- $pass = 'password'
- $secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
- $cred = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)
- $servers | foreach {
- Copy-Item -Path $folder -Destination "\\$serverName\c$" -Recurse
- Invoke-Command -ComputerName $_ -ScriptBlock { C:\folder\file.exe } -Credential $cred
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement