I've list of PW users which needs to be added to UserList.
I've read the help about Add-PWUserToUserList, it requires -InputUser parameter as array of user object.
To get the array of users I tried Get-PWusersbymatch -Email '*@xyz.com' cmdlet but it shows all the users. I do not want to add all of them.
Is there any other cmdlet I can use to make array of user object ?
Any suggestion would be helpful.
Can you try using Get-PWUser?
Example: $XYZUsers = Get-PWUser -EMail "*@xyz.com"
This may only work in 32 bit PowerShell.
shows all the users with email of xyz.com or all the users in the datasource? If you do:
$l1 = Get-PWUsersByMatch -email '*@xyz.com'
$l2 = Get-PWUsersByMatch
are the count's the same? In my testing the first one only returns accounts with email addresses ending with @xyz.com while the second returns a lot more accounts.
Is the list you have in a text file or something?
Also you can use the -Username option with Add-PWUserToUserList if you have those. It accepts an array so this works:
Add-PWUsertoUserList -UserName 'user1','user2','user3'
Thanks Brandon and Kevin for your inputs and my apology for not writing correct situation.
There are almost 500 PW users with account id @xyz.com and I would like to add only 50 pw users to UserList.
The list can be available in csv or xlsx or text format.
If you put each email address in a text file, one per line you can do:
$users = Get-Content -Path 'path/to/file.txt'
Get-PWUsersByMatch -email $users | Add-PWUsersToUserList -UserList 'UserList Name'
Answer Verified By: Aniruddh Chavan