param( [switch]$Strict, [switch]$Help ) $ErrorActionPreference = 'Stop' $ScriptName = Split-Path -Leaf $PSCommandPath if ($Help) { @' Usage: win-tool-check.ps1 [-Strict] [-Help] Read-only Windows workstation checks for PenWebTools helpers. '@ exit 0 } function Write-Section { param([string]$Name) Write-Host "" Write-Host "== $Name ==" } function Test-Command { param([string]$Name) $cmd = Get-Command $Name -ErrorAction SilentlyContinue if ($cmd) { Write-Host ("OK {0,-12} {1}" -f $Name, $cmd.Source) return $true } Write-Host ("MISSING {0,-12}" -f $Name) return $false } Write-Section 'PowerShell' Write-Host "Version: $($PSVersionTable.PSVersion)" Write-Host "Edition: $($PSVersionTable.PSEdition)" Write-Host "Host: $($Host.Name)" Write-Host "ExecutionPolicy CurrentUser: $(Get-ExecutionPolicy -Scope CurrentUser)" Write-Host "ExecutionPolicy Process: $(Get-ExecutionPolicy -Scope Process)" Write-Section 'Profiles' $profiles = @( $PROFILE.CurrentUserCurrentHost, $PROFILE.CurrentUserAllHosts ) | Select-Object -Unique foreach ($path in $profiles) { $exists = Test-Path -LiteralPath $path $state = if ($exists) { 'exists' } else { 'missing' } Write-Host "$state $path" if ($exists) { $hasBlock = Select-String -LiteralPath $path -SimpleMatch '# >>> penwebtools-powershell-prompt' -Quiet Write-Host " penwebtools prompt block: $hasBlock" } } Write-Section 'Commands' $requiredOk = $true foreach ($name in @('powershell', 'curl', 'git', 'ssh', 'winget', 'wsl', 'pwsh')) { if (-not (Test-Command $name)) { if ($name -eq 'powershell') { $requiredOk = $false } } } Write-Section 'Windows' Write-Host "OS: $([System.Environment]::OSVersion.VersionString)" Write-Host "User: $([System.Environment]::UserName)" Write-Host "Is64BitOS: $([System.Environment]::Is64BitOperatingSystem)" if ($Strict -and -not $requiredOk) { Write-Host "[$ScriptName] Strict check failed." exit 1 }