Skip to content

Suggestion: Export-PowerShellDataFile CmdLet #2783

Closed

Description

While working with DSC, I use PSD1 files quite a lot; the main use, at present, is

  • Have a 'RoleInformation.psd1' that details information about a type of server/node. This file is the same irrespective of enviroment (Dev, Test, Staging, Live, etc)
  • Have a 'NodeData.psd1' that contains a list of servers, collected from the environment listing their name, cert thumbprint and cert path (as each has it's unique cert to use)
  • Merge the 'RoleInformation' with the 'NodeData' to make an environment specific configuration data document that has expanded all properties for each node.

Because of this use, I am writing out several PSD1 files. The example above is just one use, I also have several libraries of information in PSD1 format so that everything is the same.

I have implemented my own Export-PowerShellDataFile function but it will need work to make it more professional, I'm happy to put it on GitHub and link at a later date for others to judge and perhaps suggest improvements.

I just believe that, with the huge investment in DSC, PowerShell should include a native module for this purpose.

At a high level, my current function provides:

A formatted output of a HashTable (including all tags)
Indentation (parameter based character and number)

I may look to change mine into C# but would welcome any suggestions for a best practice way or achieving a correctly formatted and indented file.

I'd also welcome suggestions on ordering the output.
I know you can created ordered hashtables, but if you're reading in from a file where you don't know all of the attributes/properties, you can't create an ordered table from it

Activity

  1. added
    WG-Cmdlets
    Issue-Enhancement
    Up-for-Grabs
    on Nov 26, 2016
  2. nightroman commented on Mar 2, 2018

    @nightroman
  3. SteveL-MSFT commented on Oct 29, 2018

    @SteveL-MSFT
    Member

    Dupe of #2875 (this one is older, but the other had more discussion)

  4. added
    Resolution-Duplicate
    and removed
    Up-for-Grabs
    on Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-EnhancementResolution-DuplicateWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions