Created
September 7, 2017 22:42
-
-
Save adbertram/d19fda7ef37569780dd45a4ef02d07c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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