sid van Posted November 25, 2021 Share Posted November 25, 2021 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
3 James Kindon Posted November 26, 2021 Share Posted November 26, 2021 $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 4 Link to comment
1 CarlStalhood Posted May 15, 2023 Share Posted May 15, 2023 I suspect that $AppList should be $App. And $Users should be $User. Add-BrokerUser -Name $User -Application $App 1 Link to comment
0 sid van Posted November 28, 2021 Author Share Posted November 28, 2021 Hi James.. Thank you ... I can use that code and add validation checking.. Have a nice day Link to comment
0 Iftekhar Ahmed Posted May 14, 2023 Share Posted May 14, 2023 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
0 James Kindon Posted May 16, 2023 Share Posted May 16, 2023 yep, just use the original code and include a single user in the array Link to comment
0 Iftekhar Ahmed Posted May 17, 2023 Share Posted May 17, 2023 Hi Carl and James, Its worked, Thank you very much for your support. Link to comment
Question
sid van
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
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 accountSign in
Already have an account? Sign in here.
Sign In Now