Scripts are a gentle reminder of the early days of automation. Scrips are everywhere; computers have been using them forever. And it eventually extended to the web as technology became more powerful.
Like an actor to the script at hand, computers execute scripts when they are invoked. The actual code may be hidden and invoked using a simple one-liner command, but scripts are a useful way to automate mundane tasks.
What is a script?
In simple terms, a script is a set of instructions that executes when it is invoked. It is similar to an object in computer programming that doesn’t have to be explicitly defined every time it’s needed. However, while it is related to programming, scripting is different. For instance, a script is not compiled at runtime and is executed by an interpreter.
While scripts are not as complex, they are useful for taking away manual control from small tasks, such as executing a program at a particular condition or running a disk cleanup after a specified number of days.
Useful scripts for every IT professional
As an IT professional or an individual with a computer, scripts can save you a lot of time.
Atera’s Remote Monitoring and Management platform allows you to create and schedule scripts. So, as a technician working offsite or an IT administrator in an office, you simply need to schedule a task and let Atera’s software do its magic.
We have compiled a list of scripts to hopefully make you’re work-life a little easier.
Disable USB Storage
Are you worried that employees working on a super confidential project may copy files? This script allows you to disable USB access on the computer. It will not break the function with input devices like a keyboard and mouse but only prevent a user from plugging in a USB storage device like a USB thumb drive or an external HDD/SSD.
reg add HKLM\SYSTEM\CurrentControlSet\Services\UsbStor /v "Start" /t REG_DWORD /d "4" /f
DNS is an address book for the internet that allows websites to be translated into IP addresses. What seems like a quick process actually involves multiple steps. Operating systems speed this much by building a cache of the most visited websites.
Clearing the DNS cache helps when the cache has outdated information. For example, if a website moves to a different server, the older IP address will no longer return the web page.
It is important to clear DNS cache frequently to avoid running into issues, especially in a web development environment.
Renew IP Address
Renewing the IP address could resolve “no internet connectivity” issues. You will first have to release the current IP address and request a new one from the DCHP server.
Upgrade Microsoft Office
Microsoft Office is one of the leading productivity software for creating text documents, spreadsheets, presentation slides, and more. Although cloud-based versions exist, having Microsoft Office locally on the machine continues to be the de-facto way to create documents.
As an IT professional, you can use this script to automatically upgrade a PC to the latest version of Microsoft Office.
setlocal reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration\ /v CDNBaseUrlif %errorlevel%==0 (goto SwitchChannel) else (goto End)
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v CDNBaseUrl /t REG_SZ /d "http://officecdn.microsoft.com/pr/492350f6-3a01-4f97-b9c0-c7c6ddf67d60" /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v UpdateUrl /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration /v UpdateToVersion /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Updates /v UpdateToVersion /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Office\16.0\Common\OfficeUpdate\ /f
Weekly system maintenance
Certain actions like creating a restore point can save you from the problems of reinstalling the operating system entirely. A restore point is like a checkpoint in a video game that can be reloaded if the operating system becomes unstable. The restore point will revert the operating system to the last known stable state.
This Power Shell script will also remove the temporary junk from Windows folders.
Checkpoint-Computer -Description "Weekly Maintanence" -RestorePointType "MODIFY_SETTINGS"
Write-Host "System Restore Point created successfully"
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace(0xA)
$temp = get-ChildItem "env:\TEMP"
$temp2 = $temp.Value
$WinTemp = "c:\Windows\Temp\*"
write-Host "Removing Junk files in $temp2." -ForegroundColor Magenta Remove-Item -Recurse "$temp2\*" -Force -Verbose
write-Host "Removing Junk files in $WinTemp." -ForegroundColor Green Remove-Item -Recurse $WinTemp -Force
Clear event logs
This PowerShell script is an easy way to clear out all event logs. The event logger is a component of the Windows operating system that records errors, such as when a program or the operating system suffers a crash.
System administrators can view the event logs to see what caused the behaviour. If you want to clear out the event logs, here’s a simple script for that.
for /F %%a IN (?wevtutil el?) DO (wevtutil.exe cl %%a >nul 2>&1)
IF (%adminTest%)==(Access) goto noAdmin
for /F "tokens=*" %%G in ('wevtutil.exe el') DO (call :do_clear "%%G")
echo Event Logs have been cleared!
echo clearing %1
wevtutil.exe cl %1
echo You must run this script as an Administrator!
Utilize Atera’s shared script library to supercharge your IT automation
The shared script library gives you access to hundreds of scripts created and shared by the growing community of Atera. Access these powerful scripts from within your RMM dashboard to clone them into your personal library or schedule a script execution for remote management.
See Atera in Action
RMM Software, PSA and Remote Access that will change the way you run your MSP Business