@@ -15,6 +15,9 @@ $script:Win10_5_profile = 'win-48_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.4
15
15
$script :Win10_6_1_profile = ' win-48_x64_10.0.17763.0_6.1.3_x64_4.0.30319.42000_core'
16
16
$script :Ubuntu1804_6_1_profile = ' ubuntu_x64_18.04_6.1.3_x64_4.0.30319.42000_core'
17
17
18
+ $script :AzF_profile = Resolve-Path " $PSScriptRoot /../../PSCompatibilityCollector/optional_profiles/azurefunctions.json"
19
+ $script :AzA_profile = Resolve-Path " $PSScriptRoot /../../PSCompatibilityCollector/optional_profiles/azureautomation.json"
20
+
18
21
$script :CompatibilityTestCases = @ (
19
22
@ { Target = $script :Srv2012_3_profile ; Script = ' Write-Information "Information"' ; Commands = @ (" Write-Information" ); Version = " 3.0" ; OS = " Windows" ; ProblemCount = 1 }
20
23
@ { Target = $script :Srv2012_3_profile ; Script = ' "Hello World" | ConvertFrom-String | Get-Member' ; Commands = @ (" ConvertFrom-String" ); Version = " 3.0" ; OS = " Windows" ; ProblemCount = 1 }
@@ -299,4 +302,53 @@ Describe 'UseCompatibleCommands' {
299
302
$diagnostics.Count | Should - Be 0
300
303
}
301
304
}
305
+
306
+ Context ' Targeting new-form Az profiles alongside older profiles' {
307
+ BeforeAll {
308
+ $settings = @ {
309
+ Rules = @ {
310
+ $script :RuleName = @ {
311
+ $script :TargetProfileConfigKey = @ (
312
+ $script :AzF_profile
313
+ $script :AzA_profile
314
+ $script :Win10_5_profile
315
+ )
316
+ }
317
+ }
318
+ }
319
+ }
320
+
321
+ It " Finds AzF problems with a script" {
322
+ $diagnostics = Invoke-ScriptAnalyzer - IncludeRule $script :RuleName - Settings $settings - ScriptDefinition '
323
+ Get-WmiObject Win32_Process
324
+ New-SelfSignedCertificate
325
+ Invoke-MySpecialFunction
326
+ '
327
+
328
+ $diagnostics.Count | Should - Be 2
329
+ $diagnosticGroups = Group-Object $diagnostics - Property Command
330
+ foreach ($group in $diagnosticGroups )
331
+ {
332
+ switch ($group.Name )
333
+ {
334
+ ' Get-WmiObject'
335
+ {
336
+ $group.Count | Should - Be 1
337
+ $group.Group [0 ].Command | Should - BeExactly ' Get-WmiObject'
338
+ }
339
+
340
+ ' New-SelfSignedCertificate'
341
+ {
342
+ $group.Count | Should - Be 1
343
+ $group.Group [0 ].Command | Should - BeExactly ' New-SelfSignedCertificate'
344
+ }
345
+
346
+ default
347
+ {
348
+ $group | Should - Be $null
349
+ }
350
+ }
351
+ }
352
+ }
353
+ }
302
354
}
0 commit comments