Import policy allows you to use the same DisplayName
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.
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.
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.
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.
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.