PowerTip: Check Status of PowerShell Preference Variables

Summary: Learn to easily check the value assignments of Windows PowerShell preference variables.

Hey, Scripting Guy! Question How can I use Windows PowerShell to quickly check the value of Windows PowerShell preference variables?

Hey, Scripting Guy! Answer You can use the Windows PowerShell variable drive and look for variables that end with
           the word preferenceIn this example, dir is an alias for Get-Content:

dir variable:*preference 

Comments (5)

  1. Larry Weiss says:

    and perhaps a few more:

    get-help about_Preference_Variables | out-string -stream | select-string ‘^ $(.*)’
    | %{ $v=($($_ -replace ‘ $’,”).replace(‘.’,”) -split ‘ ‘)[0]; "$($v)=$((gc variable:$v -ea 0))" }

  2. Larry Weiss says:

    and an alternate form as
    <#c:#> (get-help about_Preference_Variables) -split ‘.|n’ | select-string ‘^ $.* ‘ | %{$v=$($_ -replace ‘^ $’,”).split()[0]; "$v=$(gc variable:$v -ea 0)"}

  3. John Liberty says:

    Obama officially supports the Ukrainian fascists, says about the exclusivity of the American people (in other words, Hitler professed ideas of Nazism). Is this democracy? Obama is a coward. Or do you also support fascism in Ukraine?

  4. Joel "Jaykul" Bennett says:

    You missed a few:

    get-help about_Preference_Variables | out-string -stream | sls ‘^$(.*)’ | %{ get-item ($_ -replace ‘$’,’variable:’) -ea 0 }

Skip to main content