![]() ![]() The comboboxes are type 2, populated using Validation is not a concern, users cannot free type their own selection. # do somthing with the group name in $val Throw "Invalid Group Name $($NewUserIDEntryBox.Text)" # do something here so the value gets corrected! ( $val.Length -le $MaxAllowedLength) -and If ( -NOT ( $val.Length -ge $MinAllowedLength) -and $val = ($NewUserIDEntryBox.Text).trim() # remove whitespace from both ends of the value $MaxAllowedLength = 50 # maximum length of a group name ![]() $MinAllowedLength = 10 # minimum length of a group name $Begin = "^$" # allowed characters to end a group name Something like this maybe: $allowed = "^+$" # set of permissible characters in group names If the user is allowed to either pick an item from a predefined list or enter their own value then you should be doing come data validation before you use the data. You don't say what style of combo box is being used. ![]() I can't paste the entire script in here, it is several thousand lines long (most of this is the code for the GUI) and includes images and recovery data How can I tell this to use a $null value if the combobox selection is blank? I have tried using if statements but no matter how I try to add this it just creates a new error and stops the script. The code used to add the new account to a group is Add-ADGroupMember -Identity $NewUserSecurityGroupsComboBox1.Text -Members $NewUserIDEntryBox.Text -confirm:$false So it's saying it can't find a group with a blank name, and it does this for each blank combobox, so if a user is being added to 1 security group and nothing else it gives 7 of these errorsĪs I said, this doesn't stop anything, but just for the sake of my OCD I want it to skip the step if no group is selected from the combobox. However, if an account is not being added to 4 groups it gives an error, it still creates the account but it tells me Add-ADGroupMember : Cannot find an object with identity: '' under: 'DC=xxx,DC=xxxxxxxxxxx,DC=com'. The form works, accounts are created and logic to add users to various default groups based on other criteria works as intended. As part of this I have included 4 combo boxes listing all the security groups and 4 more listing all our distribution groups. I have created a form for helpdesk staff using Sapien PowerShell Studio, the form is used to create new user accounts. ![]()
0 Comments
Leave a Reply. |