次の方法で共有


Environment Variables in GP Preferences

There was a great question in the blog comments, I’m going to post the answer up here because I think the answer is cool.

Can a location (UNC) be set using both an environmental variable and a static entry?

I'll explain by example. Let's say that there are shares named %username%Folder (FredFolder, SallyFolder, EricFolder, etc.). Is there a way to set this as the location in a single GPP item for all users? I've already determined that \\server\Users\%logonuser%Folder won't work. Is there some syntax that can make this happen?

In fact, that is how you do it. The issue here is not of syntax, but more likely of placement. A potential problem in the above example is if the preference item was created under Computer Configuration; it should have been under User Configuration to be properly resolved.

Here are some examples:

image

The XML for this item is below: copy/paste that into an XML document (notepad file, save as .xml), drag that file into your Preference Folder Item’s window and you will have a preference item that updates a folder called “SimpleFolder” on every user’s desktop. Open up the item to verify this!

<<Folder clsid="{07DA02F5-F9CD-4397-A550-4AE21B6B4BD3}" name="SimpleFolder" status="SimpleFolder" image="2" changed="2009-05-13 23:45:06" uid="{B484D1CF-3C08-4DD3-86EE-1293EBD346F9}" bypassErrors="1">

<Properties action="U" path="%DesktopDir%\SimpleFolder" readOnly="0" archive="1" hidden="0"/>

</Folder>

Here’s one using LogonUser:

-image

This configuration creates a folder on the Desktop using the logged on user’s name + the string “worksWell”. Here’s the XML:

<Folder clsid="{07DA02F5-F9CD-4397-A550-4AE21B6B4BD3}" name="%LogonUser%worksWell" status="%LogonUser%worksWell" image="2" changed="2009-05-13 23:57:19" uid="{AC4D0C72-21C1-4D07-84FC-9E0595F8EFB2}">

<Properties action="U" path="%DesktopDir%\%LogonUser%worksWell" readOnly="0" archive="1" hidden="0"/>

</Folder>

To access these environment variables, just press F3 and you’ll see a window come up with all of your options. Remember to check the “Resolve variable” box at the bottom of the dialog.

image

To read more about creating folder preference items, read this TechNet article.

 

Hope this helps,

LiliaG, Group Policy PM

Thanks to:

Mark Gray, Group Policy PM and RajiveK, Group Policy Software Developer Engineer