Created
April 19, 2019 14:14
-
-
Save asvignesh/ecae8d19d5c39da015907288b089b3a7 to your computer and use it in GitHub Desktop.
Run Remote powershell and delete shadows on all machines
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
$nodes = @("nim-win1-4.asvigneshad.local","nim-win2-5.asvigneshad.local","nim-win3-3.asvigneshad.local","nim-win4-1.asvigneshad.local","nim-win5-5.asvigneshad.local") | |
$username = "asvigneshad\administrator" | |
$password = "Password" | |
$secstr = New-Object -TypeName System.Security.SecureString | |
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)} | |
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr | |
For ($i=0; $i -lt $nodes.Length; $i++) { | |
$sess = New-PSSession -Credential $cred -ComputerName $nodes[$i] | |
Enter-PSSession $sess | |
$script = "./tmp.dsh" | |
"delete shadows all" | Set-Content $script | |
diskshadow /s $script | |
Remove-Item $script | |
Exit-PSSession | |
Remove-PSSession $sess | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment