-1

currently working on a script to configure policies for a citrix farm. i have a few policies that have 7-8 settings each, and can add them individually with:

set-ctxgrouppolicyconfiguration [policyName] [type] [setting] [value]
set-ctx....
set-ctx....

Is there a way to read these settings into an array and pass that to the cmdlet?

soMuch2Learn
  • 187
  • 2
  • 5
  • 21

1 Answers1

1

I'm not too familiar with Citrix, but you could always create a list of settings in a CSV:

"PolicyName","Type","Setting","Value"
"foo","User","some","23"
"foo","User","other","42"
"bar","User","...","..."
...

define a custom function like this:

function Set-MyPolicies {
  [CmdletBinding()]
  Param(
    [Parameter(ValueFromPipeline=$true)]
    [PSObject[]]$Policies
  )

  Process {
    $Policies | % {
      Set-CtxGroupPolicyConfiguration @_
    }
  }
}

and put everything together like this:

Import-Csv 'C:\path\to\policies.csv' | Set-MyPolicies

The function uses splatting for simplified parameter handling (the column titles of the CSV were named after the parameters to allow this).

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328