# Start a remote computer by TargetHost name using database of known hosts param( [Parameter(Mandatory)] [string]$TargetHost, # Hostname when up "PortalControl" [string]$LogonUserName ="", # The account that auto-logs on (SAM name, e.g. "RoyF") [string]$HostMACList = ".\localComputers.csv" # Known MAC addresses for target hosts, in format "TargetHost,MACAddress" (e.g. "PortalControl,00:11:22:33:44:55") ) $data = Import-Csv -Path $HostMACList $targetEntry = $data | Where-Object { $_.TargetHost -eq $TargetHost } if (-not $targetEntry) { Write-Error "No entry found for -TargetHost '$TargetHost' in '$HostMACList'." exit 1 } Write-Host "Initiating wake-on-lan for $($targetEntry.TargetHost) with MAC address $($targetEntry.MACAddress)" -ForegroundColor Cyan $cmd = ".\RemoteStartup.ps1 -MacAddress $($targetEntry.MACAddress) -TargetHost $($targetEntry.TargetHost)" if ($LogonUserName -ne "") { $cmd += " -LogonUserName $LogonUserName" } Invoke-Expression -Command $cmd