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
Set-AzureADUser - setting null value for attribute #166
Comments
No, this is currently no supported
From: akemball [mailto:notifications@github.com]
Sent: Wednesday, November 15, 2017 5:04 AM
To: Azure/azure-docs-powershell-azuread <azure-docs-powershell-azuread@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: [Azure/azure-docs-powershell-azuread] Set-AzureADUser - setting null value for attribute (#166)
With the Set-MsolUser cmdlet, it is possible to set an attribute to "$null" to clear the value. E.g.
Set-Msoluser -userprincipalname -Mobile "$null" will clear whatever value is present for the Mobile phone.
But Set-AzureADUser -objectid -Mobile "$null" will generate an error.
set-AzureADUser : Error occurred while executing SetUser
Code: Request_BadRequest
Message: Invalid value specified for property 'mobile' of resource 'User'.
RequestId: e7c1d0eb-de00-4ab7-bf8b-5b7d9efbfa4e
DateTimeStamp: Wed, 15 Nov 2017 12:56:36 GMT
Details: PropertyName - mobile, PropertyErrorCode - InvalidLength
HttpStatusCode: BadRequest
HttpStatusDescription: Bad Request
HttpResponseStatus: Completed
At line:1 char:1
..........
Using AzureADPreview 2.0.0.137
Thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-docs-powershell-azuread%2Fissues%2F166&data=02%7C01%7Crodejo%40microsoft.com%7Cb887a6f5228a47ff546e08d52c2968e9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636463478721254993&sdata=WHqxUTS%2BZhlTl2Fh34iJg5KnbSOn8Xzn9UV0RgIymoU%3D&reserved=0>, or mute the thread<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAK3wONMk6CkekShlQgdzLA32tATLOE44ks5s2uFTgaJpZM4Qe5LI&data=02%7C01%7Crodejo%40microsoft.com%7Cb887a6f5228a47ff546e08d52c2968e9%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636463478721254993&sdata=8YD%2BvdMs%2B5QIT4QfBAV%2FbgWHJqsrNQIWpIPE8Ecx6OA%3D&reserved=0>.
|
So... how do I empty those properties? |
Are you going to fix this defect? Currently do we need to "remove" values by setting the value to " " which is not perfect |
Hi, can we have an update of this issue please ? Thanks, |
same today with 2.0.1.16 Name : azuread
Path : C:\Program Files\WindowsPowerShell\Modules\azuread\2.0.1.16\Microsoft.Open.AzureAD16.Graph.PowerShell.dll
Description : Azure Active Directory V2 General Availability Module.
This is the General Availability release of Azure Active Directory V2 PowerShell Module.
For detailed information on how to install and run this module from the PowerShell Gallery including prerequisites, please refer to
https://msdn.microsoft.com/powershell/gallery/readme
ModuleType : Binary
Version : 2.0.1.16 |
We're doing this quite often on a number of customers users moving from onprem to Cloud only. We too use " " instead of NULL which still works. |
Instead of this: Use this: |
Doesn't work for me. It doesn't give any error message prompt, but it doesn't neither clean the mobile field. I tried to wait a few minutes if it was caused by redundancy, but it didn't change after waiting 30 minutes. |
@Terrenus try following, I had similar requirements. Set-AzureADUser -ObjectId $line.UserPrincipleName -City " " Hope it helps. |
@dougraheem It works, kinda... Unluckily we have a script from the background that recognise " " as a space, and not as a null or empty field.. Which is what I need. I guess I need to wait for an update or something similar from it. Thanks for the hint :-) |
any update since 2017? |
Any news with this issue? I accidently set the "ImmutableId" field to a value and cannot use the "workaround" and set a white space in this field, because it has to be a unique value for alle AD identites in the tenant... |
Why is this still not possible? |
after 2 years from the first request the BUG still exists. |
Any update on this? I am too stuck with this and would like to set filed value to null rather than " ". |
It's been almost 3 years and still not a proper way of clearing the values of AAD user fields? |
Still not resolved. Shame you, guys. |
Encountered this bug today. Is there any ETA on when this will be resolved so we can use AzureAD cmdlets to clear (nullify) a value ? Currently I need to make a lot of logic in my scripts to use both cmdlets but in some cases also use Graph API directly. 📢: @RobdeJong |
Also encountered this bug today. Any ETA on this? |
It's not a required attribute, why can't I unset it?
|
I was able to find the answer to this one after some troubleshooting to make -OtherMails null. I ran into the same issues as above using $null, "$null", and " ", but I was able to modify the value and set it to null by setting the attribute to the following... Set-AzureAdUser -ObjectID $id -OtherMails @{} |
I'm facing basically the same issue as everyone else in this thread but with the FacsimileTelephoneNumber. |
Why has this issue been closed? |
No idea why this was closed - though the same user appeared to close several issues at the same time. |
@billmath Why has this issue been closed? |
@billmath or @RobdeJong: Can we get some insight on why this long-standing issue was closed without a resolution despite previous comments indicating that a future release would resolve the matter? I am attempting to transition all workflows to AzureAD commands instead of MSOL commands, but the inability to set an AAD attribute to a null value is a significant hurdle. |
Hi everyone, just came across this issue myself, and found an approach that might help others around this issue. (Of course, this should only be useful to those who have a compelling reason to keep using the AzureAD module, instead of the Microsoft Graph PowerShell module.) This workaround makes use of the fact that the $properties = [Collections.Generic.Dictionary[[String],[String]]]::new()
$properties.Add("telephoneNumber", [NullString]::Value)
Set-AzureADUser -ObjectId "user@example.com" -ExtensionProperty $properties @5465645 I know this is a bit late to be commenting, but if you're doing a migration, you should really look to change to Microsoft Graph PowerShell, instead of Azure AD PowerShell. |
Hi @psignoret, interesting workaround. It would still be nice to get this fixed properly. Regarding your recommendation to using the Microsoft Graph module (Microsoft Graph PowerShell SDK): I don't think this is a proper replacement for the AzureAD module (Azure Active Directory PowerShell for Graph). At least not for the majority of users or use-cases. The AzureAD module however is specifically designed to help with or automate administrative tasks. The Manage Microsoft 365 with PowerShell documentation also clearly states the AzureAD module is the "recommended" way (over the older MSOnline module (Microsoft Azure Active Directory Module for Windows PowerShell)) to connect to Microsoft 365 and administer user accouns, groups and licenses. It doesn't even mention the Graph SDK once - which probably has a reason. Obviously the Graph module definitely has it's use-cases (i.e. for developers creating applications that integrate with M365) but I think the larger part of users (affected by this issue at least) will be admins that just want to automate part of their user management and don't want to get into understanding and working with an API. |
Same issue here. Pretty sad that this has been closed. |
remove-azureaduserextension does the trick |
@RobdeJong This issue clearly isn't fixed. Please re-open. |
@ChrisAtMAF @stromvirvel
|
As of July 2022, trying to set a field to $null still does not do anything. No error, but doesn't change the content of the field either. Attempting to set the field to "" still throws an error as well. |
I tried a few things for setting a blank ImmutableId value and finally got this one to work. It also avoids the "Set-MsolUser : Uniqueness violation. Property: SourceAnchor." error you would receive if trying to use a space or similar character more than once. $var = "" |
I tried this one and it worked for me: |
@polaran FYI that's setting it to a single space, not to $null We should all be using Graph now (see microsoftgraph/msgraph-sdk-powershell#833) and the old module won't be updated, I suspect. But if people insist, the best options I have found are:
(NB despite the name, it clears the attribute value for a single user, not for all users - verified at https://stackoverflow.com/questions/61780722/remove-azureaduserextension-actual-result) or
|
While this doesn't excuse the lack of progress on this, This is a decent workaround (this is an example of blanking out the "OtherMails" attribute):
|
With the Set-MsolUser cmdlet, it is possible to set an attribute to "$null" to clear the value. E.g.
Set-Msoluser -userprincipalname -Mobile "$null" will clear whatever value is present for the Mobile phone.
But Set-AzureADUser -objectid -Mobile "$null" will generate an error.
set-AzureADUser : Error occurred while executing SetUser
Code: Request_BadRequest
Message: Invalid value specified for property 'mobile' of resource 'User'.
RequestId: e7c1d0eb-de00-4ab7-bf8b-5b7d9efbfa4e
DateTimeStamp: Wed, 15 Nov 2017 12:56:36 GMT
Details: PropertyName - mobile, PropertyErrorCode - InvalidLength
HttpStatusCode: BadRequest
HttpStatusDescription: Bad Request
HttpResponseStatus: Completed
At line:1 char:1
..........
Using AzureADPreview 2.0.0.137
Thanks
The text was updated successfully, but these errors were encountered: