Plugins/PSProfile.ADCompleters.ps1


Register-ArgumentCompleter -CommandName 'Get-ADUser' -ParameterName 'Properties' -ScriptBlock {
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
    @(
        'AccountExpirationDate'
        'accountExpires'
        'AccountLockoutTime'
        'AccountNotDelegated'
        'AddedProperties'
        'adminCount'
        'AllowReversiblePasswordEncryption'
        'AuthenticationPolicy'
        'AuthenticationPolicySilo'
        'BadLogonCount'
        'badPasswordTime'
        'badPwdCount'
        'c'
        'CannotChangePassword'
        'CanonicalName'
        'Certificates'
        'City'
        'CN'
        'co'
        'codePage'
        'comment'
        'Company'
        'CompoundIdentitySupported'
        'Country'
        'countryCode'
        'Created'
        'createTimeStamp'
        'Deleted'
        'Department'
        'Description'
        'directReports'
        'DisplayName'
        'DistinguishedName'
        'Division'
        'DoesNotRequirePreAuth'
        'dSCorePropagationData'
        'EmailAddress'
        'EmployeeID'
        'EmployeeNumber'
        'Enabled'
        'Fax'
        'GivenName'
        'HomeDirectory'
        'HomedirRequired'
        'HomeDrive'
        'HomePage'
        'HomePhone'
        'Initials'
        'instanceType'
        'ipPhone'
        'isDeleted'
        'KerberosEncryptionType'
        'l'
        'LastBadPasswordAttempt'
        'LastKnownParent'
        'lastLogon'
        'LastLogonDate'
        'lastLogonTimestamp'
        'LockedOut'
        'lockoutTime'
        'logonCount'
        'LogonWorkstations'
        'mail'
        'Manager'
        'MemberOf'
        'MNSLogonAccount'
        'mobile'
        'MobilePhone'
        'Modified'
        'ModifiedProperties'
        'modifyTimeStamp'
        'msDS-AuthenticatedAtDC'
        'msDS-User-Account-Control-Computed'
        'mSMQDigests'
        'mSMQSignCertificates'
        'msTSExpireDate'
        'msTSLicenseVersion'
        'msTSLicenseVersion2'
        'msTSLicenseVersion3'
        'msTSManagingLS'
        'Name'
        'nTSecurityDescriptor'
        'ObjectCategory'
        'ObjectClass'
        'ObjectGUID'
        'objectSid'
        'Office'
        'OfficePhone'
        'Organization'
        'otherIpPhone'
        'OtherName'
        'otherTelephone'
        'PasswordExpired'
        'PasswordLastSet'
        'PasswordNeverExpires'
        'PasswordNotRequired'
        'physicalDeliveryOfficeName'
        'POBox'
        'PostalCode'
        'PrimaryGroup'
        'primaryGroupID'
        'PrincipalsAllowedToDelegateToAccount'
        'ProfilePath'
        'PropertyCount'
        'PropertyNames'
        'ProtectedFromAccidentalDeletion'
        'pwdLastSet'
        'RemovedProperties'
        'SamAccountName'
        'sAMAccountType'
        'ScriptPath'
        'sDRightsEffective'
        'ServicePrincipalNames'
        'SID'
        'SIDHistory'
        'SmartcardLogonRequired'
        'sn'
        'st'
        'State'
        'StreetAddress'
        'Surname'
        'telephoneNumber'
        'Title'
        'TrustedForDelegation'
        'TrustedToAuthForDelegation'
        'UseDESKeyOnly'
        'userAccountControl'
        'userCertificate'
        'UserPrincipalName'
        'uSNChanged'
        'uSNCreated'
        'whenChanged'
        'whenCreated'
        'wWWHomePage'
    ) | Where-Object {$_ -like "$wordToComplete*"} | ForEach-Object {
        [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
    }
}

Register-ArgumentCompleter -CommandName 'Get-ADComputer' -ParameterName 'Properties' -ScriptBlock {
    @(
        'AccountExpirationDate'
        'accountExpires'
        'AccountLockoutTime'
        'AccountNotDelegated'
        'AddedProperties'
        'AllowReversiblePasswordEncryption'
        'AuthenticationPolicy'
        'AuthenticationPolicySilo'
        'BadLogonCount'
        'badPasswordTime'
        'badPwdCount'
        'CannotChangePassword'
        'CanonicalName'
        'Certificates'
        'CN'
        'codePage'
        'CompoundIdentitySupported'
        'countryCode'
        'Created'
        'createTimeStamp'
        'Deleted'
        'Description'
        'DisplayName'
        'DistinguishedName'
        'DNSHostName'
        'DoesNotRequirePreAuth'
        'dSCorePropagationData'
        'Enabled'
        'HomedirRequired'
        'HomePage'
        'instanceType'
        'IPv4Address'
        'IPv6Address'
        'isCriticalSystemObject'
        'isDeleted'
        'KerberosEncryptionType'
        'LastBadPasswordAttempt'
        'LastKnownParent'
        'lastLogoff'
        'lastLogon'
        'LastLogonDate'
        'lastLogonTimestamp'
        'localPolicyFlags'
        'Location'
        'LockedOut'
        'logonCount'
        'ManagedBy'
        'MemberOf'
        'MNSLogonAccount'
        'Modified'
        'ModifiedProperties'
        'modifyTimeStamp'
        'msDS-SupportedEncryptionTypes'
        'msDS-User-Account-Control-Computed'
        'Name'
        'nTSecurityDescriptor'
        'ObjectCategory'
        'ObjectClass'
        'ObjectGUID'
        'objectSid'
        'OperatingSystem'
        'OperatingSystemHotfix'
        'OperatingSystemServicePack'
        'OperatingSystemVersion'
        'PasswordExpired'
        'PasswordLastSet'
        'PasswordNeverExpires'
        'PasswordNotRequired'
        'PrimaryGroup'
        'primaryGroupID'
        'PrincipalsAllowedToDelegateToAccount'
        'PropertyCount'
        'PropertyNames'
        'ProtectedFromAccidentalDeletion'
        'pwdLastSet'
        'RemovedProperties'
        'SamAccountName'
        'sAMAccountType'
        'sDRightsEffective'
        'ServiceAccount'
        'servicePrincipalName'
        'ServicePrincipalNames'
        'SID'
        'SIDHistory'
        'TrustedForDelegation'
        'TrustedToAuthForDelegation'
        'UseDESKeyOnly'
        'userAccountControl'
        'userCertificate'
        'UserPrincipalName'
        'uSNChanged'
        'uSNCreated'
        'whenChanged'
        'whenCreated'
    ) | Where-Object {$_ -like "$wordToComplete*"} | ForEach-Object {
        [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
    }
}

Register-ArgumentCompleter -CommandName 'Get-ADGroup' -ParameterName 'Properties' -ScriptBlock {
    @(
        'AddedProperties'
        'CanonicalName'
        'CN'
        'Created'
        'createTimeStamp'
        'Deleted'
        'Description'
        'DisplayName'
        'DistinguishedName'
        'dSCorePropagationData'
        'GroupCategory'
        'GroupScope'
        'groupType'
        'HomePage'
        'instanceType'
        'isDeleted'
        'LastKnownParent'
        'ManagedBy'
        'member'
        'MemberOf'
        'Members'
        'Modified'
        'ModifiedProperties'
        'modifyTimeStamp'
        'Name'
        'nTSecurityDescriptor'
        'ObjectCategory'
        'ObjectClass'
        'ObjectGUID'
        'objectSid'
        'PropertyCount'
        'PropertyNames'
        'ProtectedFromAccidentalDeletion'
        'RemovedProperties'
        'SamAccountName'
        'sAMAccountType'
        'sDRightsEffective'
        'SID'
        'SIDHistory'
        'uSNChanged'
        'uSNCreated'
        'whenChanged'
        'whenCreated'
    ) | Where-Object {$_ -like "$wordToComplete*"} | ForEach-Object {
        [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
    }
}