Private/Get-MMLocalUser.ps1
function Get-MMLocalUser { [CmdletBinding()] param ( #[switch] $User, #[switch] $SyncedUser, #[switch] $RegularUser, #[switch] $SharedUser, [switch] $DisabledUser, #[switch] $EnabledUser, #[switch] $LicensedUser, #[switch] $UnlicensedUser, [string] $CountVariable ) #if(Connect-MMExchangeServer -Auto){ if ($__MMTSession.LocalUserCache.length -gt 1) { # $__MtSession.UserCache = $results # $__MtSession.UserCache.Add($cacheKey, $results) $exchUser = $__MMTSession.LocalUserCache Write-Debug "LocalUserCache found" } else { $exchUser = Get-EXCHUser -ResultSize unlimited Write-Debug "LocalUser: $($exchUser.Count)" $__MMTSession.LocalUserCache = $exchUser } $result = $exchUser if ($DisabledUser) { # Get-UserDisabledMailboxes # Get-User -RecipientTypeDetails UserMailbox | Where-Object { $_.UserAccountControl -like "*accountdisabled*" } #$result | fl *Name*, UserAccountControl, AccountDisabled # UserAccountControl : NormalAccount, DoNotExpirePassword # AccountDisabled : False $result = $result | Where-Object {$_.AccountDisabled -eq $false} } if ($CountVariable) { # https://learn.microsoft.com/de-de/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-7.5 Set-Variable -Name $CountVariable -Value ($result.Count) -Scope 1 #Set-Variable -Name $CountVariable -Value (($result| Measure).Count) -Scope 1 } return $result #} } |