Closed jimr3105 closed 2 years ago
Please post the error you get and an example of the content of userlist.txt
I ran this as a segment from ISE. Not shown is the token request and response:
PS C:\scripts\>
$password = "secretpassword"
$userlist=(get-content userlist.txt)
foreach ($user in $userlist) {
$GuacParameters = @{
"username"= $user
"password"= $password
"attributes"= @{
"disabled"= ""
"expired"= ""
"access-window-start"= ""
"access-window-end"= ""
"valid-from"= ""
"valid-until"= ""
"timezone"= ""
"guac-full-name"= ""
"guac-organization"= ""
"guac-organizational-role"= ""
}
}
write-host ". . . . .Adding $user to Guacamole Server"
New-GuacUser -DataSource mysql -Parameters $GuacParameters
start-sleep -seconds 5
} # end of foreach ($user in $userlist)
. . . . .Adding 2298BReal to Guacamole Server
WARNING: The remote server returned an error: (500) Internal Server Error.
False
. . . . .Adding 2298OBTrice to Guacamole Server
WARNING: The remote server returned an error: (500) Internal Server Error.
False
. . . . .Adding 2298ADrake to Guacamole Server
WARNING: The remote server returned an error: (500) Internal Server Error.
False
. . . . .Adding 2298MEnim to Guacamole Server
WARNING: The remote server returned an error: (500) Internal Server Error.
False
. . . . .Adding 2298DHowser to Guacamole Server
WARNING: The remote server returned an error: (500) Internal Server Error.
False
PS C:\scripts\>
The file userlist.txt is created by hand in Notepad++. In the future, it will be created automatically by powershell while building AD accounts from a CSV file (the leading number is created based on input from the user, and then the value used as a Windows pre2kname is generated from there and written to a text file... userlist.txt.
the userlist.txt for this test contained:
2298BReal
2298OBTrice
2298ADrake
2298MEnim
2298DHowser
Any feedback on this error?
This is what I capture in wireshark when I add a single user via New-GuacUser (it works)
And this is what I capture in wireshark when I add multiple users via a foreach loop (as described earlier)
hello jim 3105. Try putting the variables between "". "username"="$user" "password"="$password" You should also keep the $Parameters parameter and not how you put $GuacParameters.
Hello @jimr3105
@mgrodrigues001 Is right, you need to put $password and $user in double quotes and It will work (I've try)
The commands work independently...if I use the command "New-GuacUser -DataSource mysql -Parameters $GuacParameters" to create a single user, it works fine. I start getting the error when I put the command into a foreach loop and pull in names from a text file.
Other functions, like "Add-GuacUserConnection" in a foreach loop work just fine.
$password = "secretpassword" $userlist=(get-content userlist.txt) foreach ($user in $userlist) { $GuacParameters = @{ "username"= $user "password"= $password "attributes"= @{ "disabled"= "" "expired"= "" "access-window-start"= "" "access-window-end"= "" "valid-from"= "" "valid-until"= "" "timezone"= "" "guac-full-name"= "" "guac-organization"= "" "guac-organizational-role"= "" } } write-host ". . . . .Adding $user to Guacamole Server" New-GuacUser -DataSource mysql -Parameters $GuacParameters }