Jump to content
Welcome to our new Citrix community!
  • 0

CVAD 1912 - Powershell - Add multiple users to diferent applications in Script


sid van

Question

Hello good day,

 

We are running a test environment and I am trying write a short Powershell script to add multiple users and group to different applications.  I get error message while trying to run the script. 

The script is:

 

$AppList = @("Calculator",
"Character Map",
"Notepad"       
"Paint")
$users=@("testlab\user1",
"testlab\user2","testlab\Sales")
$Apps = Get-BrokerApplication  | Where {$_.Name -in $AppList}
$User = Add-BrokerUser  | Where {$_.Name -in $users}
foreach ($App in $Apps) { 
add-BrokerUser  -Application $APP -InputObject@($users)

 

Please help,

 

thanks 

Link to comment

6 answers to this question

Recommended Posts

  • 3
$AppList = @("App1","App2")
$Users = @("Domain\User","Domain\User2")
foreach ($App in $AppList) {
    foreach ($User in $Users) {
        Add-BrokerUser -Name $User -Application $App
    }
}

that is an example bit of code for you to work with - there is no error handling, checking or validation, it's just the basics - you can take it from there

  • Like 4
Link to comment
  • 0

Hi James,

 

I want to add multiple applications to a single user modified your script as follows:

 

$AppList = @("App1","App2","App3","App4")
$Users = @("domain\user1")
foreach ($App in $AppList) {
    foreach ($User in $Users) {
        Add-BrokerUser -Name $Users -Application $AppList
    }
}

 

==========================================================================

Got the following error while running the above scrip.

Please help me.

 

Add-BrokerUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Name'. Specified
method is not supported.
At line:3 char:30
+         Add-BrokerUser -Name $Users -Application $AppList
+                              ~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Add-BrokerUser], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Citrix.Broker.Admin.SDK.AddBrokerUserCommand

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...