Autocomplete Parameters
You can set some parameters to autocomplete, which is to say prompt the user to select from available choices which match the information they have already entered. For instance, when entering a user principal name as a parameter, the user can type FOR and be prompted to select Henry Ford, Alan Forbes, or Michelle Fornsted. In many cases this is easier and more reliable than typing out the whole name.
Set the parameter with the option values of AutoPopulate and MappedField, as shown below:
param(
[AutoPopulate(ObjectType='groups', MappedField='group_name')][string] $GroupName,
[AutoPopulate(ObjectType='users', MappedField='user_principal_name')][string] $UserPrincipalName
)
ObjectType is a required parameter but MappedField is optional. In most cases, PowerScripts will correctly deduce the mapped field but if you find it is not pulling the data you expect use this table below to link the data you want with the underlying database field it should pull it’s values from.
Device Type | Object Type | Mapped Field |
Office 365 | mailboxes | display_name |
Office 365 | mailboxes | sam_account_name |
Office 365 | mailboxes | primary_smtp_address |
Office 365 | mailboxes | identity |
Office 365 | users | user_principal_name |
Office 365 | users | display_name |
Office 365 | groups | group_name |
Office 365 | teams | display_name |
Exchange | mailboxes | display_name |
Exchange | mailboxes | sam_account_name |
Exchange | mailboxes | primary_smtp_address |
Exchange | mailboxes | identity |
Exchange | mailboxes | distinguished_name |
Active Directory | users | name |
Active Directory | users | sam_account_name |
Active Directory | users | user_principal_name |
Active Directory | users | distinguished_name |
Active Directory | groups | name |
Active Directory | groups | sam_account_name |
Active Directory | groups | distinguished_name |