среда, 7 апреля 2021 г.

Delete all computers from WSUS - PowerShell script

# This PowerShell mini-script written by Vladisla2000 is fully ready 

# and should work without any customization to your environment.

cls

$GetWSUS = Get-WsusServer # Get WSUS server as an object

$ComputersObjects = Get-WsusComputer # Gets all computers in WSUS

$ComputersDomainNames = $ComputersObjects.FullDomainName # Extracts Domain names of computers

# Every computer in the loop is deleted

ForEach($Comp in $ComputersDomainNames)

{

Write-Host ""

Write-Host I am deleting "'$Comp'" ... -ForegroundColor Green

($GetWSUS).GetComputerTargetByName("$Comp").Delete() # The main line in the script

Write-Host "'$Comp'" was deleted -ForegroundColor Yellow

}

Write-Host ""

Write-Host FINISHED! -ForegroundColor Green -BackgroundColor Red