Licensing of migRaven.24 / 7: Calculation of the relevant AD accounts

The following Powershell script must be used to correctly read out the relevant user accounts (registered within the last 90 days):

All active accounts are counted. All domain controllers are queried for this. Note for you, if the values ​​do not match, the synchronization of the DCs with each other should be checked.

Start the script in a Powershell Console on one of your domain controllers.

cls
$domain_user_all = (Get-ADUser -Filter *).Count
$domain_user_active = (Get-ADUser -LDAPFilter "(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))").count
$domain_user_login_90days = (Get-ADUser -Filter *).Count - (Get-ADUser -Filter * -Properties LastLogonTimeStamp | select @{Name="LastLogonTimeStamp";Expression={([datetime]::FromFileTime($_.LastLogonTimeStamp))}} | where {$_.LastLogonTimeStamp -lt (Get-Date).AddDays(-90)}).Count
$domain_user_HealthMailbox = (Get-ADUser -Filter "name -like 'HealthMailbox*' ").count
Write-Host "Domaincontrollern werden abgefragt . . ."
Write-Host ""
Get-ADDomainController -Filter * |Select Name |% { $_.Name+": "+ ((Get-ADUser -Server $_.Name -Filter *).Count - (Get-ADUser -Server $_.Name -Filter * -Properties LastLogonTimeStamp | select @{Name="LastLogonTimeStamp";Expression={([datetime]::FromFileTime($_.LastLogonTimeStamp))}} | where {$_.LastLogonTimeStamp -lt (Get-Date).AddDays(-90)}).Count) }
Write-Host ""
Write-Host "Anzahl aller Accounts: " $domain_user_all
Write-Host ""
Write-Host "Anzahl aller aktiven Accounts: " $domain_user_active
Write-Host ""
Write-Host "Anzahl der Benutzeraccounts, die sich in den letzten 90 Tage angemeldet haben: " $domain_user_login_90days
Write-Host ""
Write-Host "aktive HealthMailboxen: " $domain_user_HealthMailbox
Write-Host ""
Write-Host "Anzahl der Benutzeraccounts (ohne aktive HealthMailboxen), die sich in den letzten 90 Tage angemeldet haben: " ($domain_user_login_90days - $domain_user_HealthMailbox)
Write-Host "------------------------------------------------------------------------------------------------------------------"
Write-Host "Anzahl der berechneten Konten: " ($domain_user_login_90days - $domain_user_HealthMailbox) -ForegroundColor yellow
Write-Host ""
Get-ADDomainController -Filter * |Select Name |% { (Get-ADUser -Server $_.Name -Filter * -Properties LastLogonTimeStamp | select samAccountName,@{Name="LastLogonTimeStamp";Expression={([datetime]::FromFileTime($_.LastLogonTimeStamp))}} | where {$_.LastLogonTimeStamp -gt (Get-Date).AddDays(-90)}) | Out-File "Benutzerdatei $($_.Name).txt" ; write-Host "Benutzerdatei $($_.Name).txt ist erstellt (internen Gebrauch des Kunden)" }
Write-Host ""

Permanent link to this post: https://help.migraven.com/berechnung-der-relevanten-ad-konten-in-migraven-24-7/