ADLookups/_UpdateObjectCache.ps1
function _UpdateObjectCache { [CmdletBinding()] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Justification = 'Global to be used again in the same session.')] param ( [Parameter()] [Switch] $Force ) $ADLookups_FindTabInformationTextBox.Text = "Creating Object Cache using $($GetObjectSplat.Server)." $ADLookups_FindTabInformationTextBox.Text = 'Loading Users...' if (!($AllUsers) -or $Force) { switch ($STTSettings.FeatureSettings.Exchange) { $true { $Global:AllUsers = Get-ADUser @GetObjectSplat -Filter * -Properties DistinguishedName, LastBadPasswordAttempt, 'msDS-UserPasswordExpiryTimeComputed', GivenName, Surname, SamAccountName, EmailAddress, Office, OfficePhone, Manager, Enabled, LockedOut, LastLogonDate, PasswordExpired, PasswordLastSet, PasswordNeverExpires, MemberOf, UserPrincipalName, ProxyAddresses, Department, Description, whenCreated, Title, msExchRecipientTypeDetails, msExchHideFromAddressLists } $false { $Global:AllUsers = Get-ADUser @GetObjectSplat -Filter * -Properties DistinguishedName, LastBadPasswordAttempt, 'msDS-UserPasswordExpiryTimeComputed', GivenName, Surname, SamAccountName, EmailAddress, Office, OfficePhone, Manager, Enabled, LockedOut, LastLogonDate, PasswordExpired, PasswordLastSet, PasswordNeverExpires, MemberOf, UserPrincipalName, ProxyAddresses, Department, Description, whenCreated, Title } default { Write-Verbose 'Issue loading Exchange feature setting' $Global:AllUsers = Get-ADUser @GetObjectSplat -Filter * -Properties DistinguishedName, LastBadPasswordAttempt, 'msDS-UserPasswordExpiryTimeComputed', GivenName, Surname, SamAccountName, EmailAddress, Office, OfficePhone, Manager, Enabled, LockedOut, LastLogonDate, PasswordExpired, PasswordLastSet, PasswordNeverExpires, MemberOf, UserPrincipalName, ProxyAddresses, Department, Description, whenCreated, Title } } } $ADLookups_FindTabInformationTextBox.Text += 'Computers...' if (!($AllComputers) -or $Force) { $Global:AllComputers = Get-ADComputer @GetObjectSplat -Filter * -Properties DistinguishedName, CN, Created, Enabled, IPv4Address, LockedOut, LastLogonDate, OperatingSystem, MemberOf } $ADLookups_FindTabInformationTextBox.Text += 'Groups...' if (!($AllGroups) -or $Force) { $Global:AllGroups = Get-ADGroup @GetObjectSplat -Filter * -Properties Description } $ADLookups_FindTabInformationTextBox.Text += 'Service Accounts...' if (!($AllServiceAccounts) -or $Force) { $Global:AllServiceAccounts = Get-ADServiceAccount @GetObjectSplat -Filter * -Properties description } $ADLookups_FindTabInformationTextBox.Text += 'Contacts...' if (!($AllContacts) -or $Force) { $Global:AllContacts = Get-ADObject @GetObjectSplat -Filter { ( objectclass -eq 'contact' ) } -Properties cn, name, mail } _LoadCustomSources $ADLookups_FindTabInformationTextBox.Text += "`nLoading Complete." } |