dcg

Windows PowerShell Cmdlets

windows.powershell

Protects against destructive PowerShell cmdlets: registry/provider deletes (`Remove-Item HKLM:\`, `Remove-ItemProperty`, `Remove-PSDrive`), account/task removal (`Remove-LocalUser`, `Unregister-ScheduledTask`), `Disable-ComputerRestore`, forced `Stop-Computer`/`Restart-Computer`, and `Remove-VM`/`Remove-AppxPackage`.

  • 9blocking rules
  • 1safe patterns
  • 5High
  • 4Medium
~/.config/dcg/config.toml
[packs]
enabled = ["windows.powershell"]

Evaluated when a command contains Remove-Item, remove-item, ri, RI, Remove-ItemProperty, remove-itemproperty, Clear-Item, clear-item, Remove-PSDrive, remove-psdrive.

Blocking rules

Each rule ID is windows.powershell:<name>. Use it in allowlists and [policy.rules].

  1. disable-computerrestore

    High

    Disable-ComputerRestore turns off System Restore and discards restore points.

    Explanation
    `Disable-ComputerRestore` turns off System Restore for a drive and deletes its existing restore points — removing a key local recovery path, much like deleting shadow copies. Safer alternatives: - Get-ComputerRestorePoint: review existing restore points first - Checkpoint-Computer: create a restore point rather than disabling protection
  2. remove-item-provider

    High

    Remove-Item against a registry/cert/WSMan provider path deletes that store entry.

    Explanation
    `Remove-Item HKLM:\...` (or `HKCU:`/`Cert:`/`WSMan:`) deletes a registry key, certificate, or WSMan config item — not a file. The registry/cert stores have no Recycle Bin, and a wrong key can break apps, services, or trust. Safer alternatives: - Get-ItemProperty / Get-ChildItem on the path to confirm contents first - Export the key (reg export) before removing it
  3. remove-itemproperty-or-clear

    High

    Remove-ItemProperty / Clear-Item* deletes registry values or item contents.

    Explanation
    `Remove-ItemProperty` deletes a registry value; `Clear-Item`/`Clear-ItemProperty` wipe an item's contents/value. Against the registry these silently remove configuration with no undo. Safer alternatives: - Get-ItemProperty: read the value first - Export the parent key before changing values
  4. remove-localuser-or-group

    High

    Remove-LocalUser / Remove-LocalGroup deletes a local account or group.

    Explanation
    `Remove-LocalUser`/`Remove-LocalGroup` permanently deletes a local account or group and its access. The user's profile/data can be orphaned and there is no undo. Safer alternatives: - Get-LocalUser: confirm the account first - Disable-LocalUser: disable reversibly instead of deleting
  5. remove-vm-or-snapshot

    High

    Remove-VM / Remove-VMSnapshot deletes a virtual machine or its checkpoints.

    Explanation
    `Remove-VM` deletes a Hyper-V virtual machine's configuration; `Remove-VMSnapshot`/`Remove-VMCheckpoint` deletes its checkpoints (a recovery path). Targeting the wrong VM destroys it or its ability to roll back. Safer alternatives: - Get-VM: confirm the VM name first - Export-VM / Checkpoint-VM before removing anything
  6. force-stop-or-restart-computer

    Medium

    Stop-Computer/Restart-Computer -Force shuts down/reboots without saving work.

    Explanation
    `Stop-Computer -Force` / `Restart-Computer -Force` powers off or reboots immediately, bypassing apps' save/close prompts — unsaved work in any running program is lost, and on a server it drops every session. Safer alternatives: - Drop -Force so applications can save and close cleanly - Confirm no critical work/sessions are active before forcing
  7. remove-appxpackage

    Medium

    Remove-AppxPackage uninstalls an app package (potentially for all users).

    Explanation
    `Remove-AppxPackage` uninstalls a Windows app package; with `-AllUsers` it removes it for everyone. Removing a provisioned/system app can break Windows features. Safer alternatives: - Get-AppxPackage: confirm the exact package first - Avoid -AllUsers unless you intend a machine-wide removal
  8. remove-psdrive

    Medium

    Remove-PSDrive removes a PowerShell drive mapping.

    Explanation
    `Remove-PSDrive` removes a PowerShell drive. For a persistent or system drive this can break scripts and access that depend on it. Safer alternatives: - Get-PSDrive: confirm which drive and whether anything relies on it
  9. unregister-scheduledtask

    Medium

    Unregister-ScheduledTask deletes a scheduled task.

    Explanation
    `Unregister-ScheduledTask` deletes a scheduled task. If maintenance, backups, or apps rely on it, that work silently stops running. Safer alternatives: - Get-ScheduledTask: confirm the task first - Disable-ScheduledTask: disable reversibly instead

Safe patterns

Checked first. A command that matches one is never blocked by this pack.

  • ps-whatif