I have a script I am using to automate WSUS processes, and the last stage of it goes on to remove all old/unnecessary files/objects.
I would like to prompt 'Press 'Enter' to continue with removal or any other key to stop' before the cleanup stage to give people the option to not run it.
The code I currently have at the end of the script is here:
Get-WsusServer 10.1.1.25 -PortNumber 8530 | Get-WsusUpdate -Classification All -Approval Unapproved -Status FailedOrNeeded | Approve-WsusUpdate -Action Install -Target $ComputerTarget -Verbose
Write-Host "Updates have been approved!"
Write-Host "Preparing to clean WSUS Server of obsolete computers, updates, and content files."
#Part2 - WSUS Server Cleanup
##Run Cleanup Command
Get-WsusServer $WSUS_Server -PortNumber $PortNumber | Invoke-WsusServerCleanup -CleanupObsoleteComputers -CleanupObsoleteUpdates -CleanupUnneededContentFiles
Just prior to #Part2 I would like to have the prompt 'Press enter to continue or any other key to abort'
Is there a simple way to do this?
Everything I've seen appears to involve nesting the entire script inside of a code block which I'd rather not do. =/