Author Posts

March 2, 2018 at 10:14 pm

Hi,

I'm creating a fairly large script, which needs to pull in Name, Dates, Site Location etc from a external file. What would be the best way to store this information in an external file. i know i can use psd1, Json, XMl, but not sure whats best.

The values for the would have nested values, for example:

@{
      Name = London
      Offices = "Office 1","Office 2","Office 3"
      Subnet = "1.1.1.1","1.1.2.1"

}

Thanks

Tommy

March 4, 2018 at 2:21 am

Hi Tommy,
It totally depends on the amount of data you want to store. If its too large looking at something like SQL (MS SQLExpress) would help. Also because you mentioned you have nested data.

Normally CSV can be a quick and easy way to store data. But there are limitations when it comes to nested and Sub information.

You can also use XML as its more extensible. but this is still a flat file and can sometimes grow out to be too large
All CSV, JSON, XML have native Powershell export and import commands. So this would be easy.

As mentioned if you go down the SQL path, there is a free E book by Don Jones which can help you get an idea to set this up
https://www.gitbook.com/book/devops-collective-inc/ditch-excel-making-historical-trend-reports-in-po/details

there is also a powershell module you can download from the gallery if you don't want to go the whole 9 yards 🙂
https://www.powershellgallery.com/packages/Write-ObjectToSQL/1.13

Hope this help

Regards
Shihan