@@ -64,34 +64,16 @@ $script:CompatibilityTestCases = @(
64
64
@ { Target = $script :Srv2019_5_profile ; Script = ' fhx $filePath' ; Commands = @ (); Version = " 5.1" ; OS = " Windows" ; ProblemCount = 0 }
65
65
66
66
@ { Target = $script :Srv2019_6_1_profile ; Script = " Add-PSSnapIn MySnapIn" ; Commands = @ (" Add-PSSnapIn" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
67
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' ConvertFrom-String $str' ; Commands = @ (" ConvertFrom-String" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
68
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' $cb = Get-Clipboard' ; Commands = @ (" Get-Clipboard" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
69
67
@ { Target = $script :Srv2019_6_1_profile ; Script = " Get-PSSnapIn MySnapIn" ; Commands = @ (" Get-PSSnapIn" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
70
- @ { Target = $script :Srv2019_6_1_profile ; Script = " Get-WmiObject -Class Win32_Process" ; Commands = @ (" Get-WmiObject" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
71
- @ { Target = $script :Srv2019_6_1_profile ; Script = " Invoke-WmiMethod -Path win32_process -Name create -ArgumentList notepad.exe" ; Commands = @ (" Invoke-WmiMethod" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
72
68
@ { Target = $script :Srv2019_6_1_profile ; Script = " Get-Content $pshome \about_signing.help.txt | Out-Printer" ; Commands = @ (" Out-Printer" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
73
69
@ { Target = $script :Srv2019_6_1_profile ; Script = ' New-PSWorkflowSession -ComputerName "ServerNode01" -Name "WorkflowTests" -SessionOption (New-PSSessionOption -OutputBufferingMode Drop)' ; Commands = @ (" New-PSWorkflowSession" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
74
70
@ { Target = $script :Srv2019_6_1_profile ; Script = " Get-Process | Out-GridView" ; Commands = @ (" Out-GridView" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
75
71
@ { Target = $script :Srv2019_6_1_profile ; Script = " Get-Process | ogv" ; Commands = @ (" ogv" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
76
72
@ { Target = $script :Srv2019_6_1_profile ; Script = " Remove-PSSnapIn MySnapIn" ; Commands = @ (" Remove-PSSnapIn" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
77
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' $np | Remove-WmiObject' ; Commands = @ (" Remove-WmiObject" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
78
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Set-Clipboard -Value "This is a test string"' ; Commands = @ (" Set-Clipboard" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
79
73
@ { Target = $script :Srv2019_6_1_profile ; Script = " Show-Command" ; Commands = @ (" Show-Command" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
80
- @ { Target = $script :Srv2019_6_1_profile ; Script = " Set-WmiInstance -Class Win32_WMISetting -Argument @{LoggingLevel=2}" ; Commands = @ (" Set-WmiInstance" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
81
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Add-Computer -DomainName "Domain01" -Restart' ; Commands = @ (" Add-Computer" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
82
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Checkpoint-Computer -Description "Install MyApp"' ; Commands = @ (" Checkpoint-Computer" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
83
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Clear-EventLog "Windows PowerShell"' ; Commands = @ (" Clear-EventLog" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
84
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Clear-RecycleBin' ; Commands = @ (" Clear-RecycleBin" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
85
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Start-Transaction; New-Item MyCompany -UseTransaction; Complete-Transaction' ; Commands = @ (" Start-Transaction" , " Complete-Transaction" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 2 }
86
74
@ { Target = $script :Srv2019_6_1_profile ; Script = ' $composers | Convert-String -Example "first middle last=last, first"' ; Commands = @ (" Convert-String" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
87
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Disable-ComputerRestore -Drive "C:\"' ; Commands = @ (" Disable-ComputerRestore" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
88
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Enable-ComputerRestore -Drive "C:\", "D:\"' ; Commands = @ (" Enable-ComputerRestore" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
89
75
@ { Target = $script :Srv2019_6_1_profile ; Script = ' Export-Console -Path $pshome\Consoles\ConsoleS1.psc1' ; Commands = @ (" Export-Console" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
90
76
@ { Target = $script :Srv2019_6_1_profile ; Script = ' Get-Counter "\Processor(*)\% Processor Time" | Export-Counter -Path $home\Counters.blg' ; Commands = @ (" Get-Counter" , " Export-Counter" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 2 }
91
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Get-ControlPanelItem -Name "*Program*", "*App*"' ; Commands = @ (" Get-ControlPanelItem" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
92
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Get-EventLog -Newest 5 -LogName "Application"' ; Commands = @ (" Get-EventLog" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
93
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' Get-HotFix -Description "Security*" -ComputerName "Server01", "Server02" -Cred "Server01\admin01"' ; Commands = @ (" Get-HotFix" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
94
- @ { Target = $script :Srv2019_6_1_profile ; Script = ' $zip = New-WebServiceProxy -Uri "http://www.webservicex.net/uszip.asmx?WSDL"' ; Commands = @ (" New-WebServiceProxy" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
95
77
@ { Target = $script :Srv2019_6_1_profile ; Script = ' curl $uri' ; Commands = @ (" curl" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
96
78
@ { Target = $script :Srv2019_6_1_profile ; Script = ' Get-ChildItem ./ | Format-List' ; Commands = @ (); Version = " 3.0" ; OS = " Windows" ; ProblemCount = 0 }
97
79
@ { Target = $script :Srv2019_6_1_profile ; Script = ' gci .' ; Commands = @ (); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 0 }
@@ -105,6 +87,28 @@ $script:CompatibilityTestCases = @(
105
87
@ { Target = $script :Ubuntu1804_6_1_profile ; Script = ' Get-ChildItem ./ | Format-List' ; Commands = @ (); Version = " 6.1" ; OS = " Linux" ; ProblemCount = 0 }
106
88
@ { Target = $script :Ubuntu1804_6_1_profile ; Script = ' gci .' ; Commands = @ (); Version = " 6.1" ; OS = " Linux" ; ProblemCount = 0 }
107
89
@ { Target = $script :Ubuntu1804_6_1_profile ; Script = ' iex $expr | % { Transform $_ }' ; Commands = @ (); Version = " 6.1" ; OS = " Linux" ; ProblemCount = 0 }
90
+
91
+ # These entries fail on Ubuntu in Az DevOps only -- unable to reproduce locally
92
+ if (-not ($env: TF_BUILD -and $IsLinux ))
93
+ {
94
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' ConvertFrom-String $str' ; Commands = @ (" ConvertFrom-String" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
95
+ @ { Target = $script :Srv2019_6_1_profile ; Script = " Get-WmiObject -Class Win32_Process" ; Commands = @ (" Get-WmiObject" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
96
+ @ { Target = $script :Srv2019_6_1_profile ; Script = " Invoke-WmiMethod -Path win32_process -Name create -ArgumentList notepad.exe" ; Commands = @ (" Invoke-WmiMethod" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
97
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' $np | Remove-WmiObject' ; Commands = @ (" Remove-WmiObject" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
98
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Set-Clipboard -Value "This is a test string"' ; Commands = @ (" Set-Clipboard" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
99
+ @ { Target = $script :Srv2019_6_1_profile ; Script = " Set-WmiInstance -Class Win32_WMISetting -Argument @{LoggingLevel=2}" ; Commands = @ (" Set-WmiInstance" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
100
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Add-Computer -DomainName "Domain01" -Restart' ; Commands = @ (" Add-Computer" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
101
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Checkpoint-Computer -Description "Install MyApp"' ; Commands = @ (" Checkpoint-Computer" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
102
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Clear-EventLog "Windows PowerShell"' ; Commands = @ (" Clear-EventLog" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
103
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Clear-RecycleBin' ; Commands = @ (" Clear-RecycleBin" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
104
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Start-Transaction; New-Item MyCompany -UseTransaction; Complete-Transaction' ; Commands = @ (" Start-Transaction" , " Complete-Transaction" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 2 }
105
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Disable-ComputerRestore -Drive "C:\"' ; Commands = @ (" Disable-ComputerRestore" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
106
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Enable-ComputerRestore -Drive "C:\", "D:\"' ; Commands = @ (" Enable-ComputerRestore" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
107
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Get-ControlPanelItem -Name "*Program*", "*App*"' ; Commands = @ (" Get-ControlPanelItem" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
108
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Get-EventLog -Newest 5 -LogName "Application"' ; Commands = @ (" Get-EventLog" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
109
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' Get-HotFix -Description "Security*" -ComputerName "Server01", "Server02" -Cred "Server01\admin01"' ; Commands = @ (" Get-HotFix" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
110
+ @ { Target = $script :Srv2019_6_1_profile ; Script = ' $zip = New-WebServiceProxy -Uri "http://www.webservicex.net/uszip.asmx?WSDL"' ; Commands = @ (" New-WebServiceProxy" ); Version = " 6.1" ; OS = " Windows" ; ProblemCount = 1 }
111
+ }
108
112
)
109
113
110
114
$script :ParameterCompatibilityTestCases = @ (
@@ -182,7 +186,7 @@ Describe 'UseCompatibleCommands' {
182
186
$diagnostics = Invoke-ScriptAnalyzer - IncludeRule $script :RuleName - ScriptDefinition $Script - Settings $settings `
183
187
| Where-Object { -not $_.Parameter } # Filter out diagnostics about incompatible parameters
184
188
185
- $diagnostics.Count | Should - Be $ProblemCount
189
+ $diagnostics.Count | Should - Be $ProblemCount - Because ( $diagnostics .RuleName -join ' , ' )
186
190
187
191
for ($i = 0 ; $i -lt $diagnostics.Count ; $i ++ )
188
192
{
@@ -208,7 +212,7 @@ Describe 'UseCompatibleCommands' {
208
212
$diagnostics = Invoke-ScriptAnalyzer - IncludeRule $script :RuleName - ScriptDefinition $Script - Settings $settings `
209
213
| Where-Object { $_.Parameter } # Filter out diagnostics about incompatible parameters
210
214
211
- $diagnostics.Count | Should - Be $ProblemCount
215
+ $diagnostics.Count | Should - Be $ProblemCount - Because ( $diagnostics .RuleName -join ' , ' )
212
216
213
217
for ($i = 0 ; $i -lt $diagnostics.Count ; $i ++ )
214
218
{
@@ -240,7 +244,9 @@ Describe 'UseCompatibleCommands' {
240
244
$diagnostics = Invoke-ScriptAnalyzer - Path " $PSScriptRoot /CompatibilityRuleAssets/IncompatibleScript.ps1" - IncludeRule $script :RuleName - Settings $settings `
241
245
| Where-Object { $_.RuleName -eq $script :RuleName }
242
246
243
- $diagnostics.Count | Should - Be 14
247
+ $expectedNumber = if ($env: TF_BUILD -and $IsLinux ) { 13 } else { 14 }
248
+
249
+ $diagnostics.Count | Should - Be $expectedNumber - Because " Got diagnostics: $ ( $diagnostics.Message -join " , " ) "
244
250
245
251
$diagnosticGroups = Group-Object - InputObject $diagnostics - Property Command
246
252
@@ -320,7 +326,7 @@ Describe 'UseCompatibleCommands' {
320
326
}
321
327
322
328
$diagnostics = Invoke-ScriptAnalyzer - Path " $PSScriptRoot /../../" - IncludeRule $script :RuleName - Settings $settings
323
- $diagnostics.Count | Should - Be 0
329
+ $diagnostics.Count | Should - Be 0 - Because ( $diagnostics .RuleName -join ' , ' )
324
330
}
325
331
}
326
332
@@ -347,7 +353,7 @@ Describe 'UseCompatibleCommands' {
347
353
Invoke-MySpecialFunction
348
354
'
349
355
350
- $diagnostics.Count | Should - Be 2
356
+ $diagnostics.Count | Should - Be 2 - Because ( $diagnostics .RuleName -join ' , ' )
351
357
$diagnosticGroups = Group-Object - InputObject $diagnostics - Property Command
352
358
foreach ($group in $diagnosticGroups )
353
359
{
0 commit comments