Private/_UpdateObjectCache.ps1
function _UpdateObjectCache { [CmdletBinding()] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Justification = 'Global to be used again in the same session.')] param ( [Parameter()] [Switch] $Force ) 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 } } } if (!($AllComputers) -or $Force) { $Global:AllComputers = Get-ADComputer @GetObjectSplat -Filter * -Properties DistinguishedName, CN, Created, Enabled, IPv4Address, LockedOut, LastLogonDate, OperatingSystem, MemberOf, Description } if (!($AllGroups) -or $Force) { $Global:AllGroups = Get-ADGroup @GetObjectSplat -Filter * -Properties Description, Mail } if (!($AllServiceAccounts) -or $Force) { $Global:AllServiceAccounts = Get-ADServiceAccount @GetObjectSplat -Filter * -Properties description } if (!($AllContacts) -or $Force) { $Global:AllContacts = Get-ADObject @GetObjectSplat -Filter { ( objectclass -eq 'contact' ) } -Properties cn, name, mail } if ($ADLookups) { _LoadCustomSources $ADLookups_FindTabInformationTextBox.Text += "Loading Complete." } } |