PowerTip: Accessing System Values

Summary: Use Windows PowerShell to ease access to system values.

Hey, Scripting Guy! Question How can l print out the value of %systemroot%?

Hey, Scripting Guy! Answer 

a. (get-item Env:\systemroot).value

b. $env:systemroot

Comments (2)

  1. Walid Toumi says:

    hi Ed,

    thank's for sharing, here some variant:

    PS II> split-path ([Environment]::SystemDirectory)

    PS II> gc env:windir

    PS II> [ENVIRONMENT]::ExpandEnvironmentVariables('%WINDIR%')

  2. Ed Wilson says:

    @Walid Toumi woohoo!!! I love it. The cool thing about PowerShell is there are so many ways to do exactly the same things! Thanks for sharing.

Skip to main content