Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-MgGroupToLifecyclePolicy throws an error, but adds group to the Expiration policy #1304

Closed
Adminiuga opened this issue Jun 3, 2022 · 2 comments

Comments

@Adminiuga
Copy link

Running Add-MgGroupToLifecyclePolicy throws Add-MgGroupToLifecyclePolicy : Object reference not set to an instance of an object. but still adds group to the lifecycle policy. Seems to have issues parsing the response correctly.

Here's the debug log, as you can see, the request has completed successfuly, but cmdlet threw an exception

PS C:\Users\some_user> Add-MgGroupToLifecyclePolicy -GroupLifecyclePolicyId ca1ad70c-1368-42d3-a5e8-d6cbb67a4bfc -GroupId 1a28df02-8e99-4cd6-94df-eed334be76a5 -Debug
DEBUG: [CmdletBeginProcessing]: - Add-MgGroupToLifecyclePolicy begin processing with parameterSet 'AddExpanded'.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): A
DEBUG: [Authentication]: - AuthType: 'Delegated', AuthProviderType: 'InteractiveAuthenticationProvider', ContextScope:
'CurrentUser', AppName: 'Microsoft Graph PowerShell'.
DEBUG: [Authentication]: - Scopes: [Group.ReadWrite.All, openid, profile, Team.Create, TeamMember.ReadWrite.All,
TeamSettings.ReadWrite.All, User.ReadBasic.All, email, Directory.ReadWrite.All].

Confirm
Are you sure you want to perform this action?
Performing the operation "Add-MgGroupToLifecyclePolicy_AddExpanded" on target "Call remote
'GroupLifecyclePoliciesAddGroup' operation".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://graph.microsoft.com/v1.0/groupLifecyclePolicies/ca1ad70c-1368-42d3-a5e8-d6cbb67a4bfc/microsoft.graph.addGroup

Headers:


Body:
{
  "groupId": "1a28df02-8e99-4cd6-94df-eed334be76a5"
}

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Transfer-Encoding             : chunked
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : d5ead9d8-a5dd-4720-a7eb-9a8c5f5864df
client-request-id             : d5ead9d8-a5dd-4720-a7eb-9a8c5f5864df
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"North Central
US","Slice":"E","Ring":"3","ScaleUnit":"004","RoleInstance":"CH01EPF00003EB5"}}
OData-Version                 : 4.0
Cache-Control                 : no-cache
Date                          : Fri, 03 Jun 2022 16:31:40 GMT
Location                      : https://graph.microsoft.com/

Body:
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Edm.Boolean",
  "value": true
}

DEBUG: [CmdletException]: Received exception with message 'NullReferenceException - Object reference not set to an
instance of an object. :    at
Microsoft.Graph.PowerShell.Cmdlets.AddMgGroupToLifecyclePolicy_AddExpanded.<onOk>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.PowerShell.Groups.<GroupLifecyclePoliciesAddGroup_Call>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Graph.PowerShell.Groups.<GroupLifecyclePoliciesAddGroup_Call>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.PowerShell.Groups.<GroupLifecyclePoliciesAddGroup>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Graph.PowerShell.Cmdlets.AddMgGroupToLifecyclePolicy_AddExpanded.<ProcessRecordAsync>d__61.MoveNext()'

Confirm
Object reference not set to an instance of an object.
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): A
Add-MgGroupToLifecyclePolicy : Object reference not set to an instance of an object.
At line:1 char:1
+ Add-MgGroupToLifecyclePolicy -GroupLifecyclePolicyId ca1ad70c-1368-42 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-MgGroupToLifecyclePolicy_AddExpanded], NullReferenceException
    + FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.AddMgGroupToLifecyclePolicy_AddExpanded

DEBUG: [CmdletEndProcessing]: - Add-MgGroupToLifecyclePolicy end processing.
@ghost ghost added the ToTriage label Jun 3, 2022
@Adminiuga
Copy link
Author

this is with 1.9.6 version and 5.1 PowerShell

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.9.6      Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G...
Script     1.9.6      Microsoft.Graph.Groups              {Add-MgGroupFavorite, Add-MgGroupToLifecyclePolicy, Confir...
Script     1.9.6      Microsoft.Graph.Teams               {Add-MgChatMember, Add-MgTeamChannelMember, Add-MgTeamMemb...
Script     1.9.6      Microsoft.Graph.Users               {Get-MgUser, Get-MgUserCreatedObject, Get-MgUserCreatedObj...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...

PowerShell

Name             : ConsoleHost
Version          : 5.1.19041.1682
InstanceId       : ea76cfb2-9a7e-497e-a12b-c258d5ae7b7f
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

@peombwa
Copy link
Member

peombwa commented Jun 13, 2022

Thanks for bringing this to our attention. The issue has already been fixed and will be available as part of the next release #1265.

Closing as duplicate of #1241

@peombwa peombwa closed this as completed Jun 13, 2022
@ghost ghost removed the ToTriage label Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants