Skip to content

Update-MgOrganizationSettingItemInsight fails with null reference error #337

Closed

Description

Attempting to run the following results in an error:
Update-MgOrganizationSettingItemInsight -OrganizationId "" -DisabledForGroup ""

Error returned is:
Update-MgOrganizationSettingItemInsight_UpdateViaIdentityExpanded: Object reference not set to an instance of an object.

Microsoft.Graph.Identity.Organization module is at version 0.9.1. Using Fiddler to monitor requests this is failing locally (appears to be an issue with hashtable conversion based on below) before it can even query Microsoft Graph. Performing the same request in Graph Explorer with a PATCH is successful. Let me know if need any additional logs or repro steps.

Full error output::

Exception :
Type : System.NullReferenceException
TargetSite :
Name : HashTableToDictionary
DeclaringType : Microsoft.Graph.PowerShell.Runtime.DictionaryExtensions,
Microsoft.Graph.Identity.Organization.private, Version=0.9.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : Microsoft.Graph.Identity.Organization.private.dll
StackTrace :
at Microsoft.Graph.PowerShell.Runtime.DictionaryExtensions.HashTableToDictionary[V](Hashtable hashtable,
IDictionary`2 dictionary)
at Microsoft.Graph.PowerShell.Cmdlets.UpdateMgOrganizationSettingItemInsight_UpdateExpanded.ProcessRecordAsync()
Message : Object reference not set to an instance of an object.
Source : Microsoft.Graph.Identity.Organization.private
HResult : -2147467261
CategoryInfo : NotSpecified: (:) [Update-MgOrganizati…ight_UpdateExpanded], NullReferenceException
FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.UpdateMgOrganizationSettingItemInsight_UpdateExpanded
InvocationInfo :
MyCommand : Update-MgOrganizationSettingItemInsight_UpdateExpanded
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 10
Line : Update-MgOrganizationSettingItemInsight -OrganizationId "5774927f-fdea-49cc-ba30-a7216215f9cd"
-DisabledForGroup "45bca0af-7dbd-4a50-9637-cef4fadebeb1" -IsEnabledInOrganization
PositionMessage : At line:1 char:1
+ Update-MgOrganizationSettingItemInsight -OrganizationId "5774927f-fde …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Update-MgOrganizationSettingItemInsight
CommandOrigin : Internal
ScriptStackTrace : at Update-MgOrganizationSettingItemInsight, C:\Users\brianja\Documents\PowerShell\Modu
les\Microsoft.Graph.Identity.Organization\0.9.1\exports\v1.0-beta\ProxyCmdletDefinitions.ps1: line 5796
at , : line 1
PipelineIterationInfo :

Activity

  1. peombwa commented on Aug 14, 2020

    @peombwa
    Member

    Brian T. Jackett (@BrianTJackett) Thanks for reporting this client. This is a bug cause by the code generator, AutoREST should always default AdditionalProperties parameter an empty HashTable.

    A temporary workaround is to call Update-MgOrganizationSettingItemInsight with a -BodyParameter parameter like this:

    Update-MgOrganizationSettingItemInsight -OrganizationId $org.Id -BodyParameter @{"DisabledForGroup" = ""}

    , or pass an empty -additionalProperties parameters like this

    Update-MgOrganizationSettingItemInsight -OrganizationId $org.Id -DisabledForGroup "" -AdditionalProperties @{}}
  2. BrianTJackett commented on Aug 15, 2020

    @BrianTJackett
    ContributorAuthor

    Thanks for the confirmation. I had a feeling it was something wrong with one of the defaults for a hashtable. Will use the workarounds suggested.

  3. peombwa commented on Oct 29, 2020

    @peombwa
    Member

    Closing since this has been fixed in v1.1.0 . Use Update-Module Microsoft.Graph to update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions