-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEnable-PSRemotingFromList.ps1
More file actions
23 lines (19 loc) · 926 Bytes
/
Copy pathEnable-PSRemotingFromList.ps1
File metadata and controls
23 lines (19 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Enable-PSRemotingFromList.ps1
# Enables PowerShell Remoting on a list of PCs using PsExec
# Requires PsExec in PATH and admin credentials
# PC names listed one per line in the text file
# --- Configuration ---
$PCListFile = "C:\Temp\Whirley-PCs.txt"
$AdminUser = "<DomainOrAdmin>" # e.g., "CONTOSO\Administrator"
$AdminPass = "<Password>" # e.g., "P@ssw0rd" (consider using Get-Credential instead)
# ---------------------
Write-Host "--- Enabling PSRemoting on PCs from $PCListFile ---" -ForegroundColor Cyan
foreach ($i in Get-Content $PCListFile) {
if (Test-Connection -ComputerName $i -Quiet -Count 1) {
Write-Host "Enabling PSRemoting on $i ..." -ForegroundColor Yellow
psexec \\$i -u $AdminUser -p $AdminPass -h PowerShell "Enable-PSRemoting -Force"
} else {
Write-Host "Skipping $i (unreachable)" -ForegroundColor Red
}
}
Write-Host "Done." -ForegroundColor Green