Created
July 29, 2017 18:58
-
-
Save kevinblumenfeld/ff54b2aeea7b2556390a05ad8ae0d325 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
foreach ($comp in $computers) { | |
New-PSSession -ComputerName $comp -Credential $Credential | |
$TargetSess = (Get-PSSession -ComputerName $comp -Credential $Credential | where {$_.State -eq 'opened'}) | |
$destination = "c:\scripts\R" | |
Copy-Item \\source\R\* -Destination $destination -ToSession $TargetSess -Force | |
$ScriptBlock = { | |
cd "C:\scripts\R"; | |
. .\Remove-PreviousOfficeInstalls.ps1 | |
Remove-PreviousOfficeInstalls | |
} | |
Invoke-Command -SessionName $TargetSess -ScriptBlock $ScriptBlock -AsJob -JobName $comp -Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment