A PowerShell script that installs Anaconda on remote Windows machines via PowerShell remoting (WinRM).
- Local machine: PowerShell 5.1+, Administrator privileges
- Remote machine: WinRM enabled, admin share accessible (
\\hostname\C$) - Network: DNS resolution, ICMP (ping), and WinRM (TCP 5985/5986) allowed
# Display help
.\Install-Anaconda.ps1
.\Install-Anaconda.ps1 -Help
# Install using hostname
.\Install-Anaconda.ps1 -ComputerName "SERVER01"
# Install using IP address
.\Install-Anaconda.ps1 -ComputerName "10.0.0.100"Edit these variables at the top of the script (lines 50-55):
| Variable | Description | Default |
|---|---|---|
NetworkSharePath |
UNC path to installer location | \\SMB\Shared\ |
InstallerFilename |
Anaconda installer filename | Anaconda3-2025.12-1-Windows-x86_64.exe |
RemoteTempPath |
Temp directory on remote machine | C:\Temp |
AnacondaInstallPath |
Anaconda install location | C:\ProgramData\Anaconda3 |
AddToPath |
Add Anaconda to system PATH | $true |
RegisterAsSystemPython |
Register as default Python | $false |
LOCAL MACHINE
─────────────────────────────────────────────────────
1. Administrator Check
- Verifies script is running elevated
- Exits with code 1 if not admin (red text)
2. Input Check
- If no -ComputerName provided, displays help menu
- If -Help flag used, displays help menu
3. Pre-flight Connectivity Checks (Test-TargetConnectivity)
- DNS resolution ([System.Net.Dns]::GetHostEntry)
- ICMP ping test (Test-Connection, 2 packets)
- WinRM availability test (Test-WSMan)
4. File Copy via Admin Share (Copy-InstallerToRemote)
- Checks/creates \\hostname\C$\Temp directory
- Verifies source installer exists on network share
- Copies installer via admin share (avoids double-hop)
- Verifies file exists at destination
5. Remote Installation (Invoke-RemoteInstall)
│
▼
REMOTE MACHINE (via Invoke-Command)
─────────────────────────────────────────────────────
6. Run Silent Installation
- Executes: installer.exe /S /AddToPath=1 /D=<path>
- Waits for process to complete
- Captures NSIS exit code
7. Verify Installation
- Checks if conda.exe exists in Scripts folder
8. Cleanup
- Removes installer from C:\Temp
9. Return result object to local machine
│
▼
LOCAL MACHINE
─────────────────────────────────────────────────────
10. Display Remote Messages
- Color-coded: Red=ERROR, Yellow=WARNING, Gray=INFO
11. Exit with Appropriate Code
Validates connectivity before attempting installation:
- DNS Test: Resolves hostname via
[System.Net.Dns]::GetHostEntry - Ping Test:
Test-Connectionwith 2 ICMP packets - WinRM Test:
Test-WSManverifies PowerShell remoting is available
Copies installer to remote machine via admin share:
- Uses
\\hostname\C$\Temppath (avoids WinRM double-hop issue) - Creates destination directory if it doesn't exist
- Verifies source file exists before copying
- Confirms file arrived at destination after copy
Executes on the remote machine via Invoke-Command:
- Verifies installer exists at
C:\Temp - Builds installer arguments from configuration
- Runs installer silently with
Start-Process -Wait - Verifies
conda.exeexists after installation - Cleans up installer file
- Returns result object with exit code and messages
Executes the remote scriptblock and handles results:
- Calls
Invoke-Commandwith the scriptblock - Displays color-coded messages from remote execution
- Returns final exit code
| Switch | Description |
|---|---|
/S |
Silent mode (no GUI) |
/AddToPath=1 |
Add to system PATH (0=no, 1=yes) |
/RegisterPython=0 |
Register as system Python (0=no, 1=yes) |
/D=<path> |
Installation directory (must be last, no quotes) |
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Not run as Administrator |
| 10 | Target unreachable (ping failed) |
| 11 | DNS resolution failed |
| 12 | WinRM unavailable on target |
| 13 | Remote session failed |
| 20 | Failed to create temp directory |
| 21 | Source file not found |
| 22 | File copy failed |
| 23 | File copy verification failed |
| 99 | Unexpected error |
| 101 | NSIS: Installation cancelled by user |
| 102 | NSIS: Installation aborted (disk space, permissions, path) |
Anaconda uses NSIS (Nullsoft Scriptable Install System). NSIS codes are passed through as 100 + code:
- 0: Success
- 1: User cancelled
- 2: Script aborted (error during install)
The hostname could not be resolved. Verify:
- Hostname is spelled correctly
- DNS server is reachable
- Host has a DNS record (try
nslookup hostname)
Enable WinRM on the remote machine:
Enable-PSRemoting -ForceThe admin share (\\hostname\C$) is not accessible. Verify:
- You have administrative rights on the remote machine
- File and Printer Sharing is enabled
- Admin shares are not disabled via Group Policy
Verify the installer path and filename:
- Check
NetworkSharePathpoints to correct location - Check
InstallerFilenamematches exactly, including.exeextension - Verify you have read access to the network share
NSIS may report success when installation fails silently. Check:
- Sufficient disk space on remote machine
- Write permissions to install path
- Path length under 260 characters
This project is licensed under the MIT License - feel free to use, modify, and distribute.