Я запускаю скрипт, вставленный ниже:
function grep { $input | out-string -stream | select-string $args }
function Install-SSH { Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Client*' | grep('Name\s*:\s(\S+)') | % { Add-WindowsCapability -Online -Name $_.matches.groups[1].Value } }
function Uninstall-SSH { Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Client*' | grep('Name\s*:\s(\S+)') | % { Remove-WindowsCapability -Online -Name $_.matches.groups[1].Value } }
if((([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")) {
#Administrator Payload goes here.
Write-Host -ForegroundColor Green "Installing SSH..."
Get-WindowsCapability -Online
Pause #Debugging purposes
} else {
Write-Host -ForegroundColor Red "Powershell script running as Guest. Trying to run as administrator..."
Set-Location -Path $PSScriptRoot
$registryPath = "HKCU:\Environment"
$Name = "windir"
$Value = "powershell -ep bypass -w n $PSCommandPath;#"
Set-ItemProperty -Path $registryPath -Name $name -Value $Value
schtasks /run /tn \Microsoft\Windows\DiskCleanup\SilentCleanup /I | Out-Null
Remove-ItemProperty -Path $registryPath -Name $name
}
И я получаю следующую ошибку в выводе, и я не могу найти в сети ничего, что помогло бы понять, что здесь происходит. Что я делаю не так?
Installing SSH...
Get-WindowsCapability : Set current directory to C:\WINDOWS\system32 failed:The given path's format is not supported.
At D:\Code\projects\powershell-scripts\SSHInstallation.ps1:10 char:5
+ Get-WindowsCapability -Online
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Microsoft.Dism.Commands.BaseDismObject:BaseDismObject) [Get-WindowsCapabi
lity], Exception
+ FullyQualifiedErrorId : BaseCmdLet,Microsoft.Dism.Commands.GetWindowsCapabilityCommand