Skip to content

[BUG] Get-PnPServiceHealthIssue returns a null reference error when trying to get all issues #3284

@stvpwrs

Description

@stvpwrs

Reporting an Issue or Missing Feature

When calling Get-PnPServiceHealthIssue without an -Identity argument to retrieve all service issues returns a null reference error.

Expected behavior

Calling Get-PnPServiceHealthIssue with no -Identity argument should return all service issues for a tenant.

Actual behavior

Calling Get-PnPServiceHealthIssue with no -Identity argument returns:

ErrorRecord                 : Object reference not set to an instance of an object.
WasThrownFromThrowStatement : False
TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)
Message                     : Object reference not set to an instance of an object.
Data                        : {[System.Management.Automation.Interpreter.InterpretedFrameInfo, System.Management.Automation.Interpreter.InterpretedFrameInfo[]]}
InnerException              : System.Management.Automation.PSInvalidOperationException: Object reference not set to an instance of an object.
                                 at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 101
                                 at System.Management.Automation.CommandProcessor.ProcessRecord()
HelpLink                    : 
Source                      : System.Management.Automation
HResult                     : -2146233087
StackTrace                  :    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                                 at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
                                 at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
                                 at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, PSInvocationSettings settings)
                                 at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear[TResult](PowerShell pwsh, PSInvocationSettings invocationSettings) in
                              D:\a\_work\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 82
                                 at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in
                              D:\a\_work\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 194

Steps to reproduce behavior

$forPnPPowerShell = @{
    Force           = $true
    Name            = 'PnP.PowerShell'
    RequiredVersion = '2.2.0'
}
Import-Module @forPnPPowerShell

$withAppPermissions = @{
    ClientID         = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
    ReturnConnection = $true
    Tenant           = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
    Thumbprint       = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    Url              = 'https://<tenant>-admin.sharepoint.com'
}
$connection = Connect-PnPOnline @withAppPermissions

$issues = Get-PnPServiceHealthIssue -Connection $connection

# This will work
# $issues = @(Get-PnPServiceHealthIssue -Connection $connection -Identity 'TM649896')

$issues.Count

What is the version of the Cmdlet module you are running?

Directory: C:\Users\<User>\OneDrive - <Tenant>\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   2.2.0                 PnP.PowerShell                      Desk      {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder…}
Manifest   2.1.1                 PnP.PowerShell                      Desk      {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder…}

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   1.12.0                PnP.PowerShell                      Core,Desk {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder…}
Manifest   1.11.0                PnP.PowerShell                      Core,Desk {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder…}
Manifest   1.10.0                PnP.PowerShell                      Core,Desk {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Copy-PnPFolder, Export-PnPClientSidePage…}

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions