Categories: Windows

Environment Variables in Group Policy preferences

Today our customer asked us to configure a group policy for multiple users on one of the servers. While standard GPO is something most administrators do as a daily job, sometimes one need to use an environment variables instead of hardcoded values. Microsoft in it's wisdom added a great, quick functionality intoGroup Policy Management Console. When you open a window to create New Registry entry or New Folder Entry you're given an option to select the variable you need.   Bsy pressing F3 you can get an overview of all variables you can use within Group Policy settings.   Ain't it nice from MICROSOFT? YES! Below you can find full list of variables available in GPO, but also in other parts of Windows.

%AppDataDir%

The current user's Application Data directory.

%BinaryComputerSid%

The SID of the computer in hexadecimal format.

%BinaryUserSid%

The SID of the current user in hexadecimal format.

%CommonAppdataDir%

The “all users” Application Data directory.

%CommonDesktopDir%

The “all users” Desktop directory.

%CommonFavoritesDir%

The “all users” Explorer Favorites directory.

%CommonProgramsDir%

The “all users” Programs directory.

%CommonStartMenuDir%

The “all users” Start Menu directory.

%CommonStartUpDir%

The “all users” Startup directory.

%ComputerName%

The NetBIOS name of the computer.

%CurrentProcessId%

The numeric identity of the main client process.

%CurrentThreadId%

The numeric identity of the main client thread.

%DateTime%

The current time (UTC).

%DateTimeEx%

The current time (UTC) with milliseconds.

%DesktopDir%

The current user's desktop directory.

%DomainName%

The domain name or workgroup of the computer.

%FavoritesDir%

The current user's Explorer Favorites directory.

%LastError%

The last error code encountered during configuration.

%LastErrorText%

The last error code text description.

%LdapComputerSid%

The SID of the computer in LDAP escaped binary format.

%LdapUserSid%

The SID of the current user in LDAP escaped binary format.

%LocalTime%

The current local time.

%LocalTimeEx%

The current local time with milliseconds.

%LogonDomain%

The domain of the current user.

%LogonServer%

The domain controller that authenticated the current user.

%LogonUser%

The user name of the current user.

%LogonUserSid%

The SID of the current user.

%MacAddress%

The first detected MAC address on the computer.

%NetPlacesDir%

The current user's My Network Places directory.

%OsVersion%

The operating system: Windows Server® 2008 R2, Windows® 7, Windows Server® 2008, Windows Vista®, Windows Server 2003, Windows XP, or Unknown.

%ProgramFilesDir%

The Windows Program Files directory.

%ProgramsDir%

The current user's Programs directory.

%RecentDocumentsDir%

The current user's Recent Documents directory.

%ResultCode%

The client's exit code.

%ResultText%

The client's exit code text description.

%ReversedComputerSid%

The SID of the computer in reversed byte order hexadecimal format.

%ReversedUserSid%

The SID of the current user in reversed byte order hexadecimal format.

%SendToDir%

The current user's Send to directory.

%StartMenuDir%

The current user's Start Menu directory.

%StartUpDir%

The current user's Startup directory.

%SystemDir%

The Windows system directory.

%SystemDrive%

The name of the drive from which the operating system is running.

%TempDir%

The current user's Temp directory as determined by Windows API.

%TimeStamp%

The time stamp of the configurations being implemented.

%TraceFile%

The path/name of the trace file.

%WindowsDir%

The Windows directory.

This post was last modified on March 20, 2016 12:24

Przemyslaw Klys

System Architect with over 14 years of experience in the IT field. Skilled, among others, in Active Directory, Microsoft Exchange and Office 365. Profoundly interested in PowerShell. Software geek.

Share
Published by
Przemyslaw Klys

Recent Posts

Active Directory Replication Summary to your Email or Microsoft Teams

Active Directory replication is a critical process that ensures the consistent and up-to-date state of…

2 weeks ago

Syncing Global Address List (GAL) to personal contacts and between Office 365 tenants with PowerShell

Hey there! Today, I wanted to introduce you to one of the small but excellent…

5 months ago

Active Directory Health Check using Microsoft Entra Connect Health Service

Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…

7 months ago

Seamless HTML Report Creation: Harness the Power of Markdown with PSWriteHTML PowerShell Module

In today's digital age, the ability to create compelling and informative HTML reports and documents…

8 months ago

How to Efficiently Remove Comments from Your PowerShell Script

As part of my daily development, I create lots of code that I subsequently comment…

9 months ago

Unlocking PowerShell Magic: Different Approach to Creating ‘Empty’ PSCustomObjects

Today I saw an article from Christian Ritter, "PowerShell: Creating an "empty" PSCustomObject" on X…

9 months ago