powershell

sethayes

·

step09

·

Powershell

·

Total Size: 3.37 KB

·

·

Created: 5 years ago

·

Edited: 5 years ago

$Log = "C:\Users\Public\Log.txt" [bool]$restart = $false filter timestamp {"$(Get-Date -Format G) | $_"} $publicPath = "C:\Users\Public" $files = @("dotNET.exe","s1_V2_635948","WMF5.msu","win-updates.ps1","KB2533623x86.msu","KB2758857x86.msu","KB3033929x86.msu","KB3033929x64.msu","KB3123479x86.msu","3123479x64.msu","OffScrub03.vbs","OffScrub07.vbs","OffScrub10.vbs","OffScrub_O15msi.vbs","OffScrub_O16msi.vbs","OffScrbuc2r.vbs","O3652016.zip","Remove-PreviousOfficeInstalls.ps1") ForEach ($f in $files) { $file = "$publicPath\$f" If (Test-Path $file) { Write-Output "Deleting $file from C:\Users\Public Folder..." | timestamp Write-Output "Deleting $file from C:\Users\Public Folder..." | timestamp | Out-File $Log -Append Remove-Item -Force -Confirm:$false Write-Output "`t...$file has been Deleted" | timestamp Write-Output "`t...$file has been Deleted" | timestamp | Out-File $Log -Append } } If (Test-Path "C:\Users\Public\Office") { Write-Output "Deleting all items from C:\Users\Public\Office Folder..." | timestamp Write-Output "Deleting all items from C:\Users\Public\Office Folder..." | timestamp | Out-File $Log -Append Get-ChildItem -Path "C:\Users\Public\Office" -Recurse | Remove-Item -Force -Recurse -Confirm:$false Write-Output "`t...All items from C:\Users\Public\Office have been Deleted." | timestamp Write-Output "`t...All items from C:\Users\Public\Office have been Deleted." | timestamp | Out-File $Log -Append Write-Output "`tDeleting the C:\Users\Public\Office Folder..." | timestamp Write-Output "`tDeleting the C:\Users\Public\Office Folder..." | timestamp | Out-File $Log -Append Remove-Item "C:\Users\Public\Office" -Force -Confirm:$false Write-Output "`t`t...The C:\Users\Public\Office Folder has been Deleted." | timestamp Write-Output "`t`t...The C:\Users\Public\Office Folder has been Deleted." | timestamp | Out-File $Log -Append } $steps = @(Get-ChildItem "C:\Users\Public" | Where-Object {($_.Name -like "*step0*") -and (!($_.Name -like "*step09.ps1")) -and ($_.Extension -eq ".ps1")} | Select-Object FullName).FullName ForEach ($step in $steps) { Write-Output "Deleting $step from C:\Users\Public Folder..." | timestamp Write-Output "Deleting $step from C:\Users\Public Folder..." | timestamp | Out-File $Log -Append Remove-Item $step -Force -Confirm:$false Write-Output "`t...$step has been Deleted" | timestamp Write-Output "`t...$step has been Deleted" | timestamp | Out-File $Log -Append } Write-Output "Removing the Registry Setting for Which Step to do Next..." | timestamp Write-Output "Removing the Registry Setting for Which Step to do Next..." | timestamp | Out-File $Log -Append Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "ScriptStep" -Force -Confirm:$false Write-Output "`t...Registry Setting for Which Step to do Next has been Deleted" | timestamp Write-Output "`t...Registry Setting for Which Step to do Next has been Deleted" | timestamp | Out-File $Log -Append Set-ExecutionPolicy = (Get-Content C:\Users\Public\exPolicy.txt) $t = (Get-Date -Format g) Write-Output "$t | Delting Myself. Goodbye Cruel World..." Write-Output "$t | Delting Myself. Goodbye Cruel World..." | Out-File $Log -Append Remove-Item -LiteralPath $MyInvocation.MyCommand.Path -Force

2 bits

1625 views

Are you sure you want to delete?