microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.49k stars 452 forks source link

SPOApp: System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression #3945

Open skghq opened 8 months ago

skghq commented 8 months ago

Description of the issue

Command: Export-M365DSCConfiguration -Components @("SPOApp") -Credential $Credential -Path $FilePath -FileName $FileName

Stack Trace: [2023/11/24 04:34:21] {InvalidOperation} System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression. at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) "Error during Export:" at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\DSCResources\MSFT_SPOApp\MSFT_SPOApp.psm1: line 395 at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCReverse.psm1: line 615 at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCUtil.psm1: line 1320 at , C:\Scripts\<<>>\Office365_Backup_Debug_Permissions.ps1: line 59 <<redacted>>>@<<<redacted>>.onmicrosoft.com TenantId: <<>>.onmicrosoft.com

PS Output: Transcript started, output file is C:\temp\<<>>\Debug-Permissions\log\SPOApp.txt Exporting Microsoft 365 configuration for Components: SPOApp There is a newer version of the 'Microsoft365DSC' module available on the gallery. To update the module and it's dependencies, run the following command: Update-M365DSCModule

Authentication methods specified:

Connecting to {PnP}...✅ [1/1] Extracting [SPOApp] using {Credentials}...

|---[1/17] fp-insights.sppkg✅
|---[2/17] mgt-spfx-vv3.sppkg✅
|---[3/17] sba-loan-tickets.sppkg✅
|---[4/17] fp-news-insights.sppkg✅
|---[5/17] practice-group-people.sppkg✅
|---[6/17] state-survey-map.sppkg✅
|---[7/17] directory.sppkg✅
|---[8/17] fp-list.sppkg✅
|---[9/17] state-survey-banner.sppkg✅
|---[10/17] hr-career-center.sppkg✅
|---[11/17] fpdirectory.sppkg✅
|---[12/17] extranet-contacts.sppkg✅
|---[13/17] google-analytics.sppkg✅
|---[14/17] subscription-content.sppkg✅
|---[15/17] kmlrc.sppkg✅
|---[16/17] graphdelvetest.sppkg✅
|---[17/17] ❌

Error Log created at {file://C:/temp/<<>>/Debug-Permissions/cwd/1396-M365DSC-ErrorLog.log} ⌛ Export took {13 seconds} Join-Path : Cannot find path 'C:\Users\<<>>\AppData\Local\Temp\fp-insights.sppkg' because it does not exist. At C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCReverse.psm1:780 char:33

Partial Export file was saved at: C:\Users\<<>>\AppData\Local\Temp\faf0922c-134e-4ca9-b82f-ddba7682adff.partial.ps1 Copy-Item : Cannot bind argument to parameter 'Path' because it is null. At C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCReverse.psm1:782 char:37

PS C:\temp\<<>>\Debug-Permissions\cwd>

Microsoft 365 DSC Version

1.23.1115.1

Which workloads are affected

SharePoint Online

The DSC configuration

Export-M365DSCConfiguration -Components @("SPOApp") -Credential $Credential -Path $FilePath -FileName $FileName

Verbose logs showing the problem

[2023/11/24 04:34:21]
{InvalidOperation}
System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
"Error during Export:"
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\DSCResources\MSFT_SPOApp\MSFT_SPOApp.psm1: line 395
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCReverse.psm1: line 615
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCUtil.psm1: line 1320
at <ScriptBlock>, C:\Scripts\<<<redacted>>>\Office365_Backup_Debug_Permissions.ps1: line 59
<<<redacted>>>@<<<redacted>>>.onmicrosoft.com
TenantId: <<<redacted>>>.onmicrosoft.com

Transcript started, output file is C:\temp\<<<redacted>>>\Debug-Permissions\log\SPOApp.txt
Exporting Microsoft 365 configuration for Components: SPOApp
There is a newer version of the 'Microsoft365DSC' module available on the gallery.
To update the module and it's dependencies, run the following command:
Update-M365DSCModule

Authentication methods specified:
- Credentials

Connecting to {PnP}...✅
[1/1] Extracting [SPOApp] using {Credentials}...

    |---[1/17] fp-insights.sppkg✅
    |---[2/17] mgt-spfx-vv3.sppkg✅
    |---[3/17] sba-loan-tickets.sppkg✅
    |---[4/17] fp-news-insights.sppkg✅
    |---[5/17] practice-group-people.sppkg✅
    |---[6/17] state-survey-map.sppkg✅
    |---[7/17] directory.sppkg✅
    |---[8/17] fp-list.sppkg✅
    |---[9/17] state-survey-banner.sppkg✅
    |---[10/17] hr-career-center.sppkg✅
    |---[11/17] fpdirectory.sppkg✅
    |---[12/17] extranet-contacts.sppkg✅
    |---[13/17] google-analytics.sppkg✅
    |---[14/17] subscription-content.sppkg✅
    |---[15/17] kmlrc.sppkg✅
    |---[16/17] graphdelvetest.sppkg✅
    |---[17/17] ❌
 Error Log created at {file://C:/temp/<<<redacted>>>/Debug-Permissions/cwd/1396-M365DSC-ErrorLog.log}
⌛ Export took {13 seconds}
Join-Path : Cannot find path 'C:\Users\<<<redacted>>>\AppData\Local\Temp\fp-insights.sppkg' because it does not exist.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCReverse.psm1:780 char:33
+ ...             $filePath = Join-Path $env:Temp $fileToCopy.Name -Resolve
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\<<<redacted>>>...-insights.sppkg:String) [Join-Path], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Partial Export file was saved at: C:\Users\<<<redacted>>>\AppData\Local\Temp\faf0922c-134e-4ca9-b82f-ddba7682adff.partial.ps1
Copy-Item : Cannot bind argument to parameter 'Path' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.23.1115.1\modules\M365DSCReverse.psm1:782 char:37
+                     Copy-Item -Path $filePath -Destination $destPath
+                                     ~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Copy-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CopyItemCommand

PS C:\temp\<<<redacted>>>\Debug-Permissions\cwd>

Environment Information + PowerShell Version

OsName               : Microsoft Windows Server 2019 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Key   : PSVersion
Value : 5.1.17763.4974
Name  : PSVersion

Key   : PSEdition
Value : Desktop
Name  : PSEdition

Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions

Key   : BuildVersion
Value : 10.0.17763.4974
Name  : BuildVersion

Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion

Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion

Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion
skghq commented 8 months ago

I have upgraded to 1.23.1122.1. This is still an issue.