Passing Data from CSV

Welcome Forums DSC (Desired State Configuration) Passing Data from CSV

This topic contains 2 replies, has 2 voices, and was last updated by

1 year, 11 months ago.

  • Author
  • #67525

    Points: 26
    Rank: Member


    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

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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

    Points: 26
    Rank: Member

    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?


The topic ‘Passing Data from CSV’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort