Skip to content

Instantly share code, notes, and snippets.

@adbertram
Created September 7, 2017 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adbertram/d19fda7ef37569780dd45a4ef02d07c9 to your computer and use it in GitHub Desktop.
Save adbertram/d19fda7ef37569780dd45a4ef02d07c9 to your computer and use it in GitHub Desktop.
$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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment