Skip to content

A Severity setting that is not a hashtable ends Test-IntuneScript with a strict-mode error #105

Backlog

Description

@fadwen-ai

A settings table whose Severity key is not a hashtable ends Test-IntuneScript with a strict-mode error, not with SettingsInvalid.

Reproduction

On main (3b82ba2), under PowerShell 7.6 and Windows PowerShell 5.1:

Test-IntuneScript -Path .\Detect.ps1 -Settings @{ Severity = 'Error' } -ErrorAction Stop

The command ends with PropertyNotFoundStrict,Test-IntuneScript and the message The property 'Keys' cannot be found on this object. Verify that the property exists. The same happens for an IntuneScriptLab.settings.psd1 file that sets Severity = 'Error'.

Expected

SettingsInvalid,Test-IntuneScript, with a message that names the source (-Settings or the file) and says that Severity must be a hashtable of rule names, as every other value outside its set does. The help of the settings says a wrong value ends the command with SettingsInvalid.

Cause

The settings conversion reads $severityTable.Keys without first checking that the value is a dictionary. Under the module's Set-StrictMode -Version Latest, reading Keys from a string is a terminating error. The code is ConvertTo-IslSettingsObject on the #65 branches and the nested settings conversion of Get-IslSetting on main.

This is not a finding against ai-powershell-standards 2.0.0. It was found in a review of #100.

Discovered and written up with Claude Code.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions