@@ -39,13 +39,19 @@ if (Get-Service ssh-agent -ErrorAction SilentlyContinue)
3939 sc.exe delete ssh- agent 1> $null
4040}
4141
42- # unregister etw provider
43- wevtutil um `" $etwman `"
42+ # Unregister etw provider
43+ # PowerShell 7.3+ has new/different native command argument parsing
44+ if ($PSVersiontable.PSVersion -le ' 7.2.9' ) {
45+ wevtutil um `" $etwman `"
46+ }
47+ else {
48+ wevtutil um " $etwman "
49+ }
4450
4551# adjust provider resource path in instrumentation manifest
4652[XML ]$xml = Get-Content $etwman
47- $xml.instrumentationManifest.instrumentation.events.provider.resourceFileName = $sshagentpath.ToString ()
48- $xml.instrumentationManifest.instrumentation.events.provider.messageFileName = $sshagentpath.ToString ()
53+ $xml.instrumentationManifest.instrumentation.events.provider.resourceFileName = " $sshagentpath "
54+ $xml.instrumentationManifest.instrumentation.events.provider.messageFileName = " $sshagentpath "
4955
5056$streamWriter = $null
5157$xmlWriter = $null
@@ -114,16 +120,21 @@ if (Test-Path $sshProgDataPath)
114120 }
115121}
116122
117- # register etw provider
118- wevtutil im `" $etwman `"
123+ # Register etw provider
124+ # PowerShell 7.3+ has new/different native command argument parsing
125+ if ($PSVersiontable.PSVersion -le ' 7.2.9' ) {
126+ wevtutil im `" $etwman `"
127+ } else {
128+ wevtutil im " $etwman "
129+ }
119130
120131$agentDesc = " Agent to hold private keys used for public key authentication."
121- New-Service - Name ssh- agent - DisplayName " OpenSSH Authentication Agent" - BinaryPathName ` "$sshagentpath ` " - Description $agentDesc - StartupType Manual | Out-Null
132+ New-Service - Name ssh- agent - DisplayName " OpenSSH Authentication Agent" - BinaryPathName " $sshagentpath " - Description $agentDesc - StartupType Manual | Out-Null
122133sc.exe sdset ssh- agent " D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RP;;;AU)"
123134sc.exe privs ssh- agent SeAssignPrimaryTokenPrivilege/ SeTcbPrivilege/ SeBackupPrivilege/ SeRestorePrivilege/ SeImpersonatePrivilege
124135
125136$sshdDesc = " SSH protocol based service to provide secure encrypted communications between two untrusted hosts over an insecure network."
126- New-Service - Name sshd - DisplayName " OpenSSH SSH Server" - BinaryPathName ` "$sshdpath ` " - Description $sshdDesc - StartupType Manual | Out-Null
137+ New-Service - Name sshd - DisplayName " OpenSSH SSH Server" - BinaryPathName " $sshdpath " - Description $sshdDesc - StartupType Manual | Out-Null
127138sc.exe privs sshd SeAssignPrimaryTokenPrivilege/ SeTcbPrivilege/ SeBackupPrivilege/ SeRestorePrivilege/ SeImpersonatePrivilege
128139
129140Write-Host - ForegroundColor Green " sshd and ssh-agent services successfully installed"
0 commit comments