1313
1414param
1515(
16- [Switch ]$Verbose
16+ [parameter (ParameterSetName = " ByPath" )]
17+ [ValidateNotNullOrEmpty ()]
18+ [string ]
19+ $PowerShellHome ,
20+
21+ [parameter (ParameterSetName = " ByPath" )]
22+ [ValidateNotNullOrEmpty ()]
23+ [string ]
24+ $PowerShellVersion
1725)
1826
1927function Register-WinRmPlugin
@@ -74,13 +82,18 @@ function Generate-PluginConfigFile
7482 [string ]
7583 [parameter (Mandatory = $true )]
7684 [ValidateNotNullOrEmpty ()]
77- $pluginFile
85+ $pluginFile ,
86+
87+ [string ]
88+ [parameter (Mandatory = $true )]
89+ [ValidateNotNullOrEmpty ()]
90+ $powershellHomeDir
7891 )
7992
8093 # This always overwrites the file with a new version of it if the
8194 # script is invoked multiple times.
82- Set-Content - Path $pluginFile - Value " PSHOMEDIR=$PSHOME "
83- Add-Content - Path $pluginFile - Value " CORECLRDIR=$PSHOME "
95+ Set-Content - Path $pluginFile - Value " PSHOMEDIR=$powershellHomeDir "
96+ Add-Content - Path $pluginFile - Value " CORECLRDIR=$powershellHomeDir "
8497
8598 Write-Verbose " Created Plugin Config File: $pluginFile "
8699}
@@ -103,7 +116,9 @@ if ($Verbose)
103116 $VerbosePreference = " Continue"
104117}
105118
106- $powershellVersion = $PSVersionTable.PSVersion
119+ $powershellVersion = $PowershellVersion
120+ $powershellHome = $PowerShellHome
121+
107122$pluginBasePath = Join-Path " $env: WINDIR \System32\PowerShell" $powerShellVersion
108123
109124$resolvedPluginAbsolutePath = " "
@@ -122,10 +137,10 @@ $pluginRawPath = Join-Path $resolvedPluginAbsolutePath "pwrshplugin.dll"
122137$fixedPluginPath = $pluginRawPath -replace ' \\' , ' \\'
123138
124139# This is forced to ensure the the file is placed correctly
125- Copy-Item $PSHOME \pwrshplugin.dll $resolvedPluginAbsolutePath - Force - Verbose
140+ Copy-Item $powershellHome \pwrshplugin.dll $resolvedPluginAbsolutePath - Force - Verbose
126141
127142$pluginFile = Join-Path $resolvedPluginAbsolutePath " RemotePowerShellConfig.txt"
128- Generate- PluginConfigFile $pluginFile
143+ Generate- PluginConfigFile $pluginFile $powershellHome
129144
130145$pluginEndpointName = " powershell.$powershellVersion "
131146
0 commit comments