Remote maintenance toolkit for executing maintenance tasks on shopfloor PCs via WinRM.
This script provides a comprehensive remote maintenance toolkit for managing shopfloor PCs. It executes maintenance tasks via WinRM (Windows Remote Management) and can target PCs individually, by type, by business unit, or all at once.
Location: S:\dt\shopfloor\scripts\remote-execution\Invoke-RemoteMaintenance.ps1
Key Features:
When using -All, -PcType, or -BusinessUnit targeting, the script retrieves PC lists from the ShopDB API:
GET /api.asp?action=getShopfloorPCs
GET /api.asp?action=getShopfloorPCs&pctypeid=2 # CMM PCs only
GET /api.asp?action=getShopfloorPCs&businessunitid=1 # Specific business unit
PC Type IDs:
| ID | Type | ID | Type |
|---|---|---|---|
| 1 | Shopfloor | 7 | Heat Treat |
| 2 | CMM | 8 | Engineer |
| 3 | Wax Trace | 9 | Standard |
| 4 | Keyence | 10 | Inspection |
| 5 | EAS1000 | 11 | Dashboard |
| 6 | Genspect | 12 | Lobby Display |
See: ShopDB API Reference for complete API documentation.
Enable-PSRemoting -Force)# Test WinRM connectivity
Test-WSMan -ComputerName "SHOPFLOOR-PC01"
# Test with credentials
$cred = Get-Credential
Test-WSMan -ComputerName "SHOPFLOOR-PC01" -Credential $cred
$cred = Get-Credential -Message "Enter domain admin credentials"
# Flush DNS on a single PC
.\Invoke-RemoteMaintenance.ps1 -ComputerName "SHOPFLOOR-PC01" -Task FlushDNS -Credential $cred
The script outputs status for each PC:
[SHOPFLOOR-PC01] FlushDNS: SUCCESS
DNS Resolver Cache flushed successfully
| Parameter | Type | Description |
|---|---|---|
-ComputerName |
string[] | One or more computer names or IPs |
-ComputerListFile |
string | Path to text file with hostnames |
-All |
switch | Target all shopfloor PCs from ShopDB |
-PcType |
string | Target by PC type (see PC Types) |
-BusinessUnit |
string | Target by business unit (see Business Units) |
| Parameter | Type | Description |
|---|---|---|
-Task |
string | Maintenance task to execute |
| Parameter | Type | Default | Description |
|---|---|---|---|
-Credential |
PSCredential | Prompt | Remote authentication |
-ApiUrl |
string | Production | ShopDB API endpoint |
-ThrottleLimit |
int | 5 | Max concurrent sessions |
-DnsSuffix |
string | logon.ds.ge.com | DNS suffix for resolution |
Standard, Engineer, Shopfloor, CMM, Wax / Trace, Keyence,
Genspect, Heat Treat, Inspection, Dashboard, Lobby Display, Uncategorized
TBD, Blisk, HPT, Spools, Inspection, Venture, Turn/Burn, DT
| Task | Description | Duration | Impact |
|---|---|---|---|
DISM |
Repair Windows component store | 15-60 min | Low |
SFC |
System File Checker scan | 10-30 min | Low |
| Task | Description | Duration | Impact |
|---|---|---|---|
OptimizeDisk |
TRIM (SSD) or Defrag (HDD) | 5-60 min | Medium |
DiskCleanup |
Remove temp files, updates | 5-15 min | Low |
ClearUpdateCache |
Clear Windows Update cache | 1-2 min | Low |
ClearBrowserCache |
Clear Chrome/Edge cache | 1-2 min | Low |
| Task | Description | Duration | Impact |
|---|---|---|---|
RestartSpooler |
Restart Print Spooler | <1 min | Low |
FlushDNS |
Clear DNS cache | <1 min | None |
RestartWinRM |
Restart WinRM service | <1 min | Temp disconnect |
| Task | Description | Duration | Impact |
|---|---|---|---|
SetTimezone |
Set to Eastern Time | <1 min | None |
SyncTime |
Force time sync with DC | <1 min | None |
| Task | Description | Duration | Impact |
|---|---|---|---|
UpdateEMxAuthToken |
Update eMx auth from share | 1-2 min | None |
DeployUDCWebServerConfig |
Deploy UDC config | 1-2 min | None |
| Task | Description | Duration | Impact |
|---|---|---|---|
Reboot |
Restart PC (30s delay) | 2-5 min | High |
| Task | Description | Duration | Impact |
|---|---|---|---|
InstallDashboard |
Install GE Dashboard app | 2-5 min | Medium |
InstallLobbyDisplay |
Install Lobby Display app | 2-5 min | Medium |
UninstallDashboard |
Remove GE Dashboard | 1-2 min | Low |
UninstallLobbyDisplay |
Remove Lobby Display | 1-2 min | Low |
Deployment tasks require source files to be available before execution:
| Task | Source File Path |
|---|---|
InstallDashboard |
\\tsgwp00525.wjs.geaerospace.net\dt\shopfloor\scripts\Dashboard\GEAerospaceDashboardSetup.exe |
InstallLobbyDisplay |
\\tsgwp00525.wjs.geaerospace.net\dt\shopfloor\scripts\LobbyDisplay\GEAerospaceLobbyDisplaySetup.exe |
UpdateEMxAuthToken |
\\tsgwp00525.wjs.geaerospace.net\dt\shopfloor\scripts\eMx\eMxInfo.txt |
DeployUDCWebServerConfig |
\\tsgwp00525.wjs.geaerospace.net\dt\shopfloor\scripts\UDC\udc_webserver_settings.json |
C:\Windows\Temp\ on remote PC+---------------------+ WinRM +---------------------+
| Your Workstation | ------------> | Target PC |
| | | |
| Source Files: | Push File | Temp Location: |
| - Setup.exe | ------------> | C:\Windows\Temp |
| - config.json | | |
| - eMxInfo.txt | Execute | Final Location: |
| (network) | ------------> | C:\Program Files |
+---------------------+ +---------------------+
Ensure your script directory contains the required files:
S:\dt\shopfloor\scripts\remote-execution\
├── Invoke-RemoteMaintenance.ps1
├── GEAerospaceDashboardSetup.exe # For InstallDashboard
├── GEAerospaceLobbyDisplaySetup.exe # For InstallLobbyDisplay
└── udc_webserver_settings.json # For DeployUDCWebServerConfig
The UpdateEMxAuthToken task:
\\tsgwp00525.wjs.geaerospace.net\dt\shopfloor\scripts\eMx\eMxInfo.txtC:\Program Files\GE Aircraft Engines\DNC\eMxInfo.txtC:\Program Files (x86)\GE Aircraft Engines\DNC\eMxInfo.txteMxInfo-old-YYYYMMDD-HHMMSS.txt before overwritingLDnc.exe)The DeployUDCWebServerConfig task:
C:\Program Files\UDC exists)C:\ProgramData\UDC\udc_webserver_settings.jsonBoth kiosk app installers:
/VERYSILENT)Uninstall GUIDs:
{9D9EEE25-4D24-422D-98AF-2ADEDA4745ED}{42FFB952-0B72-493F-8869-D957344CA305}To add a new application for deployment, edit the script in two places:
Step 1: Add to $KioskAppConfig hashtable (~line 1388)
$KioskAppConfig = @{
# Existing entries...
# Add new application
'InstallNewApp' = @{
Action = 'Install'
InstallerPath = '\\tsgwp00525.wjs.geaerospace.net\dt\shopfloor\scripts\NewApp\NewAppSetup.exe'
InstallerName = 'NewAppSetup.exe'
AppName = 'New Application Name'
UninstallGuid = '{YOUR-GUID-HERE}' # Find in registry after manual install
}
'UninstallNewApp' = @{
Action = 'Uninstall'
InstallerName = 'NewAppSetup.exe'
AppName = 'New Application Name'
UninstallGuid = '{YOUR-GUID-HERE}'
}
}
Step 2: Add task names to ValidateSet (~line 142)
[ValidateSet(
'DISM', 'SFC', 'OptimizeDisk', 'DiskCleanup', 'ClearUpdateCache',
'RestartSpooler', 'FlushDNS', 'RestartWinRM', 'ClearBrowserCache',
'SetTimezone', 'SyncTime', 'UpdateEMxAuthToken', 'DeployUDCWebServerConfig', 'Reboot',
'InstallDashboard', 'InstallLobbyDisplay', 'UninstallDashboard', 'UninstallLobbyDisplay',
'InstallNewApp', 'UninstallNewApp' # Add new tasks here
)]
[string]$Task
Step 3: Place installer on network share
\\tsgwp00525.wjs.geaerospace.net\dt\shopfloor\scripts\NewApp\NewAppSetup.exe
Finding the Uninstall GUID:
After manually installing the application on a test PC, find the GUID in registry:
# Search for app in registry
Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" |
Get-ItemProperty | Where-Object { $_.DisplayName -like "*AppName*" } |
Select-Object DisplayName, PSChildName, UninstallString
The PSChildName is typically the GUID (e.g., {9D9EEE25-4D24-422D-98AF-2ADEDA4745ED}).
Installer Requirements:
/VERYSILENT /SUPPRESSMSGBOXES /NORESTART/qn /norestart/SIf your installer uses different flags, modify the InstallKioskApp scriptblock.
Scenario: A PC has corrupted system files causing crashes or errors.
# Run DISM repair on a single PC
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PROBLEM-PC" -Task DISM -Credential $cred
What it does:
Expected output:
[PROBLEM-PC] DISM: SUCCESS
Deployment Image Servicing and Management tool
The restore operation completed successfully.
# Run SFC after DISM
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PROBLEM-PC" -Task SFC -Credential $cred
What it does:
C:\Windows\Logs\CBS\CBS.logBest Practice - Full Repair Sequence:
# Step 1: Run DISM first
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PROBLEM-PC" -Task DISM -Credential $cred
# Step 2: Run SFC after DISM completes
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PROBLEM-PC" -Task SFC -Credential $cred
# Step 3: Reboot to apply changes
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PROBLEM-PC" -Task Reboot -Credential $cred
Scenario: PCs are running slow due to disk fragmentation or lack of TRIM.
.\Invoke-RemoteMaintenance.ps1 -ComputerName "SLOW-PC" -Task OptimizeDisk -Credential $cred
What it does:
# CMM PCs often have large files - optimize overnight
.\Invoke-RemoteMaintenance.ps1 -PcType CMM -Task OptimizeDisk -Credential $cred -ThrottleLimit 3
# Step 1: Clear update cache
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PC01" -Task ClearUpdateCache -Credential $cred
# Step 2: Run disk cleanup
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PC01" -Task DiskCleanup -Credential $cred
# Step 3: Optimize disk
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PC01" -Task OptimizeDisk -Credential $cred
Scenario: Windows Update is stuck or failing repeatedly.
# Clear the Windows Update cache
.\Invoke-RemoteMaintenance.ps1 -ComputerName "UPDATE-STUCK-PC" -Task ClearUpdateCache -Credential $cred
What it does:
C:\Windows\SoftwareDistribution\DownloadAfter clearing, trigger new update check:
# On the target PC (optional follow-up)
wuauclt /detectnow
Scenario: CMM or inspection PCs have slow browser performance.
# Single PC
.\Invoke-RemoteMaintenance.ps1 -ComputerName "CMM-PC01" -Task ClearBrowserCache -Credential $cred
# All CMM PCs
.\Invoke-RemoteMaintenance.ps1 -PcType CMM -Task ClearBrowserCache -Credential $cred
What it does:
# Restart print spooler on a PC with stuck print jobs
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PRINT-PROBLEM-PC" -Task RestartSpooler -Credential $cred
What it does:
# Flush DNS cache when a PC can't resolve hostnames
.\Invoke-RemoteMaintenance.ps1 -ComputerName "DNS-ISSUE-PC" -Task FlushDNS -Credential $cred
# Flush DNS on all PCs in a business unit
.\Invoke-RemoteMaintenance.ps1 -BusinessUnit Blisk -Task FlushDNS -Credential $cred
# Restart WinRM if subsequent remote commands fail
.\Invoke-RemoteMaintenance.ps1 -ComputerName "WINRM-ISSUE-PC" -Task RestartWinRM -Credential $cred
Note: Connection will briefly drop during restart.
Scenario: PC clock is wrong, causing certificate errors or login issues.
# Single PC
.\Invoke-RemoteMaintenance.ps1 -ComputerName "WRONG-TIME-PC" -Task SetTimezone -Credential $cred
# All shopfloor PCs
.\Invoke-RemoteMaintenance.ps1 -All -Task SetTimezone -Credential $cred
Sets timezone to: Eastern Standard Time
# Sync time with domain controller
.\Invoke-RemoteMaintenance.ps1 -ComputerName "WRONG-TIME-PC" -Task SyncTime -Credential $cred
Full time fix sequence:
# Step 1: Set correct timezone
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PC01" -Task SetTimezone -Credential $cred
# Step 2: Sync time
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PC01" -Task SyncTime -Credential $cred
Scenario: eMx authentication is failing on DNC PCs.
# Single PC
.\Invoke-RemoteMaintenance.ps1 -ComputerName "DNC-PC01" -Task UpdateEMxAuthToken -Credential $cred
# All shopfloor PCs
.\Invoke-RemoteMaintenance.ps1 -All -Task UpdateEMxAuthToken -Credential $cred
What it does:
eMxInfo.txt with timestampScenario: UDC web server settings need to be updated.
# Deploy to PCs with UDC installed
.\Invoke-RemoteMaintenance.ps1 -ComputerName "UDC-PC01","UDC-PC02" -Task DeployUDCWebServerConfig -Credential $cred
What it does:
Scenario: Convert a PC to a Dashboard kiosk.
# Single PC installation
.\Invoke-RemoteMaintenance.ps1 -ComputerName "NEWKIOSK-01" -Task InstallDashboard -Credential $cred
# Multiple PCs from a list
$kiosks = @("KIOSK-01", "KIOSK-02", "KIOSK-03")
.\Invoke-RemoteMaintenance.ps1 -ComputerName $kiosks -Task InstallDashboard -Credential $cred
What it does:
After installation:
# Complete Dashboard deployment sequence
.\Invoke-RemoteMaintenance.ps1 -ComputerName "KIOSK-01" -Task InstallDashboard -Credential $cred
.\Invoke-RemoteMaintenance.ps1 -ComputerName "KIOSK-01" -Task Reboot -Credential $cred
# After reboot, update ShopDB
.\Update-ShopfloorPCs-Remote.ps1 -ComputerName "KIOSK-01" -Credential $cred
.\Invoke-RemoteMaintenance.ps1 -ComputerName "LOBBY-01" -Task InstallLobbyDisplay -Credential $cred
# Remove Dashboard
.\Invoke-RemoteMaintenance.ps1 -ComputerName "OLD-KIOSK" -Task UninstallDashboard -Credential $cred
# Remove Lobby Display
.\Invoke-RemoteMaintenance.ps1 -ComputerName "OLD-LOBBY" -Task UninstallLobbyDisplay -Credential $cred
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PC-TO-REBOOT" -Task Reboot -Credential $cred
Note: Reboot has a 30-second delay to allow graceful shutdown.
# Reboot all Dashboard PCs (e.g., for software update)
.\Invoke-RemoteMaintenance.ps1 -PcType Dashboard -Task Reboot -Credential $cred
.\Invoke-RemoteMaintenance.ps1 -PcType "Lobby Display" -Task Reboot -Credential $cred
# Reboot all HPT PCs during maintenance window
.\Invoke-RemoteMaintenance.ps1 -BusinessUnit HPT -Task Reboot -Credential $cred
Create a text file with one hostname per line:
# shopfloor-pcs.txt
PC001
PC002
PC003
PC004
PC005
Run tasks against the list:
.\Invoke-RemoteMaintenance.ps1 -ComputerListFile ".\shopfloor-pcs.txt" -Task FlushDNS -Credential $cred
# Maintenance routine for a PC
$pc = "SHOPFLOOR-PC01"
# Step 1: Clear caches
.\Invoke-RemoteMaintenance.ps1 -ComputerName $pc -Task ClearUpdateCache -Credential $cred
.\Invoke-RemoteMaintenance.ps1 -ComputerName $pc -Task ClearBrowserCache -Credential $cred
# Step 2: Disk cleanup
.\Invoke-RemoteMaintenance.ps1 -ComputerName $pc -Task DiskCleanup -Credential $cred
# Step 3: Repair
.\Invoke-RemoteMaintenance.ps1 -ComputerName $pc -Task DISM -Credential $cred
.\Invoke-RemoteMaintenance.ps1 -ComputerName $pc -Task SFC -Credential $cred
# Step 4: Sync time
.\Invoke-RemoteMaintenance.ps1 -ComputerName $pc -Task SetTimezone -Credential $cred
.\Invoke-RemoteMaintenance.ps1 -ComputerName $pc -Task SyncTime -Credential $cred
# Step 5: Reboot
.\Invoke-RemoteMaintenance.ps1 -ComputerName $pc -Task Reboot -Credential $cred
Best for: Specific troubleshooting, targeted fixes
.\Invoke-RemoteMaintenance.ps1 -ComputerName "PROBLEM-PC" -Task DISM -Credential $cred
Best for: Type-specific maintenance, software updates
# All CMM PCs
.\Invoke-RemoteMaintenance.ps1 -PcType CMM -Task DiskCleanup -Credential $cred
# All Dashboard kiosks
.\Invoke-RemoteMaintenance.ps1 -PcType Dashboard -Task Reboot -Credential $cred
Best for: Department-specific maintenance windows
# All Blisk area PCs
.\Invoke-RemoteMaintenance.ps1 -BusinessUnit Blisk -Task SyncTime -Credential $cred
Best for: Global maintenance, security updates
# Flush DNS everywhere
.\Invoke-RemoteMaintenance.ps1 -All -Task FlushDNS -Credential $cred -ThrottleLimit 10
Best for: Custom groups, staged rollouts
.\Invoke-RemoteMaintenance.ps1 -ComputerListFile ".\phase1-pcs.txt" -Task DISM -Credential $cred
Cause: Task takes longer than session timeout.
Solution: DISM and SFC can take a long time. Check if task completed on target:
# Check DISM log
Invoke-Command -ComputerName "PC01" -Credential $cred -ScriptBlock {
Get-Content "C:\Windows\Logs\DISM\dism.log" -Tail 50
}
Cause: Credentials don't have admin rights on that PC.
Solutions:
Cause: Network share not accessible or installer missing.
Solutions:
Cause: User cancelled shutdown or application blocked it.
Solutions:
# Force immediate reboot (no 30-second delay)
Invoke-Command -ComputerName "PC01" -Credential $cred -ScriptBlock {
Restart-Computer -Force
}
Test on one PC before running against groups:
# Test on single PC first
.\Invoke-RemoteMaintenance.ps1 -ComputerName "TEST-PC" -Task DISM -Credential $cred
| Scenario | Recommended ThrottleLimit |
|---|---|
| Fast network, light tasks | 10-25 |
| Normal operations | 5 (default) |
| Heavy tasks (DISM, Defrag) | 2-3 |
| Slow network | 2-3 |
Run reboots and heavy tasks during maintenance windows:
Always confirm which PCs will be affected:
# Check PC type before reboot
.\Update-ShopfloorPCs-Remote.ps1 -PcType Dashboard -WhatIf
Redirect output for audit trail:
.\Invoke-RemoteMaintenance.ps1 -All -Task SyncTime -Credential $cred | Tee-Object -FilePath "maintenance-log-$(Get-Date -Format 'yyyyMMdd').txt"