Initial commit: Organized PowerShell scripts for ShopDB asset collection

Structure:
- asset-collection/: Local PC data collection scripts
- remote-execution/: WinRM remote execution scripts
- setup-utilities/: Configuration and testing utilities
- registry-backup/: GE registry backup scripts
- winrm-https/: WinRM HTTPS certificate setup
- docs/: Complete documentation

Each folder includes a README with detailed documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-10 10:57:54 -05:00
commit 62c0c7bb06
102 changed files with 28017 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
@echo off
REM Deploy-AssetCollectionSchedule.bat
REM Deploys the automated asset collection scheduled task on Windows machines
REM This batch file can be run via Group Policy or deployment tools
echo =====================================
echo GE Asset Collection - Schedule Deployment
echo =====================================
echo.
REM Check if running as administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
echo [ERROR] This script must be run as Administrator
echo Please run with elevated privileges
pause
exit /b 1
)
REM Check if PowerShell is available
powershell.exe -Command "Get-Host" >nul 2>&1
if %errorLevel% neq 0 (
echo [ERROR] PowerShell is not available on this system
pause
exit /b 1
)
echo Installing automated asset collection schedule...
echo.
REM Run the PowerShell installer script
powershell.exe -ExecutionPolicy Bypass -File "S:\DT\adata\script\Install-AssetCollectionSchedule.ps1"
if %errorLevel% equ 0 (
echo.
echo [SUCCESS] Automated asset collection schedule installed successfully!
echo The system will now collect asset data 4 times daily in the background.
echo.
echo Schedule:
echo - 6:00 AM daily
echo - 12:00 PM daily
echo - 6:00 PM daily
echo - 12:00 AM daily
echo.
echo Users will not be interrupted during collection.
) else (
echo.
echo [ERROR] Failed to install scheduled task
echo Please check the PowerShell output above for details
)
echo.
echo =====================================
echo Deployment Complete
echo =====================================
pause

View File

