windows-setup: say when Windows needs a restart before the SSH server exists
Add-WindowsCapability can finish without registering the sshd service until the PC restarts; the script stopped with a raw Set-Service error. It now prints a RESULT block saying to restart and run it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
# Status panel remote access for NA Ingest - run ONCE on each Windows PC
|
# Status panel remote access for NA Ingest - run ONCE on each Windows PC
|
||||||
# (OBS PC, Lighting PC, Bible TV PC), logged in as the normal user.
|
# (OBS PC, Lighting PC, Bible TV PC), logged in as the normal user.
|
||||||
#
|
#
|
||||||
# 1. Start menu -> type PowerShell -> right-click -> Run as administrator
|
# 1. Save this file as C:\Users\<you>\windows-setup.ps1
|
||||||
# 2. Paste this whole file and press Enter
|
# 2. Start menu -> type PowerShell -> right-click -> Run as administrator
|
||||||
# 3. Send the "RESULT" block it prints back to Claude
|
# 3. Set-ExecutionPolicy RemoteSigned -Scope CurrentUser (answer Y; once per PC)
|
||||||
|
# 4. Run it: & "$env:USERPROFILE\windows-setup.ps1"
|
||||||
|
# 5. Send the "RESULT" block it prints back to Claude. If it says RESTART THIS PC,
|
||||||
|
# restart, then repeat steps 2 and 4.
|
||||||
#
|
#
|
||||||
# It turns on Windows' built-in SSH server, lets NA Ingest log in with its key
|
# It turns on Windows' built-in SSH server, lets NA Ingest log in with its key
|
||||||
# (no password), and creates "start" tasks for the apps it finds (OBS, Resolume
|
# (no password), and creates "start" tasks for the apps it finds (OBS, Resolume
|
||||||
@@ -16,7 +19,21 @@ $notes = @()
|
|||||||
|
|
||||||
# 1. OpenSSH Server, started now and at every boot, allowed through the firewall
|
# 1. OpenSSH Server, started now and at every boot, allowed through the firewall
|
||||||
$cap = Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Server*' | Select-Object -First 1
|
$cap = Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Server*' | Select-Object -First 1
|
||||||
if ($cap.State -ne 'Installed') { Add-WindowsCapability -Online -Name $cap.Name | Out-Null }
|
if (-not $cap) { throw 'This Windows has no OpenSSH Server feature to install - send this message to Claude.' }
|
||||||
|
$restart = $false
|
||||||
|
if ($cap.State -ne 'Installed') {
|
||||||
|
Write-Host 'Installing the OpenSSH Server (Windows downloads it - this can take 10 minutes)...'
|
||||||
|
$restart = [bool](Add-WindowsCapability -Online -Name $cap.Name).RestartNeeded
|
||||||
|
}
|
||||||
|
if (-not (Get-Service sshd -ErrorAction SilentlyContinue)) {
|
||||||
|
$state = (Get-WindowsCapability -Online -Name $cap.Name).State
|
||||||
|
Write-Host ''
|
||||||
|
Write-Host '===== RESULT (send this to Claude) ====='
|
||||||
|
Write-Host ('pc=' + $env:COMPUTERNAME + ' sshd=missing openssh=' + $state + ' restart_needed=' + $restart)
|
||||||
|
Write-Host 'RESTART THIS PC, then run this script again.'
|
||||||
|
Write-Host '========================================'
|
||||||
|
return
|
||||||
|
}
|
||||||
Set-Service -Name sshd -StartupType Automatic
|
Set-Service -Name sshd -StartupType Automatic
|
||||||
Start-Service sshd
|
Start-Service sshd
|
||||||
if (-not (Get-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -ErrorAction SilentlyContinue)) {
|
if (-not (Get-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -ErrorAction SilentlyContinue)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user