Skip to content

Update-MgUser fails to remove OfficeLocation value #2087

@VonGlitch

Description

@VonGlitch

I am using Update-MgUser to update OfficeLocation values and sometimes when a person is between locations, or not yet assigned a location, we want the location field to be empty. But if I pass either an empty string or $nul the cmdlet fails. How do I remove the OfficeLocation value. We don't want to populate it with garbage!

PS C:\admin\365\SharePoint> Update-MgUser -UserId $User.Id -OfficeLocation ""
Update-MgUser : Invalid value specified for property 'officeLocation' of resource 'User'.
At line:1 char:1
+ Update-MgUser -UserId $User.Id -OfficeLocation ""
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ({ UserId = 7ce2...oftGraphUser1 }:<>f__AnonymousType63`2) [Update-MgUser_UpdateExpanded], RestException`1
    + FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.UpdateMgUser_UpdateExpanded

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions