Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Working with Powershell Objects?

$
0
0

I've been looking for an answer to this for a while.

I'm using powershell to return information that I need to work with.  The Script returns a hashtable.  However I can't seem to get to the data in the hashtable.  I'm fairly new to this stuff so I at the end of ideas.  Here's my code.

    string scriptFile = ScriptText.CreatSciptText(@"C:\scripts\ldap\Format-FingerDictionary.ps1");
            Command myCommand = new Command(scriptFile, true);
            int[] znums = new int[] { 115653, 209795, 262160, 243272 };
            CommandParameter commParam = new CommandParameter("Znum", znums);
            myCommand.Parameters.Add(commParam);
            pipeline.Commands.Add(myCommand);
            var obs = pipeline.Invoke();
            Hashtable hash = (Hashtable)obs[0].BaseObject;
            foreach (DictionaryEntry entry in hash)
            {
                var theKey = entry.Key;
                var theValue = entry.Value;
                Console.WriteLine(@"Key: {0} Value:{1}", theKey., theValue);
            }

When I loop through the hashtable all I get is System.Object[] as the type for both the key and the value.  The key should be an integer, and the value should be an array or list (I'm not quite sure how the powershell array would transfer to c#).


Jack of all trades master of none.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>