You can run WinGet remotely by using PowerShell Remoting (Enter-PSSession or Invoke-Command), PsExec, or a Remote Monitoring and Management (RMM) tool. Because WinGet is installed in the user profile by default, the primary challenge is executing the command in the correct user context rather than the system account. Most remote execution methods default to a system or administrative session that lacks the necessary user-level environment variables and app execution aliases.
Using PowerShell Remoting with Invoke-Command
PowerShell Remoting is the most native way to execute WinGet commands across a network. To use this, you must first enable PowerShell Remoting on the target machine by running Enable-PSRemoting as an administrator. Once enabled, you can use the Invoke-Command cmdlet to send a specific WinGet instruction to one or multiple computers.
To successfully run WinGet, you cannot simply call "winget". You must call the full path to the executable or use the App Installer's alias. The executable is typically located in a deep folder within the Program FilesAppX directory. A more reliable method is to invoke the command through the command prompt wrapper. Use the following syntax: Invoke-Command -ComputerName TargetPC -ScriptBlock { cmd /c winget install "PackageName" --silent --accept-package-agreements --accept-source-agreements }.
The --silent and --accept flags are mandatory for remote execution. Without these, WinGet will attempt to open an interactive prompt on the remote machine's hidden session, causing the command to hang indefinitely. The session will time out after the default 30 seconds if the process waits for a user input that never appears. Ensure the target machine has the App Installer updated via the Microsoft Store before attempting remote deployment.
Executing WinGet via PsExec
PsExec, part of the Sysinternals suite, allows you to execute processes on remote systems without needing to configure WinRM. It is particularly useful for legacy environments or when PowerShell Remoting is blocked by group policy. To run WinGet with PsExec, you must use the -i switch to interact with the user session or the -s switch to run as system, though the latter often fails with WinGet due to profile restrictions.
The correct command structure is psexec \\RemoteComputer -s cmd /c winget install "PackageName". However, because WinGet is a Windows Store app, it relies on the AppX package manager. If you run as the system account (-s), WinGet may report that it is not recognized as a command. To solve this, you must specify the full path to the winget.exe located in the user's LocalAppData folder or the system-wide AppX folder. This requires knowing the exact version string in the folder path, which varies by update.
Another approach with PsExec is to launch a command prompt in the active user's session using the -i 1 flag (assuming session 1 is the active user). This allows WinGet to access the user's profile and the Microsoft Store licenses associated with that account. This method is more likely to succeed with packages that require user-level installation rather than machine-wide installation.
Handling the System Account and User Context
The most common failure when running WinGet remotely is the "command not found" error. This happens because WinGet is not a global system binary; it is an alias for a package installed in the user's profile. When you connect via SSH or WinRM, you are often placed in a non-interactive session that does not load the user's environment variables or the App Execution Aliases path.
To bypass this, you can create a system-wide alias or a symbolic link. Create a directory like C:\WinGet and create a symbolic link to the winget.exe file. This allows any remote session, regardless of the user context, to call the executable via a static path. Alternatively, you can use a scheduled task. Create a task on the remote machine that runs as the logged-in user and trigger that task remotely using the SchTasks command.
Comparing the different execution contexts helps determine which method to use based on the software being installed:
| Context | Access Level | WinGet Behavior | Best Use Case |
|---|---|---|---|
| User Session | User Permissions | Full access to Store apps | User-specific tools (VS Code) |
| System Account | Full Administrative | Limited to machine-wide installers | Drivers and System Utilities |
| Admin Session | Elevated User | Can install most software | Standard Enterprise Apps |
Automating Deployments with RMM Tools
Remote Monitoring and Management (RMM) tools provide a more scalable way to run WinGet than manual PowerShell scripts. Most RMMs allow you to push a script to a group of machines. To make this work, the script must explicitly handle the environment path. Instead of calling "winget", the script should first locate the winget.exe path dynamically using a PowerShell search command: Get-ChildItem -Path "C:\Program Files\WindowsApps" -Filter "winget.exe" -Recurse.
Once the path is found, the RMM can execute the install command. For example, if the path is C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe, the RMM should call that full string. This removes the dependency on the user's PATH environment variable. You should also include a check to see if the application is already installed using "winget list" to avoid redundant installation attempts that could trigger restart prompts.
When using RMMs, always wrap the command in a try-catch block. WinGet returns specific exit codes that the RMM can use to report success or failure. An exit code of 0 indicates success, while codes like 0x8a15001a indicate that the package was not found. Logging the output of the command to a local text file on the remote machine is recommended for auditing purposes since RMM consoles often truncate long output strings.
Troubleshooting Common Remote WinGet Errors
The error "winget is not recognized as an internal or external command" is the most frequent issue. This is solved by using the full path to the executable or by running the command through a shell that loads the user profile. If you are using PowerShell, try using Start-Process with the -Verb RunAs parameter to ensure the process has the necessary elevation, though this is difficult in a completely headless remote session.
Another common issue is the "Agreement" prompt. Even with the --accept-package-agreements flag, some packages have secondary prompts. To resolve this, ensure you are using the latest version of the App Installer. You can force an update of the App Installer remotely by using the command: Add-AppxPackage -Register "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller*\AppxManifest.xml". This ensures the remote machine is using the most recent version of the WinGet engine.
Network timeouts can also occur if the remote machine is behind a proxy. WinGet uses the system proxy settings, but remote sessions may not inherit these settings. You may need to configure the proxy for the system account specifically using netsh winhttp set proxy proxy-server="http=yourproxy:port". Without this, WinGet will fail to connect to the Microsoft Community Repository, resulting in a connection error during the "searching for package" phase.
Advanced Scripting for Mass Remote Installation
For deploying software to 10 or more machines, a loop script in PowerShell is the most efficient method. Create a text file containing the list of target computer names. Use the Get-Content cmdlet to read this list and pipe it into a foreach loop. Inside the loop, use Invoke-Command to execute the installation. This allows you to track which machines succeeded and which failed in real-time.
Example logic for a mass deployment script: Read the computer list, check for connectivity using Test-Connection, and then execute the WinGet command. If the command fails, the script should log the computer name and the error code to a CSV file. This prevents the entire deployment from stopping if one machine is offline or has a corrupted App Installer installation.
To ensure stability, include a delay of 5 to 10 seconds between machine executions if you are on a limited bandwidth connection. This prevents the local network from being saturated by multiple simultaneous downloads of large installers from the Microsoft servers. Additionally, use the --source winget flag to ensure the tool only looks in the official repository and ignores any third-party sources that might be configured on individual machines, which could lead to inconsistent versioning across your fleet.