Here’s a PowerShell script that can be used to scan for Windows updates, install them and optionally restart the system automatically. I’ve been using this for a few years now on Windows Server 2008 R2 and above without issues.
Continue readingCategory: Windows
For a time, I had a server with an issue where the IIS SMTP virtual server stopped due to an error. My usual automatic checks for stopped Windows services didn’t pick this up because the Windows service continued to run, even though the SMTP virtual server had stopped.
This caused some internal emails to be delayed. It was easy enough to start the virtual server again, but better to put a script in place to check the status and start the SMTP virtual server if necessary.
Continue readingHere’s a PowerShell script for a function to send email with optional attachments. It accepts a comma-separated list of attachments, or no attachments at all.
You can include this in other PowerShell scripts to make this function available, rather than having the email sending functionality repeated in multiple scripts.
Continue readingHere’s a quick one-liner that can rename multiple files with PowerShell. The rename-item cmdlet can be used to search and replace text in the original filename.
dir "c:\Work" -s | rename-item -NewName {$_.name -replace "text-to-find","repacement-text"}
Continue reading
Here’s a quick PowerShell script which allows you to set the computer description remotely.
You’ll need to run this in a PowerShell window with administrative rights for the remote PC.
$RemotePC = Read-Host -Prompt 'Input the remote computer name e.g. PC0123'
$RemoteDescription = Read-Host -Prompt 'Input the new description for the remote computer'
$PC = Get-WmiObject -class Win32_OperatingSystem -computername $RemotePC
$PC.Description = $RemoteDescription
$PC.Put()
Sometimes you need a quick and simple way to backup a user directory to a network drive/NAS share or external drive.
Here’s a batch file that will backup using Robocopy the subdirectories of your user directory to the location of your choice.
Continue readingSometimes you need to apply a group policy to an OU but prevent that same policy from applying to certain machines in the OU. Rather than creating child OUs, you could use a WMI filter. Note however that there are performance penalties…
For instance, you might need to apply a group policy which installs the 64 bit version of the Windows Management Framework to the PCs OU. This will be fine for most PCs in that OU, but maybe there are some older 32 bit Windows 7 PCs in the OU which would cause the 64 bit installer to fail.
Continue readingOn a new laptop running Windows 10, 1809, I experienced an issue that caused the boot time to increase to over 5 minutes. After the boot process eventually finished, many devices were not working correctly.
For example, I found:
- no Wi-Fi networks showing in the list before logging on
- the fingerprint scanner is not working
- after logging in, you can’t enter any text in the search bar or Windows app store apps
Sometimes a VSS writer stops working and this can usually be seen in the logs of a failed backup job.
You can check which VSS writer is in a failed state by running the command vssadmin list writers