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 foundRelated 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.junkTechnical Explanation
Why this works:
sudo pwshlaunches an elevated PowerShell instance (pwsh.exe is an executable)- The
-commandparameter passes the cmdlet instruction to the elevated session - Within the elevated PowerShell context,
move-itemcmdlet is available
Alternative Approaches
-
Elevated PowerShell Session:
sudo pwsh # Then run move-item normally in the child shell session -
Standard Windows Approach:
# Launch PowerShell manually as administrator # Then: move-item -path AdobeCollabSync.exe -destination AdobeCollabSync.exe.unwanted.junk