Files
powershell-scripts/docs/Update-PC-CompleteAsset.md
cproudlock 7d3519f613 Add comprehensive documentation and update deployment paths
Documentation:
- Add ShopDB-API.md with full API reference (all GET/POST endpoints)
- Add detailed docs for Update-ShopfloorPCs-Remote, Invoke-RemoteMaintenance, Update-PC-CompleteAsset
- Add DATA_COLLECTION_PARITY.md comparing local vs remote data collection
- Add HTML versions of all documentation with styled code blocks
- Document software deployment mechanism and how to add new apps
- Document deprecated scripts (Invoke-RemoteAssetCollection, Install-KioskApp)

Script Updates:
- Update deployment source paths to network share (tsgwp00525.wjs.geaerospace.net)
  - InstallDashboard: \\...\scripts\Dashboard\GEAerospaceDashboardSetup.exe
  - InstallLobbyDisplay: \\...\scripts\LobbyDisplay\GEAerospaceLobbyDisplaySetup.exe
  - UpdateEMxAuthToken: \\...\scripts\eMx\eMxInfo.txt
  - DeployUDCWebServerConfig: \\...\scripts\UDC\udc_webserver_settings.json
- Update machine network detection to include 100.0.0.* for CMM cases
- Rename PC Type #9 from "Part Marker" to "Inspection"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 11:45:00 -05:00

665 lines
18 KiB
Markdown

