From b06961eaa5877ad93f35d09951080ada0e100084 Mon Sep 17 00:00:00 2001 From: Paul DiMaggio Date: Wed, 29 Nov 2023 12:14:47 -0500 Subject: [PATCH] Fixed WindowsPowerShell Profile Path and added IMPORTANT NOTE Line 42-46 --- MyScripts/Bootstrap-RemoteHostViaSSH.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MyScripts/Bootstrap-RemoteHostViaSSH.ps1 b/MyScripts/Bootstrap-RemoteHostViaSSH.ps1 index b5fea3f..68d3150 100644 --- a/MyScripts/Bootstrap-RemoteHostViaSSH.ps1 +++ b/MyScripts/Bootstrap-RemoteHostViaSSH.ps1 @@ -39,6 +39,11 @@ $ScriptsBaseUri = "https://raw.githubusercontent.com/pldmgg/misc-powershell/mast } } +# IMPORTANT NOTE: If YOU are not the one to install SSH/SSHD on the remote Windows Machine using the above... +# Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/pldmgg/misc-powershell/master/MyScripts/Install-SSHD.ps1')) +# ...make sure you set powershell.exe as the default shell for SSHD on the remote host via: +# $PowerShellBinPath = $(Get-Command "powershell.exe").Source; Set-ItemProperty -Path HKLM:\SOFTWARE\OpenSSH -Name DefaultShell -Value $PowerShellBinPath -ErrorAction Stop + $ScriptsDir = "C:\Scripts" Import-Module "$ScriptsDir\powershell\BootstrapRemoteHost.psm1" $NewComputerName = "win11services1" @@ -109,7 +114,7 @@ $null = Invoke-WebRequest -Uri "https://raw.githubusercontent.com/pldmgg/misc-po # Set profile.ps1 for Windows PowerShell $PSProfilePath = "C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1" -$PSProfilePath1 = "C:\Users\$RemoteUserName\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" +$PSProfilePath1 = "C:\Users\$RemoteUserName\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" $SCPRemoteLocationStringPSProfile = $RemoteUserName + '@' + $RemoteIPAddress + ':' + $PSProfilePath $SCPRemoteLocationStringPSProfile1 = $RemoteUserName + '@' + $RemoteIPAddress + ':' + $PSProfilePath1 scp.exe -i $SSHPrivateKeyPath $tempFileForProfile $SCPRemoteLocationStringPSProfile