Passing Data from CSV

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of TommyQuality TommyQuality 2 months, 3 weeks ago.

  • Author
  • #67525
    Profile photo of TommyQuality


    I need to create multiple groups within a DSC script. Im using a hashtable to pass the data through.

    $Nodes = @(
    @{NodeName = "TESTWEB01";Role = "IIS";PSDscAllowPlainTextPassword = $true},
    @{NodeName = "TESTWEB02";Role = "IIS";PSDscAllowPlainTextPassword = $true},
    @{Nodename = "*";Features = "Web-Mgmt-Tools","WEb-Scripting-Tools" , "Web-Mgmt-Service"

    but i need to add groups to the hashtable that will contain GroupName and Description, whats the best way to achieve this – Could i use

    @{Nodename = "*";Features = "Web-Mgmt-Tools","WEb-Scripting-Tools" , "Web-Mgmt-Service;groups=(Get-Content "C:\groups.csv"

    Or do i need to add each group to my hashtable as individual key/value pairs?


  • #67534
    Profile photo of Don Jones
    Don Jones

    Well... I'd say, "have you tried it?" As written, no, that won't work. But that's because you haven't told PowerShell to actually execute your Get-Content. In double quotes, that's normally done as a subexpression, a la "blah blah $(Get-Content whatever.txt)". If I were experimenting, that's what I'd try first.

  • #67545
    Profile photo of TommyQuality

    Thanks for the reply Don, I didn't really mean to ask will this work, it's more whats best? I mean i could just create loads of DSC Group Resources in the script and assign the Name, Description and members, but that doesn't seem like the best way to do it.

    I could populate the hash table with individual groups, but then the hash table would be massive, so i suppose i have answered my own question and should use get-content or import-csv, unless there is a better way?


You must be logged in to reply to this topic.