Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. $servers = Get-Content -Path C:\servers.txt
  2. $folder = 'C:\Foo'
  3.  
  4. $user = 'foo'
  5. $pass = 'password'
  6.  
  7. $secpasswd = ConvertTo-SecureString $pass -AsPlainText -Force
  8. $cred = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)
  9.  
  10. $servers | foreach {
  11. Copy-Item -Path $folder -Destination "\\$serverName\c$" -Recurse
  12. Invoke-Command -ComputerName $_ -ScriptBlock { C:\folder\file.exe } -Credential $cred
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement