Run the following (update the list
to contain valid KB numbers) to uninstall updates on a local system:
@ECHO OFFSET list=3133977 3137061 3138612 3138901 3139923for %%a in (%list%) do (%windir%\syswow64\wusa.exe /uninstall /kb:%%a /quiet /norestart /log)
Run the following (update the hosts
list with valid hostnames) to get .CSV output of updates on remote systems:
@echo offSET dFormat=_%date:~-4,4%%date:~-10,2%%date:~-7,2%SET sCMDparams=qfe get Caption, Description, HotfixID, InstallDate, InstalledBy /format:csvSET hosts=HOSTNAME1 HOSTNAME2ECHO %dFormat%ECHO .FOR %%f in (%hosts%) DO (ECHO Processing %%fECHO Output file: %%f_%dFormat%.csvwmic /NODE:%%f /output:%%f_%dFormat%.csv %sCMDparams%)ECHO .ECHO Remember to delete the first blank lineECHO .ECHO .ECHO Finished.ECHO .
msg susie /SERVER:WKST-ABC.burmat.co "Please call 123-456-7890 x369"
Or you can launch it to all users on a given computer if you don't know the username. Enable verbose mode (/V
) and wait for a callback (/W
) to get a callback when the user closes it:
msg * /V /W /SERVER:WKST-123 This is a test message
This script is better kept out in a public place and called with the a remote command utility to loop through a list of hostnames. You can just replace the %1
to hardcode a host if you want though.
@echo offREM shutdown -m \\%1 /aecho Start Checking %1ping -n 1 -l 100 %1IF %ERRORLEVEL%==1 GOTO BADshutdown -r -f -m \\%1 -t 300 -d up:125:1 -c "Please SAVE Your work. In 5 minutes, this machine will reboot for a policy updates (Msg time: %time%)"GOTO GOOD:BADECHO %1,Failed,%date%,%time% >> BadPCs.txtGOTO EXIT:GOODECHO %1,Good,%date%,%time% >> GoodPCs.txtGOTO EXIT:EXITecho Stop Checking %1
When you need to comment out or uncomment out a line, sed makes it pretty easy. Just change the word pattern to something identifiable:
sed -i '/pattern/s/^/#/g' apache2.conf # commentsed -i '/pattern/s/^#//g' apache2.conf # uncomment
PS C:\WINDOWS\system32> Invoke-Command -ComputerName 'SERVER01' -ScriptBlock { quser }USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIMEadmin console 1 Active none 12/24/2018 10:35 AMPS C:\WINDOWS\system32> Invoke-Command -ComputerName 'SERVER01' -ScriptBlock { logoff 1 }