forked from HumanEquivalentUnit/powershell-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCleanMatter.ps1
More file actions
17 lines (17 loc) · 739 Bytes
/
CleanMatter.ps1
File metadata and controls
17 lines (17 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$Res = Get-Content "CheckMe.txt" | Where-Object {$_.Contains("Target")}
$CT = $Res.Trim()
$CT = $CT.Substring(8)
$CT.Trim() | Out-File "Result.txt"
Remove-Item -Path "CheckMe.txt" -Force
New-Item "RunThis.cmd" -Type File -Force -Value "@Echo Off" | Out-Null
Add-Content "RunThis.cmd" "`n"
$ReadLine = Get-Content "Result.txt"
ForEach ($Line In $ReadLine) {
Add-Content "RunThis.cmd" "cmdkey /Delete:$Line"
}
Add-Content "RunThis.cmd" "net use * /DEL"
Add-Content "RunThis.cmd" "cmdkey /Delete:WindowsLive:target=virtualapp/didlogical"
Add-Content "RunThis.cmd" "cmdkey /Delete:$Env:ComputerName"
Add-Content "RunThis.cmd" "cmdkey /Delete /ras"
Remove-Item -Path "CheckMe.cmd" -Force
Remove-Item -Path "Result.txt" -Force