# Update-PC-CompleteAsset.ps1
Local data collection script that runs directly on shopfloor PCs to collect comprehensive system information and send it to the ShopDB database.
## Table of Contents
- [Overview](#overview)
- [API Integration](#api-integration)
- [Prerequisites](#prerequisites)
- [Quick Start](#quick-start)
- [Parameters Reference](#parameters-reference)
- [How-To Guides](#how-to-guides)
- [Manual Execution](#how-to-run-manually)
- [Scheduled Tasks](#how-to-schedule-automatic-collection)
- [Group Policy Deployment](#how-to-deploy-via-group-policy)
- [Testing Connectivity](#how-to-test-connectivity)
- [Troubleshooting](#how-to-troubleshoot-issues)
- [Data Collected](#data-collected)
- [PC Type Detection](#pc-type-detection)
- [Supporting Files](#supporting-files)
- [Comparison with Remote Script](#comparison-with-remote-script)
---
## Overview
This script runs locally on individual shopfloor PCs to collect comprehensive system information and send it to the ShopDB API. Unlike the remote collection script, this script runs in the local user context, allowing it to collect additional data like mapped drives and user-specific settings.
**Location:** `S:\dt\shopfloor\scripts\complete-asset\Update-PC-CompleteAsset.ps1`
**Use Cases:**
- Scheduled data collection on each PC
- Startup script deployment
- Manual inventory updates
- Collecting data that requires local context
**Advantages over Remote Collection:**
- Can detect V-Drive access (mapped drives)
- Can access C:\Apps folder with user context
- No WinRM configuration required on target
- Works even if remote management is disabled
---
## API Integration
This script sends collected data to the ShopDB API:
### Storing PC Data
```
POST /api.asp?action=updateCompleteAsset
```
Parameters include:
- `hostname`, `serialNumber` (required)
- `manufacturer`, `model`, `osVersion`
- `pcType` - Auto-detected based on installed software
- `networkInterfaces` - JSON array of network configurations
- `dncConfig` - DNC/FTP settings (if applicable)
- `installedApps` - Tracked applications with versions
- `hasVnc`, `hasWinRM` - Feature detection flags
### Updating Printer Mapping
If a default printer is detected:
```
POST /api.asp?action=updatePrinterMapping
```
Links the PC to its default network printer in ShopDB.
### Updating Installed Applications
```
POST /api.asp?action=updateInstalledApps
```
Updates the list of tracked applications (matched against `applications.csv`).
**See:** [ShopDB API Reference](ShopDB-API.html) for complete API documentation.
---
## Prerequisites
### On the Target PC
1. **PowerShell 5.1 or higher**
```powershell
$PSVersionTable.PSVersion
```
2. **Local administrator rights** (for full data collection)
3. **Network access to ShopDB API**
- HTTPS access to production server
- Or HTTP access to development server
4. **TLS 1.2 support** (Windows 10 has this by default)
### Script Files Required
The script depends on a helper file that should be in the same directory:
```
complete-asset/
├── Update-PC-CompleteAsset.ps1 # Main script
├── Get-ShopfloorConfig.ps1 # Helper functions (auto-loaded)
```
And the applications tracking file should be at:
```
powershell/
└── applications.csv # Application definitions
```
---
## Quick Start
### Step 1: Copy Scripts to Target PC
Copy the `complete-asset` folder to the target PC:
```
C:\Scripts\complete-asset\
├── Update-PC-CompleteAsset.ps1
├── Get-ShopfloorConfig.ps1
```
### Step 2: Open PowerShell as Administrator
Right-click PowerShell and select "Run as administrator"
### Step 3: Navigate to Script Directory
```powershell
cd C:\Scripts\complete-asset
```
### Step 4: Run the Script
```powershell
.\Update-PC-CompleteAsset.ps1
```
### Step 5: Verify Output
The script will display collection progress and API response:
```
========================================
Complete PC Asset Collection & Storage
========================================
Computer: SHOPFLOOR-PC01
Dashboard: https://production-server/shopdb/api.asp
=== STEP 1: COLLECT SYSTEM INFO ===
Collecting comprehensive system information...
System Details:
Hostname: SHOPFLOOR-PC01
Manufacturer: Dell Inc.
Model: OptiPlex 7080
Serial: ABC1234
PC Type: Shopfloor
...
=== STEP 4: SEND TO DATABASE ===
[OK] Complete asset data stored in database!
PCID: 1234
Operation: update
```
---
## Parameters Reference
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `-DashboardURL` | string | No | Auto-detect | Override the API endpoint URL |
| `-TestConnections` | switch | No | False | Test connectivity only, no data collection |
---
## How-To Guides
### How to Run Manually
#### Basic Execution
```powershell
# Navigate to script directory
cd C:\Scripts\complete-asset
# Run with default settings (auto-detects production API)
.\Update-PC-CompleteAsset.ps1
```
#### Specify API Endpoint
```powershell
# Use development server
.\Update-PC-CompleteAsset.ps1 -DashboardURL "http://192.168.122.151:8080/api.asp"
# Use staging server
.\Update-PC-CompleteAsset.ps1 -DashboardURL "https://staging-server/shopdb/api.asp"
```
#### Run from Any Location
```powershell
# Full path execution
& "C:\Scripts\complete-asset\Update-PC-CompleteAsset.ps1"
# With UNC path
& "\\server\share\scripts\Update-PC-CompleteAsset.ps1"
```
---
### How to Test Connectivity
Before deploying widely, test that the PC can reach the API:
```powershell
.\Update-PC-CompleteAsset.ps1 -TestConnections
```
**Expected Output (Success):**
```
=== CONNECTION TESTS ===
Skipping proxy test (not accessible from client PCs)
Testing dashboard connection...
Dashboard URL: https://production-server/shopdb/api.asp
[OK] Dashboard responded successfully
[OK] Dashboard connection working!
```
**Expected Output (Failure):**
```
=== CONNECTION TESTS ===
Testing dashboard connection...
Dashboard URL: https://production-server/shopdb/api.asp
[FAIL] Could not connect to dashboard
[FAIL] Dashboard connection failed
```
**Troubleshooting Failed Connections:**
1. Check network connectivity: `ping production-server`
2. Check firewall rules for HTTPS (443)
3. Verify TLS configuration
4. Try with HTTP if HTTPS fails: `-DashboardURL "http://..."`
---
### How to Schedule Automatic Collection
#### Option 1: Windows Task Scheduler (GUI)
1. **Open Task Scheduler**
- Press `Win + R`, type `taskschd.msc`, press Enter
2. **Create New Task**
- Click "Create Task" (not "Create Basic Task")
3. **General Tab**
- Name: `ShopDB PC Collection`
- Description: `Collects PC data and sends to ShopDB`
- Security options:
- "Run whether user is logged on or not"
- "Run with highest privileges"
- Configure for: Windows 10
4. **Triggers Tab**
- New trigger: "At startup"
- Delay task for: 5 minutes (allows network to connect)
- Or: "Daily" at specific time
5. **Actions Tab**
- Action: Start a program
- Program: `powershell.exe`
- Arguments: `-ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Scripts\complete-asset\Update-PC-CompleteAsset.ps1"`
6. **Conditions Tab**
- Check "Start only if network connection is available"
7. **Settings Tab**
- Allow task to be run on demand
- Stop task if it runs longer than: 1 hour
#### Option 2: PowerShell Script to Create Task
```powershell
# Run this on target PC as administrator
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
-Argument '-ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Scripts\complete-asset\Update-PC-CompleteAsset.ps1"'
$trigger = New-ScheduledTaskTrigger -AtStartup -RandomDelay (New-TimeSpan -Minutes 5)
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries `
-StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Hours 1)
Register-ScheduledTask -TaskName "ShopDB PC Collection" `
-Action $action -Trigger $trigger -Principal $principal -Settings $settings `
-Description "Collects PC data and sends to ShopDB"
```
#### Option 3: Daily Collection at Specific Time
```powershell
# Run daily at 6:00 AM
$trigger = New-ScheduledTaskTrigger -Daily -At 6am
Register-ScheduledTask -TaskName "ShopDB PC Collection" `
-Action $action -Trigger $trigger -Principal $principal -Settings $settings
```
#### Verify Scheduled Task
```powershell
# List the task
Get-ScheduledTask -TaskName "ShopDB PC Collection"
# Run the task manually to test
Start-ScheduledTask -TaskName "ShopDB PC Collection"
# Check task history
Get-ScheduledTaskInfo -TaskName "ShopDB PC Collection"
```
---
### How to Deploy via Group Policy
#### Step 1: Prepare Network Share
Create a network share accessible to all shopfloor PCs:
```
\\fileserver\shopdb-scripts\
├── complete-asset\
│ ├── Update-PC-CompleteAsset.ps1
│ └── Get-ShopfloorConfig.ps1
└── applications.csv
```
Set permissions:
- Domain Computers: Read & Execute
- Authenticated Users: Read & Execute
#### Step 2: Create GPO
1. Open Group Policy Management Console
2. Create new GPO: "ShopDB PC Collection"
3. Link to OU containing shopfloor PCs
#### Step 3: Configure Computer Startup Script
Navigate to:
```
Computer Configuration > Policies > Windows Settings > Scripts > Startup
```
Add PowerShell script:
- Script Name: `\\fileserver\shopdb-scripts\complete-asset\Update-PC-CompleteAsset.ps1`
Or create a batch wrapper:
**startup-collection.bat:**
```batch
@echo off
REM Wait for network
ping -n 30 127.0.0.1 > nul
REM Run collection script
powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "\\fileserver\shopdb-scripts\complete-asset\Update-PC-CompleteAsset.ps1"
```
#### Step 4: Force GPO Update (Testing)
On target PC:
```cmd
gpupdate /force
```
Then restart to trigger startup script.
---
### How to Deploy via SCCM/Endpoint Manager
#### Create Application
1. **Detection Method:**
```powershell
# Detect if last collection was within 24 hours
$logPath = "C:\Logs\CompleteAsset"
$recentLog = Get-ChildItem $logPath -Filter "*.log" |
Where-Object { $_.LastWriteTime -gt (Get-Date).AddHours(-24) }
if ($recentLog) { Write-Output "Installed" }
```
2. **Install Command:**
```cmd
powershell.exe -ExecutionPolicy Bypass -File "Update-PC-CompleteAsset.ps1"
```
3. **Deployment Schedule:**
- Recurring deployment: Daily
- Run as: System
---
### How to Troubleshoot Issues
#### Problem: Script Runs But No Data in Database
**Check 1: API Response**
Look at script output for API errors:
```
[FAIL] Dashboard could not store data: Invalid hostname
```
**Check 2: Network Connectivity**
```powershell
.\Update-PC-CompleteAsset.ps1 -TestConnections
```
**Check 3: Log Files**
```powershell
# Find recent log files
Get-ChildItem "C:\Logs\CompleteAsset" -Recurse | Sort-Object LastWriteTime -Descending | Select -First 5
```
---
#### Problem: PC Type Detection Wrong
**Check installed applications:**
```powershell
# List installed apps the script sees
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
Where-Object { $_.DisplayName } |
Select-Object DisplayName |
Sort-Object DisplayName
```
**Verify detection criteria:**
- Dashboard: Look for "GE Aerospace Dashboard"
- CMM: Look for "PC-DMIS" or "PCDMIS" or "goCMM" or "DODA"
- Wax Trace: Look for "FormTracePak" or "FormStatusMonitor"
---
#### Problem: DNC Configuration Not Detected
**Check registry paths:**
```powershell
# Check 32-bit registry
Test-Path "HKLM:\SOFTWARE\GE Aircraft Engines"
# Check 64-bit registry
Test-Path "HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines"
# List DNC settings
Get-ChildItem "HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines\DNC" -Recurse
```
---
#### Problem: Serial Ports Not Detected
**Check Win32_SerialPort:**
```powershell
Get-CimInstance -ClassName Win32_SerialPort | Select DeviceID, Description
```
If empty, serial ports may be virtual or use different drivers.
---
#### Problem: VNC Not Detected
**Check manually:**
```powershell
# Check registry
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" |
Where-Object { $_.DisplayName -like "*VNC*" }
# Check service
Get-Service -Name "vncserver*"
```
---
#### Problem: Script Errors on Startup
**Check execution policy:**
```powershell
Get-ExecutionPolicy
# Should be RemoteSigned or Bypass
# Fix:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
```
**Check script signing:**
If policy requires signed scripts, sign the script or use:
```powershell
powershell.exe -ExecutionPolicy Bypass -File "script.ps1"
```
---
## Data Collected
### Basic System Information
| Field | Source | Example |
|-------|--------|---------|
| Hostname | `$env:COMPUTERNAME` | `SHOPFLOOR-PC01` |
| Serial Number | CIM_BIOSElement | `ABC1234` |
| Service Tag | CIM_BIOSElement | `ABC1234` |
| Manufacturer | CIM_ComputerSystem | `Dell Inc.` |
| Model | CIM_ComputerSystem | `OptiPlex 7080` |
| Total Physical Memory | CIM_ComputerSystem | `16.0` GB |
| Domain Role | CIM_ComputerSystem | `1` (Member Workstation) |
| OS Version | CIM_OperatingSystem | `Windows 10 Enterprise` |
| Last Boot Time | CIM_OperatingSystem | `2025-01-15 08:30:00` |
| Current Time Zone | Get-TimeZone | `Eastern Standard Time` |
| Logged In User | CIM_ComputerSystem | `DOMAIN\jsmith` |
| PC Type | Software Detection | `Shopfloor` |
| Machine No | Hostname/Registry | `M0612` |
### DNC Configuration (Shopfloor PCs)
| Field | Registry Path | Example |
|-------|---------------|---------|
| Site | `DNC\General\Site` | `WJF` |
| CNC | `DNC\General\Cnc` | `FANUC` |
| NcIF | `DNC\General\NcIF` | `FOCAS2` |
| Machine No | `DNC\General\MachineNo` | `M0612` |
| Host Type | `DNC\General\HostType` | `MX` |
| FTP Primary | `DNC\MX\FtpHostPrimary` | `10.134.50.10` |
| FTP Secondary | `DNC\MX\FtpHostSecondary` | `10.134.50.11` |
### GE Registry Information
| Field | Source | Example |
|-------|--------|---------|
| Registry 32-bit | Path exists check | `true` |
| Registry 64-bit | Path exists check | `true` |
| Dual Path Enabled | eFocas registry | `true` |
| Path 1 Name | eFocas registry | `Primary` |
| Path 2 Name | eFocas registry | `Backup` |
### Network Interfaces
| Field | Source | Example |
|-------|--------|---------|
| Interface Name | Get-NetAdapter | `Ethernet0` |
| IP Address | Get-NetIPConfiguration | `10.134.50.101` |
| Subnet Mask | Get-NetIPConfiguration | `24` |
| Default Gateway | Get-NetIPConfiguration | `10.134.50.1` |
| MAC Address | Get-NetAdapter | `00-11-22-33-44-55` |
| Is DHCP | Get-NetIPConfiguration | `false` |
| Is Active | Get-NetAdapter | `true` |
| Is Machine Network | IP pattern match | `false` (192.168.* or 100.0.0.* for CMM) |
| Is Primary | IP pattern match | `true` (10.134.*) |
### Additional Data
| Field | Source | Example |
|-------|--------|---------|
| Serial Ports | Win32_SerialPort | `COM1, COM2` |
| Has VNC | Registry + Service check | `true` |
| Default Printer FQDN | Win32_Printer | `10.80.92.53` |
| All Installed Apps | Registry (HKLM + HKU) | 127 apps |
| Tracked Applications | CSV matching | `UDC v2.1, Tanium v7.4` |
---
## PC Type Detection
The script detects PC type based on installed software in this priority order:
| Priority | Type | Detection Method |
|----------|------|-----------------|
| 1 | Dashboard | `GE Aerospace Dashboard` installed |
| 2 | Lobby Display | `GE Aerospace Lobby Display` installed |
| 3 | CMM | PC-DMIS, goCMM, or DODA software |
| 4 | Wax Trace | FormTracePak or FormStatusMonitor |
| 5 | Keyence | VR-3000, VR-5000, or VR-6000 |
| 6 | EAS1000 | GageCal or NI Software |
| 7 | Genspect | Genspect measuring software |
| 8 | Heat Treat | HeatTreat application |
| 9 | Inspection | Machine #: 0612, 0613, 0615, 8003 |
| 10 | Shopfloor | Default for domain shop PCs |
| 11 | Engineer | Has C:\Apps AND V-Drive access |
| 12 | Standard | Default for other domain PCs |
**Note:** Priority matters - a PC with both Dashboard and CMM software will be classified as "Dashboard".
---
## Supporting Files
### Required Directory Structure
```
S:\dt\shopfloor\scripts\complete-asset\
├── Update-PC-CompleteAsset.ps1 # Main script
└── Get-ShopfloorConfig.ps1 # Helper functions (REQUIRED)
```
**Important:** Both files must be in the same directory. The main script dot-sources the helper:
```powershell
. "$PSScriptRoot\Get-ShopfloorConfig.ps1"
```
### Get-ShopfloorConfig.ps1
Helper script providing these functions:
| Function | Purpose |
|----------|---------|
| `Get-NetworkInterfaceConfig` | Network adapters with IsPrimary/IsMachineNetwork |
| `Get-SerialPortConfig` | DNC serial port settings |
| `Get-GERegistryInfo` | GE Aircraft Engines registry (DualPath, paths) |
| `Get-DNCConfig` | DNC general configuration |
| `Get-ShopfloorConfigurations` | Combines all above into one call |
| `Get-InstalledApplications` | Detects UDC/CLM processes |
### applications.csv
Defines tracked applications for version tracking:
```csv
app_id,app_name,search_patterns
2,UDC,"Universal Data Collector"
4,CLM,"Cell Level Manager|ppdcs"
77,HeatTreat,"HeatTreat"
82,GE Aerospace Dashboard,"GE Aerospace Dashboard"
83,GE Aerospace Lobby Display,"GE Aerospace Lobby Display"
```
**Location:** `S:\dt\shopfloor\scripts\applications.csv`
---
## Comparison with Remote Script
| Feature | Local Script | Remote Script |
|---------|-------------|---------------|
| Execution | On target PC | From admin workstation |
| WinRM Required | No | Yes |
| V-Drive Detection | Yes | No |
| C:\Apps Detection | Yes | Limited |
| Batch Operations | No (one PC) | Yes (many PCs) |
| User Context | Local user | WinRM context |
| Admin Rights | Needed locally | Needed remotely |