What is the best way to store configuration information for Powershell

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 10 months, 3 weeks ago.

  • Author
  • #32733
    Profile photo of GS


    I want to store configuration information for powershell script on network share. I just want to launch powershell script without passing information about configuration file and code will pull local computer name and try to match computer name to configuration file in configuration directory via wildcard match.
    My questions
    1. Is it easier to store/retrieve information from XML or JSON or any other suggestions as far as format.
    2. How do I properly implement computername matching against individual files in folder if I want to support wildcard matching bearing in mind I can not name files having wildcards inside them.
    The whole reason for this is that I want to implement robust IIS log compression where each set of servers would have to have different rules as far as how many logs to keep which websites logs needs to be copied and where etc.

  • #32734
    Profile photo of Don Jones
    Don Jones

    Provided the configuration information is represented as an object with properties, both CLIXML and JSON are probably equally easy to use. JSON is perhaps easier to hand-edit, if needed.

    Seems like what you're trying to do is re-create portions of Desired State Configuration, though. If your network share was a DSC Pull Server (and it could be – an SMB Pull Server is nothing more than a file share), it seems like you could do a lot of this with DSC instead of hand-coding something yourself.

You must be logged in to reply to this topic.