Oct 21, 2014 A Better ToString Method for Hash Tables I didn’t make it to the PowerShell Summit 2014 in Europe this year, but I’ve been getting much of the.
This topic contains 6 replies, has 3 voices, and was last updated by
Windows LiveUser32
3 years, 11 months ago.- You can turn it into an object using pscustomobject, and then successfully pipe that to a Csv. Notice, I've also created a separate keys for process, state, and startmode. I'm not sure if this will work (for you), so if not, take a look at the second option to leave the process, state, and startmode as a single value for the one, WindowsDefender, key.Box Prox wrote about this in 2014, and I've referenced the post numerous times when I hit the System.Object[] in my exported, Csv files. Here's the link: http://learn-powershell.net/2014/01/24/avoiding-system-object-or-similar-output-when-using-export-csv/.Most recently, I used it to a fix a problem with a DHCP/DNS function I wrote: http://tommymaynard.com/script-sharing-find-dns-servers-being-used-by-dhcp-scopes-2015. I even gave him credit at the bottom of that post.Anyway, let me know if this helps, and if you can't scroll left-right in the script windows, use the double-sided arrows to open it in a separate window.
- That's expected behavior prior to PowerShell 3.0, when creating a custom object with this option. There's different ways to create custom objects in the earlier versions of PowerShell. Here's how to do it in the different versions: http://blogs.technet.com/b/heyscriptingguy/archive/2013/11/07/a-powershell-object-lesson-part-3.aspx. I choose PowerShell 3.0, since I think that's when we were able to order our hash tables, such as what you did in your example.
- Stephen,No need to use a hashtable as an interim step.If you need to change the column header, you do it like this:
- Posts
The topic ‘Hashtable - export : to CSV’ is closed to new replies.