When attempting to use Windows sudo for file operations via PowerShell commands, encountered “command not found” errors:

sudo move-item -path AdobeCollabSync.exe -destination AdobeCollabSync.exe.unwanted.junk
# ERROR: command not found

Related scenario: Disabling Adobe Collab Sync

Root Cause Analysis

Windows sudo utility is designed specifically to elevate executables, not command-line tooling or PowerShell cmdlets. The limitation stems from:

  • Architecture: Windows sudo works by elevating a new process
  • Scope: Only direct executables can be launched in an elevated context
  • PowerShell cmdlets: Not standalone executables, only available within PowerShell host environment

Workaround

Elevate the PowerShell process itself, then execute the command:

# Correct Approach:
sudo pwsh -command move-item -path AdobeCollabSync.exe -destination AdobeCollabSync.exe.unwanted.junk

Technical Explanation

Why this works:

  1. sudo pwsh launches an elevated PowerShell instance (pwsh.exe is an executable)
  2. The -command parameter passes the cmdlet instruction to the elevated session
  3. Within the elevated PowerShell context, move-item cmdlet is available

Alternative Approaches

  1. Elevated PowerShell Session:

    sudo pwsh  # Then run move-item normally in the child shell session
    
  2. Standard Windows Approach:

    # Launch PowerShell manually as administrator
    # Then: move-item -path AdobeCollabSync.exe -destination AdobeCollabSync.exe.unwanted.junk