@@ -184,7 +184,7 @@ public class NewAzureRoleAssignmentCommand : ResourcesBaseCmdlet
184184 [ Parameter ( Mandatory = false , ValueFromPipelineByPropertyName = true , ParameterSetName = ParameterSet . ScopeWithSPN ,
185185 HelpMessage = "Condition to be applied to the RoleAssignment." ) ]
186186 [ ValidateNotNullOrEmpty ]
187- public string Condition { get ; set ; }
187+ public string Condition { get ; set ; } = null ;
188188
189189 [ Parameter ( Mandatory = false , ValueFromPipelineByPropertyName = true , ParameterSetName = ParameterSet . Empty ,
190190 HelpMessage = "Version of the condition." ) ]
@@ -207,7 +207,7 @@ public class NewAzureRoleAssignmentCommand : ResourcesBaseCmdlet
207207 [ Parameter ( Mandatory = false , ValueFromPipelineByPropertyName = true , ParameterSetName = ParameterSet . ScopeWithSPN ,
208208 HelpMessage = "Version of the condition." ) ]
209209 [ ValidateNotNullOrEmpty ]
210- public string ConditionVersion { get ; set ; }
210+ public string ConditionVersion { get ; set ; } = null ;
211211
212212 [ Parameter ( Mandatory = true , ValueFromPipelineByPropertyName = true , ParameterSetName = ParameterSet . RoleIdWithScopeAndObjectId ,
213213 HelpMessage = "Role Id the principal is assigned to." ) ]
@@ -245,7 +245,7 @@ public override void ExecuteCmdlet()
245245 this . ResourceType = RoleAssignment . ObjectType ;
246246 this . Scope = RoleAssignment . Scope ;
247247 Guid guid = Guid . Empty ;
248- Guid . TryParse ( RoleAssignment . RoleDefinitionId , out guid ) ;
248+ Guid . TryParse ( RoleAssignment . RoleDefinitionId , out guid ) ;
249249 this . RoleDefinitionId = guid ;
250250 this . Description = RoleAssignment . Description ;
251251 this . Condition = RoleAssignment . Condition ;
@@ -271,7 +271,9 @@ public override void ExecuteCmdlet()
271271 }
272272
273273 }
274- double _conditionVersion = double . Parse ( ( ConditionVersion ?? "2.0" ) ) ;
274+ // ensure that if ConditionVersion is empty in any way, it becomes null
275+ ConditionVersion = string . IsNullOrEmpty ( ConditionVersion ) ? null : string . IsNullOrWhiteSpace ( ConditionVersion ) ? null : ConditionVersion ;
276+ double _conditionVersion = double . Parse ( ConditionVersion ?? "2.0" ) ;
275277 if ( _conditionVersion < 2.0 )
276278 {
277279 WriteExceptionError ( new ArgumentException ( "Argument -ConditionVersion must be greater or equal than 2.0" ) ) ;
0 commit comments