File tree Expand file tree Collapse file tree 4 files changed +16
-15
lines changed
docs/reference/schemas/config/functions Expand file tree Collapse file tree 4 files changed +16
-15
lines changed Original file line number Diff line number Diff line change
1
+ $Script :IsPowerShellCore = $PSVersionTable.PSEdition -eq ' Core'
2
+
3
+ if ($Script :IsPowerShellCore ) {
4
+ if ($IsWindows ) {
5
+ Import-Module - Name ' PSDesiredStateConfiguration' - RequiredVersion 1.1 - UseWindowsPowerShell - WarningAction SilentlyContinue
6
+ }
7
+ Import-Module - Name ' PSDesiredStateConfiguration' - MinimumVersion 2.0 .7 - Prefix ' Pwsh' - WarningAction SilentlyContinue
8
+ } else {
9
+ Import-Module - Name ' PSDesiredStateConfiguration' - RequiredVersion 1.1 - WarningAction SilentlyContinue
10
+ }
11
+
1
12
function Write-DscTrace {
2
13
param (
3
14
[Parameter (Mandatory = $false )]
@@ -11,19 +22,6 @@ function Write-DscTrace {
11
22
$host.ui.WriteErrorLine ($trace )
12
23
}
13
24
14
- $Script :IsPowerShellCore = $PSVersionTable.PSEdition -eq ' Core'
15
-
16
- if ($Script :IsPowerShellCore ) {
17
- if ($IsWindows ) {
18
- Import-Module - Name ' PSDesiredStateConfiguration' - RequiredVersion 1.1 - UseWindowsPowerShell - WarningAction SilentlyContinue
19
- }
20
- Import-Module - Name ' PSDesiredStateConfiguration' - MinimumVersion 2.0 .7 - Prefix ' Pwsh' - WarningAction SilentlyContinue
21
- } else {
22
- " Loading module: 'PSDesiredStateConfiguration" | Write-DscTrace - Operation Trace
23
- " The PSModulePaths: $env: PSModulePath " | Write-DscTrace - Operation Trace
24
- Import-Module - Name ' PSDesiredStateConfiguration' - RequiredVersion 1.1 - WarningAction SilentlyContinue
25
- }
26
-
27
25
function Build-DscConfigDocument {
28
26
[CmdletBinding ()]
29
27
[OutputType ([System.Collections.Specialized.OrderedDictionary ])]
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ Describe 'PowerShell extension tests' {
15
15
$out = dsc - l trace config get -f $psFile 2> $TestDrive / error.log | ConvertFrom-Json
16
16
$LASTEXITCODE | Should - Be 0 - Because (Get-Content - Path $TestDrive / error.log - Raw | Out-String )
17
17
$out.results [0 ].result.actualState.Ensure | Should - Be ' Absent'
18
- (Get-Content - Path $TestDrive / error.log - Raw) | Should -Match " Importing file '$psFile ' with extension 'Microsoft.DSC.Extension/PowerShell'"
18
+ $psFile = $psFile.ToString ().Replace(' \' , ' \\' )
19
+ (Get-Content - Path $TestDrive / error.log - Raw) | Should -Match " Importing file '$psFile ' with extension 'Microsoft.DSC.Extension/WindowsPowerShell'"
19
20
}
20
21
21
22
It ' Invalid PowerShell configuration document file returns error' - Skip:(! $IsWindows ) {
@@ -35,7 +36,8 @@ configuration InvalidConfiguration {
35
36
dsc - l trace config get -f $psFile 2> $TestDrive / error.log
36
37
$LASTEXITCODE | Should - Be 2 - Because (Get-Content - Path $TestDrive / error.log - Raw | Out-String )
37
38
$content = (Get-Content - Path $TestDrive / error.log - Raw)
38
- $content | Should - BeLike " *Importing file '$psFile ' with extension 'Microsoft.DSC.Extension/WindowsPowerShell'*"
39
+ $psFile = $psFile.ToString ().Replace(' \' , ' \\' )
40
+ $content | Should -Match " Importing file '$psFile ' with extension 'Microsoft.DSC.Extension/WindowsPowerShell'"
39
41
$content | Should -Match " No DSC resources found in the imported modules."
40
42
}
41
43
}
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ Describe 'WindowsPowerShell adapter resource tests - requires elevated permissio
48
48
}
49
49
50
50
It ' Get works on Binary "File" resource' {
51
+
51
52
$testFile = " $testdrive \test.txt"
52
53
' test' | Set-Content - Path $testFile - Force
53
54
$r = ' {"DestinationPath":"' + $testFile.replace (' \' , ' \\' ) + ' "}' | dsc resource get - r ' PSDesiredStateConfiguration/File' -f -
You can’t perform that action at this time.
0 commit comments