PowerShell - Override any policies

Hi Team

Is it possible to bypass any policy settings when running a powershell script to change some user settings on the account? 

I need to change SamAccount from being lowercase to uppercase but there is a policy stopping the change from happening. 

Thanks in advance 

  • There exists an ability to suppress the enforcement of a policy rule.

    If you want to handle this programmatically, you would have to implement this within a policy script embedded in a provisioning policy

    Function OnGetEffectivePolicy ($Request)
    {
    
    If ($Request.Class -ne "user"){return}
    
    # Here you need some logic to determine whether or not to fire the "Clear..." line
    # Perhaps use a Control?
    
    Try
    {
    
    # You would set this control in the cmdlet adjusting the samaccountname
    # i.e. -Control @{BatchSamUpdate='YES'}
    
    If ($Request.GetInControl("BatchSamUpdate") -eq "YES")
    {
    $Request.ClearEffectivePolicyInfo("samaccountname", $Constants.EDS_EPI_UI_POLICY_RULE)
    }
    
    }
    Catch
    {
    
    }
    
    
    }

  • Thanks Johnny. Will take a look at this