@@ -0,0 +1,111 @@
# Install-AssetCollectionSchedule.ps1
# Creates a Windows scheduled task to run asset collection 4 times daily in the background
param(
[string]$ScriptPath = "S:\DT\adata\script\Update-PC-CompleteAsset-Silent.bat",
[string]$TaskName = "GE Asset Collection",
[string]$TaskDescription = "Automated PC asset collection for GE shopfloor systems - runs silently 4 times daily"
)
Write-Host "===================================== " -ForegroundColor Cyan
Write-Host "GE Asset Collection - Schedule Installer" -ForegroundColor Cyan
Write-Host "===================================== " -ForegroundColor Cyan
Write-Host ""
# Check if running as administrator
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "[ERROR] This script must be run as Administrator to create scheduled tasks" -ForegroundColor Red
Write-Host "Please right-click and 'Run as Administrator'" -ForegroundColor Yellow
exit 1
}
# Verify the script file exists
if (-not (Test-Path $ScriptPath)) {
Write-Host "[ERROR] Asset collection script not found at: $ScriptPath" -ForegroundColor Red
Write-Host "Please ensure the script is deployed to the correct location" -ForegroundColor Yellow
exit 1
}
Write-Host "Installing scheduled task for automated asset collection..." -ForegroundColor Green
Write-Host " Script Path: $ScriptPath" -ForegroundColor Gray
Write-Host " Task Name: $TaskName" -ForegroundColor Gray
Write-Host " Frequency: 4 times daily (every 6 hours)" -ForegroundColor Gray
Write-Host ""
try {
# Remove existing task if it exists
$existingTask = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
if ($existingTask) {
Write-Host "Removing existing scheduled task..." -ForegroundColor Yellow
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
}
# Define the action - run the batch file completely hidden
$action = New-ScheduledTaskAction -Execute "cmd.exe" -Argument "/c `"$ScriptPath`"" -WorkingDirectory "S:\DT\adata\script"
# Define multiple triggers for 4 times daily (6:00 AM, 12:00 PM, 6:00 PM, 12:00 AM)
$trigger1 = New-ScheduledTaskTrigger -Daily -At "06:00"
$trigger2 = New-ScheduledTaskTrigger -Daily -At "12:00"
$trigger3 = New-ScheduledTaskTrigger -Daily -At "18:00"
$trigger4 = New-ScheduledTaskTrigger -Daily -At "00:00"
# Define settings - run in background, don't disturb users
$settings = New-ScheduledTaskSettingsSet `
-AllowStartIfOnBatteries `
-DontStopIfGoingOnBatteries `
-StartWhenAvailable `
-RunOnlyIfNetworkAvailable `
-DontStopOnIdleEnd `
-Hidden `
-Priority 4 `
-ExecutionTimeLimit (New-TimeSpan -Hours 2) `
-RestartCount 3 `
-RestartInterval (New-TimeSpan -Minutes 10)
# Run as SYSTEM account for maximum permissions and no user interaction
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
# Create the scheduled task
$task = New-ScheduledTask -Action $action -Trigger @($trigger1, $trigger2, $trigger3, $trigger4) -Settings $settings -Principal $principal -Description $TaskDescription
# Register the task
Register-ScheduledTask -TaskName $TaskName -InputObject $task -Force
Write-Host "[SUCCESS] Scheduled task created successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "Task Details:" -ForegroundColor Cyan
Write-Host " Name: $TaskName" -ForegroundColor Gray
Write-Host " Schedule: 4 times daily at 6:00 AM, 12:00 PM, 6:00 PM, 12:00 AM" -ForegroundColor Gray
Write-Host " Account: SYSTEM (runs in background)" -ForegroundColor Gray
Write-Host " Hidden: Yes (no user interruption)" -ForegroundColor Gray
Write-Host " Network Required: Yes" -ForegroundColor Gray
Write-Host " Max Runtime: 2 hours" -ForegroundColor Gray
Write-Host " Auto Restart: 3 attempts if failed" -ForegroundColor Gray
Write-Host ""
# Test the task by running it once
Write-Host "Testing scheduled task..." -ForegroundColor Yellow
Start-ScheduledTask -TaskName $TaskName
Start-Sleep -Seconds 3
$taskInfo = Get-ScheduledTaskInfo -TaskName $TaskName
Write-Host " Last Run: $($taskInfo.LastRunTime)" -ForegroundColor Gray
Write-Host " Last Result: $($taskInfo.LastTaskResult)" -ForegroundColor Gray
Write-Host " Next Run: $($taskInfo.NextRunTime)" -ForegroundColor Gray
Write-Host ""
Write-Host "[INFO] Task installation complete!" -ForegroundColor Green
Write-Host "The asset collection will now run automatically 4 times daily in the background." -ForegroundColor Green
Write-Host "Users will not see any windows or be interrupted during execution." -ForegroundColor Green
} catch {
Write-Host "[ERROR] Failed to create scheduled task: $($_.Exception.Message)" -ForegroundColor Red
Write-Host "Please check Windows Event Viewer for additional details" -ForegroundColor Yellow
exit 1
}
Write-Host ""
Write-Host "===================================== " -ForegroundColor Cyan
Write-Host "Installation Complete" -ForegroundColor Cyan
Write-Host "===================================== " -ForegroundColor Cyan

View File

@@ -0,0 +1,36 @@
@echo off
REM Install-Schedule.bat
REM Simple batch file to install the asset collection scheduled task
REM Runs PowerShell with bypass policy to avoid execution restrictions
echo =====================================
echo Installing Asset Collection Schedule
echo =====================================
echo.
REM Check if running as administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
echo [ERROR] Must run as Administrator
echo Right-click this file and select "Run as administrator"
pause
exit /b 1
)
echo Running PowerShell installer...
echo.
REM Run PowerShell with bypass policy
powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "%~dp0Install-AssetCollectionSchedule.ps1"
if %errorLevel% equ 0 (
echo.
echo [SUCCESS] Asset collection schedule installed!
echo Your machine will now collect asset data 4 times daily.
) else (
echo.
echo [ERROR] Installation failed
)
echo.
pause

166
setup-utilities/README.md Normal file
View File

@@ -0,0 +1,166 @@
# Setup & Utility Scripts
Scripts for configuring WinRM, scheduling tasks, and testing API connectivity.
## Scripts
### Setup-WinRM.ps1
**WinRM configuration utility** - Configures WinRM on the management server for remote asset collection.
**What it does:**
1. Enables WinRM service
2. Configures trusted hosts for remote connections
3. Sets up HTTP listener on port 5985
4. Tests connectivity to specified computers
**Usage:**
```powershell
# Trust all hosts (less secure, simpler)
.\Setup-WinRM.ps1 -TrustedHosts "*"
# Trust specific IPs
.\Setup-WinRM.ps1 -TrustedHosts "10.48.130.100,10.48.130.101"
# Setup and test
.\Setup-WinRM.ps1 -TrustedHosts "*" -TestConnection @("10.48.130.100")
```
**Parameters:**
| Parameter | Default | Description |
|-----------|---------|-------------|
| `-TrustedHosts` | `""` | Comma-separated list of trusted hosts |
| `-TestConnection` | `@()` | Array of computers to test after setup |
**Requires:** Administrator privileges
---
### Install-AssetCollectionSchedule.ps1
**Scheduled task installer** - Creates Windows scheduled task for automated asset collection.
**What it does:**
1. Creates scheduled task running 4 times daily (6:00, 12:00, 18:00, 00:00)
2. Configures silent execution (no window popup)
3. Runs as SYSTEM account
4. Handles battery/network conditions appropriately
**Usage:**
```powershell
# Install with defaults
.\Install-AssetCollectionSchedule.ps1
# Custom script path
.\Install-AssetCollectionSchedule.ps1 -ScriptPath "C:\Scripts\Update-PC-CompleteAsset-Silent.bat"
```
**Parameters:**
| Parameter | Default | Description |
|-----------|---------|-------------|
| `-ScriptPath` | `S:\DT\adata\script\Update-PC-CompleteAsset-Silent.bat` | Path to batch file |
| `-TaskName` | `"GE Asset Collection"` | Name for scheduled task |
**Schedule:**
- 6:00 AM
- 12:00 PM
- 6:00 PM
- 12:00 AM
**Requires:** Administrator privileges
---
### Test-API-Connection.ps1
**API connectivity tester** - Tests connectivity and functionality of the ShopDB API.
**What it does:**
1. Tests basic API connectivity (GET request)
2. Tests INSERT operation (creates test PC record)
3. Tests UPDATE operation (modifies test record)
4. Tests DELETE operation (cleans up test record)
5. Reports success/failure for each operation
**Usage:**
```powershell
# Test development API
.\Test-API-Connection.ps1
# Test production API
.\Test-API-Connection.ps1 -DashboardURL "https://production-server/shopdb/api.asp"
```
**Parameters:**
| Parameter | Default | Description |
|-----------|---------|-------------|
| `-DashboardURL` | `http://192.168.122.151:8080/api.asp` | API endpoint to test |
**Output Example:**
```
========================================
ShopDB API Connection Test
========================================
Test 1: Basic API Connectivity
[OK] API is online
Message: Dashboard API ready
Version: 2.0
Schema: Phase 2
Test 2: INSERT New PC Record
[OK] PC record created successfully
Hostname: TEST-PS-1234
Machine ID: 567
Operation: insert
Test 3: UPDATE PC Record
[OK] PC record updated successfully
Test 4: DELETE Test Record
[OK] Test record cleaned up
========================================
All tests passed!
========================================
```
---
## Batch File Launchers
| File | Purpose |
|------|---------|
| `Deploy-AssetCollectionSchedule.bat` | Deploys scheduled task to multiple PCs |
| `Install-Schedule.bat` | Local scheduled task installation |
---
## Requirements
- PowerShell 5.1 or later
- Administrator privileges
- Network access to ShopDB API (for Test-API-Connection.ps1)
## Common Use Cases
### Initial Setup on Management Server
```powershell
# 1. Configure WinRM to trust all shopfloor PCs
.\Setup-WinRM.ps1 -TrustedHosts "*"
# 2. Test API connectivity
.\Test-API-Connection.ps1 -DashboardURL "https://production-server/shopdb/api.asp"
```
### Deploy Scheduled Collection to a PC
```powershell
# On each target PC (as administrator):
.\Install-AssetCollectionSchedule.ps1
```
### Verify Everything is Working
```powershell
# Test API
.\Test-API-Connection.ps1
# Check scheduled task
Get-ScheduledTask -TaskName "GE Asset Collection" | Format-List
```

View File

@@ -0,0 +1,186 @@
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Sets up WinRM configuration for remote asset collection.
.DESCRIPTION
This script configures WinRM settings to enable remote PowerShell execution
for asset collection across shopfloor computers.
.PARAMETER TrustedHosts
Comma-separated list of trusted hosts (IP addresses or computer names).
Use "*" to trust all hosts (less secure but simpler).
.PARAMETER TestConnection
Test WinRM connection to specified computers after setup.
.EXAMPLE
.\Setup-WinRM.ps1 -TrustedHosts "10.48.130.100,10.48.130.101"
.EXAMPLE
.\Setup-WinRM.ps1 -TrustedHosts "*"
.NOTES
Author: System Administrator
Date: 2025-09-26
Version: 1.0
#>
param(
[Parameter(Mandatory=$false)]
[string]$TrustedHosts = "",
[Parameter(Mandatory=$false)]
[string[]]$TestConnection = @()
)
function Show-WinRMStatus {
Write-Host "=== Current WinRM Configuration ===" -ForegroundColor Cyan
try {
$winrmStatus = Get-Service WinRM
Write-Host "WinRM Service Status: $($winrmStatus.Status)" -ForegroundColor $(if($winrmStatus.Status -eq 'Running') {'Green'} else {'Red'})
$listeners = winrm enumerate winrm/config/listener
Write-Host "WinRM Listeners: $($listeners.Count) configured" -ForegroundColor Gray
$trustedHosts = (Get-Item WSMan:\localhost\Client\TrustedHosts).Value
Write-Host "Current Trusted Hosts: $trustedHosts" -ForegroundColor Gray
} catch {
Write-Host "Error checking WinRM status: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host ""
}
function Enable-WinRMConfiguration {
param([string]$TrustedHosts)
Write-Host "=== Configuring WinRM ===" -ForegroundColor Cyan
try {
# Enable PowerShell Remoting
Write-Host "Enabling PowerShell Remoting..." -ForegroundColor Yellow
Enable-PSRemoting -Force -SkipNetworkProfileCheck
Write-Host "[OK] PowerShell Remoting enabled" -ForegroundColor Green
# Start WinRM service
Write-Host "Starting WinRM service..." -ForegroundColor Yellow
Start-Service WinRM
Set-Service WinRM -StartupType Automatic
Write-Host "[OK] WinRM service started and set to automatic" -ForegroundColor Green
# Configure trusted hosts if specified
if (-not [string]::IsNullOrEmpty($TrustedHosts)) {
Write-Host "Setting trusted hosts to: $TrustedHosts" -ForegroundColor Yellow
Set-Item WSMan:\localhost\Client\TrustedHosts -Value $TrustedHosts -Force
Write-Host "[OK] Trusted hosts configured" -ForegroundColor Green
} else {
Write-Host "[SKIP] No trusted hosts specified" -ForegroundColor Yellow
}
# Configure firewall
Write-Host "Configuring Windows Firewall..." -ForegroundColor Yellow
try {
Set-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)" -Enabled True
Write-Host "[OK] Firewall rule enabled" -ForegroundColor Green
} catch {
Write-Host "[WARN] Could not configure firewall rule: $($_.Exception.Message)" -ForegroundColor Yellow
}
# Set authentication
Write-Host "Configuring authentication..." -ForegroundColor Yellow
Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true
Set-Item WSMan:\localhost\Service\Auth\CredSSP -Value $true
Write-Host "[OK] Authentication configured" -ForegroundColor Green
Write-Host ""
Write-Host "WinRM configuration completed successfully!" -ForegroundColor Green
} catch {
Write-Host "Error configuring WinRM: $($_.Exception.Message)" -ForegroundColor Red
return $false
}
return $true
}
function Test-WinRMConnections {
param([string[]]$Computers)
if ($Computers.Count -eq 0) {
return
}
Write-Host "=== Testing WinRM Connections ===" -ForegroundColor Cyan
$credential = Get-Credential -Message "Enter credentials for testing remote connections"
if (-not $credential) {
Write-Host "No credentials provided for testing" -ForegroundColor Yellow
return
}
foreach ($computer in $Computers) {
Write-Host "Testing connection to $computer..." -NoNewline
try {
$session = New-PSSession -ComputerName $computer -Credential $credential -ErrorAction Stop
Remove-PSSession $session
Write-Host " [OK]" -ForegroundColor Green
} catch {
Write-Host " [FAIL] $($_.Exception.Message)" -ForegroundColor Red
}
}
Write-Host ""
}
function Show-NextSteps {
Write-Host "=== Next Steps ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. Ensure target computers have WinRM enabled:" -ForegroundColor Yellow
Write-Host " Run this script on each target computer:" -ForegroundColor White
Write-Host " .\Setup-WinRM.ps1" -ForegroundColor Gray
Write-Host ""
Write-Host "2. Create your computer list file:" -ForegroundColor Yellow
Write-Host " Copy shopfloor-pcs-example.txt to shopfloor-pcs.txt" -ForegroundColor White
Write-Host " Edit the file to include your actual computer IP addresses" -ForegroundColor White
Write-Host ""
Write-Host "3. Test connections:" -ForegroundColor Yellow
Write-Host " .\Invoke-RemoteAssetCollection.ps1 -ComputerList @('10.48.130.100') -TestConnections" -ForegroundColor Gray
Write-Host ""
Write-Host "4. Run asset collection:" -ForegroundColor Yellow
Write-Host " .\Invoke-RemoteAssetCollection.ps1 -ComputerListFile .\shopfloor-pcs.txt" -ForegroundColor Gray
Write-Host " or" -ForegroundColor White
Write-Host " .\Run-RemoteCollection.bat" -ForegroundColor Gray
Write-Host ""
}
# Main execution
try {
Write-Host "=== WinRM Setup Script ===" -ForegroundColor Cyan
Write-Host "Date: $(Get-Date)" -ForegroundColor Gray
Write-Host ""
# Show current status
Show-WinRMStatus
# Configure WinRM
$success = Enable-WinRMConfiguration -TrustedHosts $TrustedHosts
if ($success) {
# Show updated status
Show-WinRMStatus
# Test connections if requested
if ($TestConnection.Count -gt 0) {
Test-WinRMConnections -Computers $TestConnection
}
# Show next steps
Show-NextSteps
}
} catch {
Write-Host "Fatal error: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}

View File

@@ -0,0 +1,170 @@
# Test script for ShopDB API connectivity and functionality
# Tests the new Phase 2 ASP API endpoint
param(
[Parameter(Mandatory=$false)]
[string]$DashboardURL = "http://192.168.122.151:8080/api.asp"
)
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "ShopDB API Connection Test" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Test 1: Basic connectivity
Write-Host "Test 1: Basic API Connectivity" -ForegroundColor Yellow
try {
$response = Invoke-RestMethod -Uri "$DashboardURL?action=getDashboardData" -Method Get -TimeoutSec 10
if ($response.success) {
Write-Host " [OK] API is online" -ForegroundColor Green
Write-Host " Message: $($response.message)" -ForegroundColor Gray
Write-Host " Version: $($response.version)" -ForegroundColor Gray
Write-Host " Schema: $($response.schema)" -ForegroundColor Gray
} else {
Write-Host " [FAIL] API responded but not successful" -ForegroundColor Red
exit 1
}
} catch {
Write-Host " [FAIL] Cannot reach API: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
Write-Host ""
# Test 2: INSERT new PC
Write-Host "Test 2: INSERT New PC Record" -ForegroundColor Yellow
$testHostname = "TEST-PS-" + (Get-Random -Minimum 1000 -Maximum 9999)
$testSerial = "SER-" + (Get-Random -Minimum 100000 -Maximum 999999)
try {
$postData = @{
action = 'updateCompleteAsset'
hostname = $testHostname
serialNumber = $testSerial
manufacturer = 'Dell'
model = 'OptiPlex 7090'
pcType = 'Standard'
loggedInUser = 'testuser'
osVersion = 'Windows 10 Pro'
}
$response = Invoke-RestMethod -Uri $DashboardURL -Method Post -Body $postData -TimeoutSec 30
if ($response.success) {
Write-Host " [OK] PC record created successfully" -ForegroundColor Green
Write-Host " Hostname: $testHostname" -ForegroundColor Gray
Write-Host " Machine ID: $($response.machineid)" -ForegroundColor Gray
Write-Host " Operation: $($response.operation)" -ForegroundColor Gray
$machineId = $response.machineid
} else {
Write-Host " [FAIL] Failed to create PC: $($response.error)" -ForegroundColor Red
exit 1
}
} catch {
Write-Host " [FAIL] Error creating PC: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
Write-Host ""
# Test 3: UPDATE existing PC
Write-Host "Test 3: UPDATE Existing PC Record" -ForegroundColor Yellow
$updatedSerial = "SER-UPDATED-" + (Get-Random -Minimum 100000 -Maximum 999999)
try {
$postData = @{
action = 'updateCompleteAsset'
hostname = $testHostname
serialNumber = $updatedSerial
manufacturer = 'Dell'
model = 'OptiPlex 7090'
pcType = 'Engineer' # Changed type
loggedInUser = 'updateduser'
osVersion = 'Windows 10 Enterprise'
}
$response = Invoke-RestMethod -Uri $DashboardURL -Method Post -Body $postData -TimeoutSec 30
if ($response.success) {
Write-Host " [OK] PC record updated successfully" -ForegroundColor Green
Write-Host " Hostname: $testHostname" -ForegroundColor Gray
Write-Host " Machine ID: $($response.machineid)" -ForegroundColor Gray
Write-Host " Serial Updated: $updatedSerial" -ForegroundColor Gray
} else {
Write-Host " [FAIL] Failed to update PC: $($response.error)" -ForegroundColor Red
exit 1
}
} catch {
Write-Host " [FAIL] Error updating PC: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
Write-Host ""
# Test 4: INSERT Shopfloor PC with network interfaces
Write-Host "Test 4: INSERT Shopfloor PC with Network Data" -ForegroundColor Yellow
$shopfloorHostname = "SHOPFLOOR-TEST-" + (Get-Random -Minimum 1000 -Maximum 9999)
$shopfloorSerial = "SER-SF-" + (Get-Random -Minimum 100000 -Maximum 999999)
try {
$networkInterfaces = @(
@{
InterfaceName = "Ethernet0"
IPAddress = "192.168.1.100"
SubnetMask = 24
MACAddress = "00-11-22-33-44-55"
IsDHCP = 0
IsMachineNetwork = 1
},
@{
InterfaceName = "Ethernet1"
IPAddress = "10.48.130.50"
SubnetMask = 24
MACAddress = "00-11-22-33-44-66"
IsDHCP = 1
IsMachineNetwork = 0
}
) | ConvertTo-Json -Compress
$postData = @{
action = 'updateCompleteAsset'
hostname = $shopfloorHostname
serialNumber = $shopfloorSerial
manufacturer = 'Dell'
model = 'OptiPlex 7060'
pcType = 'Shopfloor'
loggedInUser = 'shopfloor'
osVersion = 'Windows 10 Enterprise LTSC'
machineNo = 'M123'
networkInterfaces = $networkInterfaces
}
$response = Invoke-RestMethod -Uri $DashboardURL -Method Post -Body $postData -TimeoutSec 30
if ($response.success) {
Write-Host " [OK] Shopfloor PC created with network data" -ForegroundColor Green
Write-Host " Hostname: $shopfloorHostname" -ForegroundColor Gray
Write-Host " Machine ID: $($response.machineid)" -ForegroundColor Gray
Write-Host " Network Interfaces: $($response.data.networkInterfaces)" -ForegroundColor Gray
Write-Host " Machine No: M123" -ForegroundColor Gray
} else {
Write-Host " [FAIL] Failed to create shopfloor PC: $($response.error)" -ForegroundColor Red
exit 1
}
} catch {
Write-Host " [FAIL] Error creating shopfloor PC: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "All Tests PASSED!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Summary:" -ForegroundColor Yellow
Write-Host " - API connectivity verified" -ForegroundColor White
Write-Host " - INSERT operations working" -ForegroundColor White
Write-Host " - UPDATE operations working" -ForegroundColor White
Write-Host " - Shopfloor PC with network data working" -ForegroundColor White
Write-Host " - Phase 2 schema validated" -ForegroundColor White
Write-Host ""