|
Re: Set-Variable Fred J. wrote:
> PS> Set-Variable -name xy -value "orange"
> PS> Set-Variable -name xy -description "this variable contains a color"
> PS> Get-Variable -name xy
> Name Value
> ---- -----
> xy orange
>
> PS> Get-Variable -name xy |format-list -property *
> Name : xy
> Description : this variable contains a color
> Value : orange
> Options : None
> Attributes : {}
>
> PS> get-variable xy | format-list -property description
> Description : this variable contains a color
>
> Why isn't a value returned when I do this? All I get is a prompt.
> PS > $xy.description
What you're asking for there is the value of a "description" property of
whatever $xy points to.
If $xy was a DateTime then you can do this:
PS > $xy.Year
2006
But in your case $xy is a string ("orange"), and System.String doesn't
have a property called Description.
I guess get-variable is the only way to get to this "metadata" attached
to a variable in PS. |