File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,22 @@ param (
6
6
7
7
begin {
8
8
$lines = [System.Collections.Generic.List [string ]]::new()
9
- $Operation = ' Trace'
9
+
10
+ if ($PSVersionTable.PSEdition -ne ' Core' ) {
11
+ # Remove all PowerShell paths
12
+ $env: PSModulePath = ($env: PSModulePath -split ' ;' | Where-Object {
13
+ $_ -notmatch ' PowerShell[\\/]7' -and
14
+ $_ -notmatch ' Program Files[\\/]PowerShell[\\/]' -and
15
+ $_ -notmatch ' Documents[\\/]PowerShell[\\/]'
16
+ }) -join ' ;'
10
17
11
- $trace = @ {$Operation.ToLower () = " The current module paths: $env: PSModulePath " } | ConvertTo-Json - Compress
12
- $host.ui.WriteErrorLine ($trace )
18
+ # Make sure the default path is Windows PowerShell is included
19
+ $winPsPath = " $env: windir \System32\WindowsPowerShell\v1.0\Modules"
20
+ if ($env: PSModulePath -notmatch [regex ]::Escape($winPsPath )) {
21
+ # Separator is already at the end
22
+ $env: PSModulePath = $env: PSModulePath + $winPsPath
23
+ }
24
+ }
13
25
14
26
$scriptModule = Import-Module " $PSScriptRoot /convertDscResource.psd1" - Force - PassThru - WarningAction SilentlyContinue - ErrorAction Stop
15
27
}
You can’t perform that action at this time.
0 commit comments