powershell-intune-samples icon indicating copy to clipboard operation
powershell-intune-samples copied to clipboard

Import policy allows you to use the same DisplayName

Open MKPerry opened this issue 6 years ago • 4 comments

Testing in my lab has shown that if you use one of the "Import_JSON" scripts, it is possible to import a JSON file that has the DisplayName attribute matching one that already exists. In the Intune console you see two policies with the same name. Could we add a graph look up and if a policy has the same displayname as an existing one then add something like _Copy or _1.

MKPerry avatar Apr 18 '19 12:04 MKPerry

Good idea - currently the displayname is not the unique key identifier of the policy - it's the guid of the policy. Unfortunately you dont know what the policy guid will be until it is generated. One possible scenario could be that we return the policy guid back with the successful upload.

tabs-not-spaces avatar Jul 09 '19 00:07 tabs-not-spaces

Testing in my lab has shown that if you use one of the "Import_JSON" scripts, it is possible to import a JSON file that has the DisplayName attribute matching one that already exists. In the Intune console you see two policies with the same name. Could we add a graph look up and if a policy has the same displayname as an existing one then add something like _Copy or _1.

I know this is very old at this point, but I like this. Or maybe a parameter default false that if true, will function as described. This way nothing breaks.

TheRealBenForce avatar Feb 10 '23 21:02 TheRealBenForce

It wouldn't be difficult to pull down all policies and compare the displayName props. But the sample code doesn't need to do this... It's in the name - it's sample.

If there's interest in this I can provide examples on how to do it.

tabs-not-spaces avatar Feb 11 '23 06:02 tabs-not-spaces

I appreciate that but it's not necessary for me. My interest is to be able to describe intune configuration as code and "make it so". Like what would see with DSC, terraform, etc. But it seems like I probably won't be part of this project at work so its unlikely I'd put it to practice even if were available.

TheRealBenForce avatar Feb 13 '23 23:02 TheRealBenForce