Active Directory and DataGridViews

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: Active Directory and DataGridViews

Post by localpct »

Should be lots of fun with all of these properties and figuring our how to use -eq instead of -match

'BadLogonCount',
'badPasswordTime',
'badPwdCount',
'CanonicalName',
'City',
'CN',
'createTimeStamp',
'Deleted',
'Department',
'directReports',
'EmailAddress',
'EmployeeNumber',
'employeeType',
'GivenName',
'HomeDirectory',
'HomedirRequired',
'HomeDrive',
'HomePage',
'isDeleted',
'LastBadPasswordAttempt',
'lastLogon',
'location',
'mail',
'mailNickname',
'Manager',
'Modified',
'modifyTimeStamp',
'Name',
'objectSid',
'OfficePhone',
'PasswordExpired',
'PasswordLastSet',
'POBox',
'SID',
'Title',
'TrustedForDelegation',
'TrustedToAuthForDelegation',
'uid',
'UseDESKeyOnly',
'userAccountControl',
'UserPrincipalName',
'uSNChanged',
'uSNCreated',
'whenChanged',
'whenCreated'
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Active Directory and DataGridViews

Post by jvierra »

You have to use match. It is matching the column contents and not the name. Using eq would create a very large, slow and cumbersome block of code. Just join the list with '|' and use it in the match.

$_.Name -match $list

You can also use an array.

If $list is an array then:
$_.Name -in $list

A comma separated list can be split and rejoined.

An array can be used as "-Properties" and as a filter with "-in".
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked