New-AzRoleAssignment error: string format is incorrect
This script used to work with module az.resources 2.1.0: $qa = get-azadgroup -displayname qa; New-AzRoleAssignment -ObjectId $qa.Id -RoleDefinitionName Owner -ResourceGroupName RG-QA
Started getting this error on one computer but not the other. When I checked the modules version for az.resources, I had 2.1.0, 2.4.0 and 2.5.0. After removing versions 2.4.0 and 2.5.0, the script worked. I have the language of Powershell set to French.
Here is the error message:
PS>New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectId $qa.id -RoleDefinitionName Contributor New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectI ...
-
+ CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectI ...
-
+ CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
I was getting with the -Debug switch on:
PS>New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectId $qa.id -RoleDefinitionName Contributor -debug DÉBOGUER : 17:28:01 - NewAzureRoleAssignmentCommand begin processing with ParameterSet 'ResourceGroupWithObjectIdParameterSet'. Confirmer Voulez-vous continuer cette opération ? &Oui Oui pour &tout &Interrompre la commande &Suspendre t DÉBOGUER : 17:28:03 - using account id '[email protected]'... Confirmer Le format de la chaîne d'entrée est incorrect. &Oui Oui pour &tout &Interrompre la commande &Suspendre t New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectI ...
-
+ CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectI ...
-
+ CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
DÉBOGUER : AzureQoSEvent: CommandName - New-AzRoleAssignment; IsSuccess - False; Duration - 00:00:02.9425758;; Exception - System.FormatException: Le format de la chaîne d'entrée est incorrect. à System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) à Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand.ExecuteCmdlet() à Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord(); DÉBOGUER : Finish sending metric. DÉBOGUER : 17:28:05 - NewAzureRoleAssignmentCommand end processing.
I have the same issue. If I force to load module version 2.4.0, this is working but not with 2.5.0 version. I'm using PowerShell 5.1 and Windows 10. In cloudshell where module version 2.5.0 is loaded this is working just fine
Something as simple as
New-AzRoleAssignment -ObjectId '<GUID_of_AAD_user_or_group>' -RoleDefinitionName 'Owner'
fails with Az.Resources 2.5.0, but works with 2.3.0 for instance. Do you even test before releasing new "stable" releases?
Output with Debug and Verbose set to Continue (exact same error using an actual GUID from the tenant in question as well, this is just for demo purposes).
PS C:\Users\OlavRønnestadBirkela>
$DebugPreference = 'Continue'
$InformationPreference = 'Continue'
$VerbosePreference = 'Continue'
New-AzRoleAssignment -ObjectId ([guid]::NewGuid().'Guid') -RoleDefinitionName 'Owner'
DEBUG: 09:15:36 - NewAzureRoleAssignmentCommand begin processing with ParameterSet 'EmptyParameterSet'.
DEBUG: 09:15:36 - using account id '<user_with_owner_on_subscription>'...
New-AzRoleAssignment : Input string was not in a correct format.
At line:5 char:1
+ New-AzRoleAssignment -ObjectId ([guid]::NewGuid().'Guid') -RoleDefini ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzRoleAssignment], FormatException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
DEBUG: AzureQoSEvent: CommandName - New-AzRoleAssignment; IsSuccess - False; Duration - 00:00:00.0269738;; Exception - System.FormatException: Input string was not in a correct format.
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
at Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 09:15:37 - NewAzureRoleAssignmentCommand end processing.
We are looking at the issue, for the moment, the workaround is to use the 2.4.0 version of the Az.Resources module.
Uninstall-Module -name Az.Resources -AllVersions -force && Install-Module -name Az.Resources -RequiredVersion 2.4.0
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure.
@armleads-azure
Any update here? This is still not resolved. Az.Resources 3.0.0 was released 15 days ago, no fix in that release either.
- https://www.powershellgallery.com/packages/Az.Resources
@o-l-a-v I have pushed a fix, however it didn't make it in time for the 3.0.0 release next release is on 11/17 you should try again then
I found a workaround, run [cultureinfo]::CurrentCulture = 'en-US' before calling New-AzRoleAssignment
Hello @dagoroz , @yvesgermain Apologies for the delayed follow-up on this. I see that this issue is opened a long time ago and no further activity had taken place. So wanted to check if you are still looking for assistance on this query? Please let us know.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure.
Issue Details
This script used to work with module az.resources 2.1.0: $qa = get-azadgroup -displayname qa; New-AzRoleAssignment -ObjectId $qa.Id -RoleDefinitionName Owner -ResourceGroupName RG-QA
Started getting this error on one computer but not the other. When I checked the modules version for az.resources, I had 2.1.0, 2.4.0 and 2.5.0. After removing versions 2.4.0 and 2.5.0, the script worked. I have the language of Powershell set to French.
Here is the error message:
PS>New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectId $qa.id -RoleDefinitionName Contributor New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectI ...
-
+ CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectI ...
-
+ CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
I was getting with the -Debug switch on:
PS>New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectId $qa.id -RoleDefinitionName Contributor -debug DÉBOGUER : 17:28:01 - NewAzureRoleAssignmentCommand begin processing with ParameterSet 'ResourceGroupWithObjectIdParameterSet'. Confirmer Voulez-vous continuer cette opération ? &Oui Oui pour &tout &Interrompre la commande &Suspendre t DÉBOGUER : 17:28:03 - using account id '[email protected]'... Confirmer Le format de la chaîne d'entrée est incorrect. &Oui Oui pour &tout &Interrompre la commande &Suspendre t New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectI ...
-
+ CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectI ...
-
+ CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
DÉBOGUER : AzureQoSEvent: CommandName - New-AzRoleAssignment; IsSuccess - False; Duration - 00:00:02.9425758;; Exception - System.FormatException: Le format de la chaîne d'entrée est incorrect. à System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) à Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand.ExecuteCmdlet() à Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord(); DÉBOGUER : Finish sending metric. DÉBOGUER : 17:28:05 - NewAzureRoleAssignmentCommand end processing.
| Author: | yvesgermain |
|---|---|
| Assignees: | dagoroz |
| Labels: |
|
| Milestone: | - |
As for me, you can close the case.
Thanks!
Yves Germain
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: msftbot[bot] @.> Sent: Saturday, October 23, 2021 8:55:19 PM To: Azure/azure-powershell @.> Cc: yvesgermain @.>; Mention @.> Subject: Re: [Azure/azure-powershell] New-AzRoleAssignment error: string format is incorrect (#12815)
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azurehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Farmleads-azure&data=04%7C01%7C%7Ca8e97f97bebe4ab295bb08d99688f44b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637706337218910849%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=61lIwYLMKUAt%2FNgT8xs9cQuYdCyMwlm5YjTrX2N3DUs%3D&reserved=0.
Issue Details
This script used to work with module az.resources 2.1.0: $qa = get-azadgroup -displayname qa; New-AzRoleAssignment -ObjectId $qa.Id -RoleDefinitionName Owner -ResourceGroupName RG-QA
Started getting this error on one computer but not the other. When I checked the modules version for az.resources, I had 2.1.0, 2.4.0 and 2.5.0. After removing versions 2.4.0 and 2.5.0, the script worked. I have the language of Powershell set to French.
Here is the error message:
PS>New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectId $qa.id -RoleDefinitionName Contributor New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectI ...
-
CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException
-
FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName Gumstorage-rg-devops -ObjectI ...
-
CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException
-
FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
I was getting with the -Debug switch on:
PS>New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectId $qa.id -RoleDefinitionName Contributor -debug DÉBOGUER : 17:28:01 - NewAzureRoleAssignmentCommand begin processing with ParameterSet 'ResourceGroupWithObjectIdParameterSet'. Confirmer Voulez-vous continuer cette opération ? &Oui Oui pour &tout &Interrompre la commande &Suspendre t DÉBOGUER : 17:28:03 - using account id @.@.>'... Confirmer Le format de la chaîne d'entrée est incorrect. &Oui Oui pour &tout &Interrompre la commande &Suspendre t New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectI ...
-
CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException
-
FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
New-AzRoleAssignment : Le format de la chaîne d'entrée est incorrect. Au caractère Ligne:1 : 1
- New-AzRoleAssignment -ResourceGroupName GumStorage-rg-devops -ObjectI ...
-
CategoryInfo : CloseError : (:) [New-AzRoleAssignment], FormatException
-
FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
DÉBOGUER : AzureQoSEvent: CommandName - New-AzRoleAssignment; IsSuccess - False; Duration - 00:00:02.9425758;; Exception - System.FormatException: Le format de la chaîne d'entrée est incorrect. à System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) à Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand.ExecuteCmdlet() à Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord(); DÉBOGUER : Finish sending metric. DÉBOGUER : 17:28:05 - NewAzureRoleAssignmentCommand end processing.
Author: yvesgermain Assignees: dagoroz Labels:
ARM, Service Attention, question, customer-reported, needs-author-feedback
Milestone: -
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%2F12815%23issuecomment-950240107&data=04%7C01%7C%7Ca8e97f97bebe4ab295bb08d99688f44b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637706337218920833%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Ul%2Fl58UvxTm8ESYXzYTDeVFLutb87%2BzMqzgfZfkwpso%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAIG7KB4BVOIX6MKL7HV5KULUINKPPANCNFSM4QQ2D5NQ&data=04%7C01%7C%7Ca8e97f97bebe4ab295bb08d99688f44b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637706337218930830%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=IRBorm8Bc6El%2BxOk%2FCFGAEzaA30%2F2MTQxeIGnk%2B5fT4%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7Ca8e97f97bebe4ab295bb08d99688f44b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637706337218930830%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=6kwGrmTZirEFSiOX3pZgDFK0LJ9TV%2FKEfPdfe86FN8M%3D&reserved=0 or Androidhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7Ca8e97f97bebe4ab295bb08d99688f44b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637706337218940821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4SFDfUh%2BMp9rfpeaxE4WBnW2S94cIGESyDIdHPKVyV4%3D&reserved=0.
We will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.
Please also do visit Microsoft Q&A the home for technical questions and answers at Microsoft.