This is going to be a crappy bug report, sorry, but its such an intermittent issue that I've never been able to isolate and thought someone with project insights might know what's going on from the $_.Exception.ToString() output.
[2026-06-23T15:34:43.2037194+10:00] Performing build function [Confirm-ADTScriptIntegrity], please wait...
[2026-06-23T15:34:43.2037194+10:00] Confirming all PowerShell files have no code violations.
[2026-06-23T15:34:44.0050428+10:00] The call to [Invoke-ScriptAnalyzer] threw a NullReferenceException type.
[2026-06-23T15:34:44.0090737+10:00] System.NullReferenceException: Object reference not set to an instance of an object.
at System.Management.Automation.CommandInfo.ResolveParameter(String name)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetExportedFunction(Ast ast)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidReservedCharInCmdlet.<AnalyzeScript>d__0.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass85_1.<AnalyzeSyntaxTree>b__2()
[2026-06-23T15:34:44.0111185+10:00] at Confirm-ADTScriptIntegrity, C:\Repos\PSAppDeployToolkit\src\PSAppDeployToolkit.Build\Private\Confirm-ADTScriptIntegrity.ps1: line 15
at Invoke-ADTModuleBuild, C:\Repos\PSAppDeployToolkit\src\PSAppDeployToolkit.Build\Public\Invoke-ADTModuleBuild.ps1: line 42
at <ScriptBlock>, C:\Repos\PSAppDeployToolkit\build.ps1: line 12
[2026-06-23T15:34:44.0131970+10:00] Object reference not set to an instance of an object.
[2026-06-23T15:34:44.0152115+10:00] Failed to complete build function [Confirm-ADTScriptIntegrity].
-------------------------------------------------------------------------------
Module build failed to complete. Review the thrown ErrorRecord and try again.
End of log.
C:\Repos\PSAppDeployToolkit\build.ps1 : Object reference not set to an instance of an object.
+ CategoryInfo : InvalidOperation: (:) [build.ps1], NullReferenceException
+ FullyQualifiedErrorId : RULE_ERROR,build.ps1
C:\Windows\System32>
Steps to reproduce
[Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord[]]$result = Invoke-ScriptAnalyzer -Path $Script:ModuleConstants.Paths.SourceRoot -ExcludeRule PSUseShouldProcessForStateChangingFunctions, PSUseSingularNouns -Recurse -Fix:(!(Test-ADTBuildingWithinPipeline)) -Verbose:$false | & { process { if ((!$_.RuleName.Equals('PSUseToExportFieldsInManifest') -or !$_.ScriptName.Equals('PSAppDeployToolkit.Extensions.psd1')) -and (!$_.RuleName.Equals('PSAvoidUsingWriteHost') -or ($_.ScriptPath -notmatch 'PSAppDeployToolkit\.Build'))) { return $_ } } }
Expected behavior
That the NullReferenceException does not occur.
Actual behavior
A NullReferenceException occurs.
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
> $PSVersionTable
PS C:\Windows\System32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.26100.8655
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.8655
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
PS C:\Windows\System32> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.25.0
1.24.0
1.23.0
1.22.0
1.23.0
PS C:\Windows\System32>
This is going to be a crappy bug report, sorry, but its such an intermittent issue that I've never been able to isolate and thought someone with project insights might know what's going on from the
$_.Exception.ToString()output.Steps to reproduce
Expected behavior
That the
NullReferenceExceptiondoes not occur.Actual behavior
A
NullReferenceExceptionoccurs.If an unexpected error was thrown then please report the full error details using e.g.
$error[0] | Select-Object *Environment data