On Fri, 4 Jan 2013 14:32:31 -0800 (PST),
kar...@markmanns.dk wrote in
microsoft.public.windows.powershell:
>Hi
>I'am a bit stuck on this one, so any help would be appriciated:
>I have the following code snippet:
>
>c:\get-host
>Which returns:
>Name : Windows PowerShell ISE Host
>Version : 2.0
>InstanceId : e5ab551b-4fad-4ae6-89c3-e91e0633d4ff
>UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
>CurrentCulture : da-DK
>CurrentUICulture : en-US
>PrivateData : Microsoft.PowerShell.Host.ISE.ISEOptions
>IsRunspacePushed : False
>Runspace : System.Management.Automation.Runspaces.LocalRunspace
>
>I want to create a foreach or a for loop, iterating every key and value, and (for a beginng) display the key names and their values on the screen.
You are mistaken about the data structure. There is no hash and there
are no key-value pairs anywhwere in the result of get-host. Try
"get-member" to see the actual nature of the result type:
PS C:\> get-host | get-member
TypeName: System.Management.Automation.Internal.Host.InternalHost
Name MemberType Definition
---- ---------- ----------
EnterNestedPrompt Method System.Void EnterNestedPrompt()
Equals Method bool Equals(System.Object obj)
ExitNestedPrompt Method System.Void ExitNestedPrompt()
GetHashCode Method int GetHashCode()
GetType Method type GetType()
NotifyBeginApplication Method System.Void NotifyBeginApplication()
NotifyEndApplication Method System.Void NotifyEndApplication()
PopRunspace Method System.Void PopRunspace()
PushRunspace Method System.Void PushRunspace(runspace
runspace)
SetShouldExit Method System.Void SetShouldExit(int
exitCode)
ToString Method string ToString()
CurrentCulture Property System.Globalization.CultureInfo
CurrentCulture {get;}
CurrentUICulture Property System.Globalization.CultureInfo
CurrentUICulture {get;}
InstanceId Property System.Guid InstanceId {get;}
IsRunspacePushed Property System.Boolean IsRunspacePushed {get;}
Name Property System.String Name {get;}
PrivateData Property System.Management.Automation.PSObject
PrivateData {get;}
Runspace Property
System.Management.Automation.Runspaces.Runspace Runspace {get;}
UI Property
System.Management.Automation.Host.PSHostUserInterface UI {get;}
Version Property System.Version Version {get;}
>I have created the following which obvioiusly doesn't work, because I don't know how to syntax it. But I hope You get the idea:
Has nothing to do with syntax but with assuming the wrong data
structure.
jue