PowerShell Cmdlet Deep Dive: Disable-ComputerRestore
Welcome back to Wahmans PowerShell Blog! Today we’re going to explore a lesser-known but powerful cmdlet: Disable-ComputerRestore. As per Microsoft’s documentation, this cmdlet disables the System Restore feature on the specified file system drive.
This can be useful for system administrators or power users who need to manage system restore points efficiently, especially on systems where restore points shouldn’t be created due to performance or security policies.
Syntax
Disable-ComputerRestore [-Drive] <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
Let’s go through four practical examples, starting from beginner level up to more advanced usage.
Example 1: Disable System Restore on C: Drive
This is the simplest use case. You want to disable System Restore on the C: drive on your local machine.
Disable-ComputerRestore -Drive "C:\"
This will immediately disable the System Restore feature for the C: drive.
Example 2: Disable System Restore on Multiple Drives
Suppose you have multiple drives (C:, D:, and E:) and you want to disable System Restore on all of them in one go.
Disable-ComputerRestore -Drive "C:\", "D:\", "E:\"
This handy one-liner will disable System Restore across multiple target drives.
Example 3: Disable System Restore Remotely Using PowerShell Remoting
Let’s say you want to disable System Restore on a remote machine called REMOTEPC01. You’d need to use PowerShell remoting:
Invoke-Command -ComputerName REMOTEPC01 -ScriptBlock {
Disable-ComputerRestore -Drive "C:\"
}
Make sure that PowerShell Remoting is enabled on the remote system and that you have the necessary permissions.
Example 4: Disable System Restore on All Drives Using a Script
This advanced script loops through all local fixed drives and disables System Restore on each automatically.
$drives = Get-PSDrive -PSProvider 'FileSystem' | Where-Object { $_.Free -gt 0 -and $_.Root -match '^.:\\' }
foreach ($drive in $drives) {
Disable-ComputerRestore -Drive $drive.Root
}
This can be included in a startup script or automation task in your infrastructure to ensure System Restore is disabled everywhere it is not needed.
Final Notes
Always be cautious when disabling System Restore, especially on personal or end-user machines. System Restore can be a useful fallback in case of misconfigurations or failures, so disable it only when necessary and always in accordance with IT policies.
That’s it for today’s cmdlet spotlight!
Happy scripting, and I will see you in the next post!
Leave a Reply