mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Don't fail if SaferPolicy API is not available on Win10 IoT or NanoServer (#7075)
* don't fail if SaferApi is not available * fix install-powershellremoting to work on Windows PowerShell 5.1
This commit is contained in:
committed by
Aditya Patwardhan
parent
bda8fd376c
commit
abcdce4e3e
@@ -124,7 +124,7 @@ function Install-PluginEndpoint {
|
||||
# #
|
||||
######################
|
||||
|
||||
if ($PsCmdlet.ParameterSetName -eq "ByPath")
|
||||
if ($PowerShellHome -ne $null)
|
||||
{
|
||||
$targetPsHome = $PowerShellHome
|
||||
$targetPsVersion = & "$targetPsHome\pwsh" -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
|
||||
@@ -135,6 +135,7 @@ function Install-PluginEndpoint {
|
||||
$targetPsHome = $PSHOME
|
||||
$targetPsVersion = $PSVersionTable.PSVersion.ToString()
|
||||
}
|
||||
Write-Verbose "PowerShellHome: $targetPsHome" -Verbose
|
||||
|
||||
# For default, not tied to the specific version endpoint, we apply
|
||||
# only first number in the PSVersion string to the endpoint name.
|
||||
@@ -163,7 +164,16 @@ function Install-PluginEndpoint {
|
||||
return
|
||||
}
|
||||
|
||||
$pluginBasePath = Join-Path ([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Windows) + "\System32\PowerShell") $targetPsVersion
|
||||
if ($PSVersionTable.PSVersion -lt "6.0")
|
||||
{
|
||||
# This script is primarily used from Windows PowerShell for Win10 IoT and NanoServer to setup PSCore6 remoting endpoint
|
||||
# so it's ok to hardcode to 'C:\Windows' for those systems
|
||||
$pluginBasePath = Join-Path "C:\Windows\System32\PowerShell" $targetPsVersion
|
||||
}
|
||||
else
|
||||
{
|
||||
$pluginBasePath = Join-Path ([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Windows) + "\System32\PowerShell") $targetPsVersion
|
||||
}
|
||||
|
||||
$resolvedPluginAbsolutePath = ""
|
||||
if (! (Test-Path $pluginBasePath))
|
||||
|
||||
Reference in New Issue
Block a user