Azure policy notscope powershell

2021-10-26T08:12:14.443+00:00

Hi,
I'm investigating implementing Azure policy using powershell and can successfully do this, apart from adding exclusions. I can retrieve current existing exclusions, but not add them. I've read through the documentation, but don't seem to be able to locate any information about this, only doing a manual update via the portal?

I've tried using the -NotScope parameter with Set-AzPolicyAssignment with RG names I want to exclude, but get an error :

Set-AzPolicyAssignment : InvalidCreatePolicyAssignmentRequest : The policy assignment
'xxxxxxxxxxxxxxxxxx' not scopes 'testRG' must all be below the policy assignment's scope

Any point in the right direction would be greatly appreciated!

Thanks,
Marc

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
1,014 questions
{count} votes

Accepted answer
  1. Monalla-MSFT 13,071 Reputation points Moderator
    2021-10-27T00:05:00.1+00:00

    @McCarthy, Marc (IT Cyber Security, Group CIO) - Thanks for reaching out.

    The error message you are receiving is correct. Whatever is defined with the -NotScope parameter must be within the Scope that is defined.

    For example, if the policy is applied to a resource group, then exceptions can only be applied to resources within that resource group.

    This is a service level limitation and not a limitation with Azure PowerShell. The same limitation applies to Azure CLI and the Azure portal.

    Hope that helps.

    If the above response helped, please feel free to "Accept as Answer" so it can be beneficial to the community.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.