Open AdamFields1 opened 2 years ago
@LucasYao93 , please look into this issue.
I think we will need to add the namespace to make it work.
$expirationRule = [Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Models.Api20201001Preview.RoleManagementPolicyExpirationRule]@{
isExpirationRequired = "false";
maximumDuration = "P180D";
id = "Expiration_Admin_Eligibility";
ruleType = [Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Support.RoleManagementPolicyRuleType]("RoleManagementPolicyExpirationRule");
targetCaller = "Admin";
targetOperation = @('All');
targetLevel = "Eligibility";
targetObject = $null;
targetInheritableSetting = $null;
targetEnforcedSetting = $null;
}
$rules = [Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Models.Api20201001Preview.IRoleManagementPolicyRule[]]@($expirationRule)
Either use the full namespace as mentioned by @dolauli or use the using statement in the PowerShell script (at the top of the script) to use just the shorthand of the class name.
using namespace Microsoft.Azure.PowerShell.Cmdlets.Resources.Authorization.Models.Api20201001Preview;
Note - The module Az.Resources
needs to be loaded in the PowerShell session before using the above statement.
Could we have the documentation updated with @dolauli solution please ?
Description
I am trying to update Azure PIM role policy settings with Update-AzRoleManagementPolicy since this seems easier than working with ARM templates. However, when I go to execute the examples found here https://docs.microsoft.com/en-us/powershell/module/az.resources/update-azrolemanagementpolicy?view=azps-8.0.0 they do not work and throw an error that the class RoleManagementPolicyExpirationRule cannot be found. I have tried this both in my Azure gov and public tenants with the same results.
Issue script & Debug output
Environment data
Module versions
Error output