Closed
Description
I've got a script with some compatibility bugs in it. I can run the compatibility rules on it like this:
$settings = @{
Rules = @{
PSUseCompatibleCommands = @{
Enable = $true
TargetProfiles = @(
'win-8_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework' # Server 2019 - PS 5.1 (the platform it already runs on)
'win-8_x64_6.2.9200.0_3.0_x64_4.0.30319.42000_framework' # Server 2012 - PS 3
'ubuntu_x64_18.04_6.1.3_x64_4.0.30319.42000_core' # Ubuntu 18.04 - PS 6.1
)
}
PSUseCompatibleTypes = @{
Enable = $true
TargetProfiles = @(
'win-8_x64_10.0.17763.0_5.1.17763.316_x64_4.0.30319.42000_framework'
'win-8_x64_6.2.9200.0_3.0_x64_4.0.30319.42000_framework'
'ubuntu_x64_18.04_6.1.3_x64_4.0.30319.42000_core'
)
}
PSUseCompatibleSyntax = @{
Enable = $true
TargetVersions = @('3.0', '5.1', '6.1')
}
}
}
Invoke-ScriptAnalyzer -Settings $settings -Path ./script.ps1
And get:
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseCompatibleCommands Warning blogBad.ps 9 The parameter 'FullyQualifiedName' is not available for
1 command 'Import-Module' by default in PowerShell version
'3.0' on platform 'Microsoft Windows Server 2012 Datacenter'
PSUseCompatibleCommands Warning blogBad.ps 13 The parameter 'Depth' is not available for command
1 'Get-ChildItem' by default in PowerShell version '3.0' on
platform 'Microsoft Windows Server 2012 Datacenter'
PSUseCompatibleCommands Warning blogBad.ps 22 The command 'Get-AuthenticodeSignature' is not available by
1 default in PowerShell version '6.1.3' on platform 'Ubuntu
18.04.2 LTS'
PSUseCompatibleCommands Warning blogBad.ps 30 The command 'Compress-Archive' is not available by default
1 in PowerShell version '3.0' on platform 'Microsoft Windows
Server 2012 Datacenter'
PSUseCompatibleTypes Warning blogBad.ps 12 The method 'Get' is not available on type
1 'System.Management.Automation.WildcardPattern' by default
in PowerShell version '3.0' on platform 'Microsoft Windows
Server 2012 Datacenter'
PSUseCompatibleSyntax Warning blogBad.ps 11 The constructor syntax '[System.Collections.Generic.List[Sys
1 tem.Management.Automation.Signature]]::new()' is not
available by default in PowerShell versions 3,4
But when I put the settings in a psd1 file and run the same with:
Invoke-ScriptAnalyzer -Settings ./mysettings.psd1 -Path ./script.ps1
I get no output.
Is this expected behaviour -- is there something I need to add to a settings file to make this work? Or is this something I should be fixing in the engine?
Metadata
Metadata
Assignees
Labels
No labels