Historic Blog. No longer active. A script repository that stopped at Powershell 4.0 is at www.rmfdevelopment.com/PowerShell_Scripts . My historic blog (no longer active) on Network Security ( http://thinking-about-network-security.blogspot.com ) is also Powershell heavy. AS of 2/27/2014 all Scripts are PS 4.0.
Sunday, August 5, 2012
Some notes on querying variables in Powershell 3.0
PS C:\ps1> ls variable:/*
Name Value
---- -----
null
false False
true True
MaximumErrorCount 256
MaximumVariableCount 4096
MaximumFunctionCount 4096
MaximumAliasCount 4096
MaximumDriveCount 4096
Error {Cannot find drive. A drive with the name 'variablwe' does not exist., System.Management.Automation.P...
PSDefaultParameterValues {}
$ variablwe:/*
^ ls
StackTrace at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object inpu...
ErrorView NormalView
LASTEXITCODE 0
PSEmailServer
....
PS C:\Windows\system32> ((ls variable:/) | gm *).typename | get-unique
System.Management.Automation.PSVariable
System.Management.Automation.QuestionMarkVariable
System.Management.Automation.LocalVariable
System.Management.Automation.SessionStateCapacityVariable
System.Management.Automation.NullVariable
PS C:\Windows\system32> (ls variable:/).Name
$
?
^
args
ConfirmPreference
ConsoleFileName
DebugPreference
Error
ErrorActionPreference
ErrorView
ExecutionContext
false
foreach
FormatEnumerationLimit
HOME
...
PS C:\Windows\system32> foreach ($i in (ls variable:/*)) {($i | Select Name,Value)}
Name Value
---- -----
null
false False
true True
MaximumErrorCount 256
MaximumVariableCount 4096
MaximumFunctionCount 4096
MaximumAliasCount 4096
MaximumDriveCount 4096
Error {System.Management.Automation.ParseException: At line:1 char:100...
PSDefaultParameterValues {}
$ }
^ foreach
StackTrace at System.Management.Automation.Internal.PipelineProcessor.Sy...
OutputEncoding System.Text.ASCIIEncoding
ConfirmPreference High
DebugPreference SilentlyContinue
ErrorActionPreference Continue
ProgressPreference Continue
VerbosePreference SilentlyContinue
WarningPreference Continue
ErrorView NormalView
NestedPromptLevel 0
WhatIfPreference False
FormatEnumerationLimit 4
PSEmailServer
PSSessionOption System.Management.Automation.Remoting.PSSessionOption
PSSessionConfigurationName http://schemas.microsoft.com/powershell/Microsoft.PowerShell
PSSessionApplicationName wsman
PWD C:\Windows\system32
...
PS C:\Windows\system32> foreach ($i in (ls variable:/).Name) {ls variable:/$i | Select Name,Module,Description}
Name Module Description
---- ------ -----------
$
$
^
? Execution status of last command.
i
^
args
ConfirmPreference Dictates when confirmation should be requ...
ConsoleFileName Name of the current console file.
DebugPreference Dictates action taken when an Debug messa...
Error
ErrorActionPreference Dictates action taken when an error messa...
ErrorView Dictates the view mode to use when displa...
ExecutionContext The execution objects available to cmdlets.
false Boolean False
foreach
PS C:\ps1> foreach ($i in (ls variable:/*).Name) {ls variable:/$i | Select Name,@{Name="Value";Expression={($_.value)}}}
Name Value
---- -----
null
false False
true True
MaximumErrorCount 256
MaximumVariableCount 4096
MaximumFunctionCount 4096
MaximumAliasCount 4096
MaximumDriveCount 4096
Error {Illegal key ValueCount, Illegal key ValueCount, Illegal key Val...
PSDefaultParameterValues {}
$ }
^ foreach
StackTrace at System.Management.Automation.MshCommandRuntime.ThrowTermin...
ErrorView NormalView
LASTEXITCODE 0
PSEmailServer
PWD C:\ps1
$ }
^ foreach
? True
y {1, 8, 27, 64...}
i ?
a {4, 3, 2, 1}
.....
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment