Invoke-Formatter not working correctly for small scriptblocks
See original GitHub issueBefore submitting a bug report:
- Make sure you are able to repro it on the latest released version
- Perform a quick search for existing issues to check if this bug has already been reported
Steps to reproduce
Invoke-Formatter -ScriptDefinition '{ $_.Status.IsCompleted -eq $true }'
Invoke-Formatter -ScriptDefinition '{ $null -ne $_.Status }'
Expected behavior
No error.
Actual behavior
Error
Invoke-Formatter : Object reference not set to an instance of an object.
At line:1 char:1
+ Invoke-Formatter -ScriptDefinition '{ $null -ne $_.Status }; '
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-Formatter], NullReferenceException
+ FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeFormatterCommand
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0
1.19.1
1.19.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Using Invoke-Command with Variables in ScriptBlock
Invoke-Command : Cannot validate argument on parameter 'ScriptBlock'. The argument is null. Provide a valid value for the argument, and then try ...
Read more >about Script Blocks - PowerShell
In the PowerShell programming language, a script block is a collection of statements or expressions that can be used as a single unit....
Read more >The PowerShell Best Practices and Style Guide
Like English spelling and grammar rules, PowerShell programming best practices and style rules nearly always have exceptions, but we are documenting a ...
Read more >Untitled
Script commands names Classic SysAdmin: Writing a Simple Bash Script WebbCurrently, the last echo command does not print itself, only its output is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It doesn’t matter