# Function Reference Documentation ## Update-PC-CompleteAsset.ps1 ### Core Functions #### `Get-DashboardURL` **Purpose**: Intelligent dashboard API URL discovery and validation **Parameters**: - `$ProvidedURL` (string, optional) - User-specified URL **Logic Flow**: 1. Check command-line parameter 2. Check environment variable `ASSET_DASHBOARD_URL` 3. Check configuration file `dashboard-config.json` 4. Auto-discovery probe of candidate URLs 5. Fallback to default production URL **Returns**: `[string]` - Validated dashboard API URL ```powershell function Get-DashboardURL { param([string]$ProvidedURL) # Priority-based URL resolution if (-not [string]::IsNullOrEmpty($ProvidedURL)) { return $ProvidedURL } # Auto-discovery with connection testing foreach ($url in $candidates) { $testResponse = Invoke-RestMethod -Uri "$url?action=getDashboardData" -Method Get -TimeoutSec 5 if ($testResponse.success) { return $url } } } ``` --- #### `Test-ProxyConnection` / `Test-DashboardConnection` **Purpose**: Network connectivity validation for external services **Parameters**: - `$ProxyURL` / `$DashboardURL` (string) - Target URL to test **Returns**: `[bool]` - Connection success status **Features**: - Configurable timeout values - Detailed error reporting - Service availability verification --- #### `Test-AppsFolder` / `Test-VDriveAccess` / `Test-WindowsLTSC` **Purpose**: PC type classification helper functions **Returns**: `[bool]` - Feature presence status **Classification Logic**: ```powershell function Get-PCType { if (Test-AppsFolder -and Test-VDriveAccess) { return "Engineer" # Development workstations } elseif (Test-WindowsLTSC) { return "Shopfloor" # Manufacturing systems } else { return "Standard" # Corporate systems } } ``` --- #### `Get-GEMachineNumber` **Purpose**: Extract GE machine numbers from hostname patterns **Parameters**: - `$Hostname` (string) - Computer hostname **Pattern Matching**: - `H###` patterns `M###` (H123 M123) - `G###` patterns `M###` (G456 M456) - Regex: `[HG](\d{3})` **Returns**: `[string]` - Formatted machine number or `$null` --- #### `Collect-SystemInfo` **Purpose**: Comprehensive system information gathering **Returns**: `[hashtable]` - Complete system profile **Data Sources**: - **WMI/CIM Classes**: `CIM_ComputerSystem`, `CIM_BIOSElement`, `CIM_OperatingSystem` - **Environment Variables**: Hostname, user context - **Registry Analysis**: OS edition detection - **File System**: Apps folder and drive access testing **Output Structure**: ```powershell $systemInfo = @{ Hostname = $env:COMPUTERNAME Manufacturer = $computerSystem.Manufacturer # Dell, HP, etc. Model = $computerSystem.Model # OptiPlex 7070 SerialNumber = $bios.SerialNumber # Hardware serial ServiceTag = $bios.SerialNumber # Dell service tag LoggedInUser = $computerSystem.UserName.Split('\')[-1] OSVersion = $os.Caption # Windows 10 Enterprise LTSC TotalPhysicalMemory = [Math]::Round($computerSystem.TotalPhysicalMemory / 1GB, 2) DomainRole = $computerSystem.DomainRole # Domain membership CurrentTimeZone = (Get-TimeZone).Id # Timezone information LastBootUpTime = $os.LastBootUpTime # Last boot timestamp PCType = Get-PCType -HasAppsFolder $hasApps -HasVDriveAccess $hasVDrive -IsLTSC $isLTSC MachineNo = Get-GEMachineNumber -Hostname $systemInfo.Hostname } ``` **Error Handling**: Graceful degradation with "Unknown" fallbacks for failed WMI queries --- #### `Collect-ShopfloorInfo` **Purpose**: Manufacturing-specific configuration collection **Parameters**: - `$SystemInfo` (hashtable) - Basic system information **Conditional Logic**: Only executes for `PCType = "Shopfloor"` **Returns**: `[hashtable]` - Manufacturing configuration data or `$null` **Calls**: `Get-ShopfloorConfigurations` function from imported module --- #### `Get-WarrantyFromProxy` **Purpose**: Dell warranty information retrieval via proxy server **Parameters**: - `$ServiceTag` (string) - Dell service tag - `$ProxyURL` (string) - Proxy server URL **API Integration**: ```powershell $uri = "$ProxyURL" + "?vendor=dell&action=warranty&servicetag=$ServiceTag" $response = Invoke-RestMethod -Uri $uri -Method Get -TimeoutSec 30 ``` **Response Processing**: Extracts warranty end date, status, service level, and days remaining **Current Status**: Disabled by default (`$SkipWarranty = $true`) --- #### `Send-CompleteDataToDashboard` **Purpose**: Centralized data transmission to dashboard API **Parameters**: - `$SystemInfo` (hashtable) - System information - `$ShopfloorInfo` (hashtable) - Manufacturing configuration - `$WarrantyData` (hashtable) - Warranty information - `$DashboardURL` (string) - API endpoint URL **Payload Construction**: Creates comprehensive HTTP POST payload with structured data **Manufacturing Data Handling** **Enhanced in v3.0**: ```powershell # DualPath and Registry Architecture Data $postData.dncDualPathEnabled = $geInfo.DualPathEnabled $postData.dncPath1Name = $geInfo.Path1Name $postData.dncPath2Name = $geInfo.Path2Name $postData.dncGeRegistry32Bit = $geInfo.Registry32Bit $postData.dncGeRegistry64Bit = $geInfo.Registry64Bit $postData.dncGeRegistryNotes = $geInfo.RegistryNotes | ConvertTo-Json -Compress ``` **Error Handling**: Comprehensive HTTP exception handling with detailed error reporting --- ## Get-ShopfloorConfig.ps1 ### Manufacturing Intelligence Functions #### `Get-NetworkInterfaceConfig` **Purpose**: Advanced network interface analysis with manufacturing intelligence **Returns**: `[array]` - Network interface configuration objects **Multi-Method Approach**: 1. **Primary**: `Get-NetAdapter` / `Get-NetIPConfiguration` cmdlets 2. **Fallback**: WMI `Win32_NetworkAdapterConfiguration` class **Manufacturing Intelligence**: ```powershell # Machine network detection $isMachineNetwork = $ip.IPAddress -match '^192\.168\.' $interface = @{ InterfaceName = $adapter.Name IPAddress = $ip.IPAddress SubnetMask = $ip.PrefixLength DefaultGateway = $gateway MACAddress = $adapter.MacAddress IsDHCP = if ($ipConfig.NetIPv4Interface.Dhcp -eq 'Enabled') { 1 } else { 0 } IsActive = 1 IsMachineNetwork = if ($isMachineNetwork) { 1 } else { 0 } } ``` --- #### `Get-SerialPortConfig` **Purpose**: Serial communication port enumeration and configuration analysis **Returns**: `[array]` - Serial port configuration objects **Registry Data Source**: `HKLM:\HARDWARE\DEVICEMAP\SERIALCOMM` **Configuration Structure**: ```powershell $config = @{ PortName = $portName # COM1, COM2, etc. DevicePath = $devicePath # Hardware device path IsActive = 1 # Availability status ConfigSource = "Registry" # Data source identifier } ``` --- #### `Get-DNCConfig` **Purpose**: Direct Numerical Control configuration extraction from GE Aircraft Engines registry **Returns**: `[hashtable]` - Complete DNC configuration or `$null` **Multi-Path Registry Analysis**: ```powershell $paths = @( 'HKLM:\SOFTWARE\GE Aircraft Engines\DNC\General', 'HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines\DNC\General' ) ``` **Configuration Sections Analyzed**: - **General**: Site, CNC type, NcIF, Machine number, Debug settings - **MX**: FTP host configuration, account credentials - **FMS**: FMS host settings, socket configuration **Output Structure**: ```powershell $dncConfig = @{ Site = $general.Site # WestJefferson CNC = $general.Cnc # Fanuc 30 NcIF = $general.NcIF # EFOCAS MachineNumber = $general.MachineNo # 3109 HostType = $general.HostType # WILM Debug = $general.Debug # ON/OFF # ... additional configuration parameters } ``` --- #### `Get-GERegistryInfo` **New in v3.0** **Purpose**: Comprehensive GE Aircraft Engines registry architecture analysis with DualPath detection **Returns**: `[hashtable]` - Complete registry architecture and DualPath configuration **Dual Registry Architecture Support**: ```powershell $registryPaths = @{ '32bit' = 'HKLM:\SOFTWARE\GE Aircraft Engines' '64bit' = 'HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines' } ``` **Smart Conflict Resolution**: ```powershell # Priority system prevents data overwrites if ($geInfo.DualPathEnabled -eq $null) { $geInfo.DualPathEnabled = $efocasValues.DualPath -eq 'YES' Write-Host "Setting DualPath from $pathType registry: $($geInfo.DualPathEnabled)" } else { Write-Host "DualPath already set from other registry location, keeping existing value" } ``` **Comprehensive Data Collection**: - **Registry Presence**: 32-bit and/or 64-bit detection - **Sub-key Enumeration**: Complete service inventory - **DualPath Configuration**: eFocas DualPath settings extraction - **Path Configuration**: Path1Name and Path2Name identification - **Metadata Collection**: Timestamps, registry paths, additional settings **Output Structure**: ```powershell $geInfo = @{ Registry32Bit = $false # Boolean: Found in 32-bit registry Registry64Bit = $true # Boolean: Found in 64-bit registry DualPathEnabled = $true # Boolean: DualPath enabled Path1Name = "Path1Primary" # String: Primary path name Path2Name = "Path2Secondary" # String: Secondary path name RegistryNotes = @{ # Hashtable: Comprehensive metadata "64bit" = @{ BasePath = "HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines" SubKeys = "DNC, Enhanced DNC, MarkZebra, PPDCS" Found = "2025-09-06 14:30:00" } "64bit-eFocas" = @{ DualPath = "YES" Path1Name = "Path1Primary" Path2Name = "Path2Secondary" IpAddr = "192.168.1.1" SocketNo = "8192" Danobat = "NO" DataServer = "NO" } } } ``` --- #### `Get-ShopfloorConfigurations` **Purpose**: Master orchestration function for all manufacturing-specific data collection **Returns**: `[hashtable]` - Complete manufacturing configuration profile **Orchestration Logic**: ```powershell $configurations = @{ NetworkInterfaces = Get-NetworkInterfaceConfig # Network topology analysis CommConfigs = Get-SerialPortConfig # Serial communication ports DNCConfig = Get-DNCConfig # Direct Numerical Control settings GERegistryInfo = Get-GERegistryInfo # Registry architecture analysis } ``` **Summary Reporting**: ```powershell Write-Host "Configuration Summary:" -ForegroundColor Green Write-Host " Network Interfaces: $($configurations.NetworkInterfaces.Count)" Write-Host " Comm Configs: $($configurations.CommConfigs.Count)" Write-Host " DNC Config: $(if ($configurations.DNCConfig) { 'Yes' } else { 'No' })" Write-Host " GE Registry (32-bit): $(if ($configurations.GERegistryInfo.Registry32Bit) { 'Yes' } else { 'No' })" Write-Host " GE Registry (64-bit): $(if ($configurations.GERegistryInfo.Registry64Bit) { 'Yes' } else { 'No' })" Write-Host " DualPath Enabled: $(if ($configurations.GERegistryInfo.DualPathEnabled -eq $null) { 'Not Found' } elseif ($configurations.GERegistryInfo.DualPathEnabled) { 'Yes' } else { 'No' })" ``` --- ## Error Handling Patterns ### Standard Error Handling Template ```powershell try { # Primary operation $result = Get-SomeInformation Write-Host "[OK] Operation successful" -ForegroundColor Green } catch { Write-Host "[FAIL] Operation failed: $($_.Exception.Message)" -ForegroundColor Red # Graceful degradation or fallback } ``` ### Registry Access Error Handling ```powershell try { $registryValue = Get-ItemProperty -Path $registryPath -ErrorAction SilentlyContinue } catch { Write-Host "Error reading registry: $_" -ForegroundColor Red $geInfo.RegistryNotes[$pathType] = @{ Error = $_.Exception.Message } } ``` ### Network Communication Error Handling ```powershell try { $response = Invoke-RestMethod -Uri $url -Method Post -Body $postData -TimeoutSec 30 } catch [System.Net.WebException] { Write-Host "[FAIL] Network error: $($_.Exception.Message)" -ForegroundColor Red return $false } catch { Write-Host "[FAIL] Unexpected error: $($_.Exception.Message)" -ForegroundColor Red return $false } ``` --- **Function reference provides comprehensive understanding of all script capabilities, parameters, error handling, and integration patterns for enterprise manufacturing environments.**