Last active
January 24, 2022 18:12
-
-
Save corneliusdavid/6cdeae326454caa04c2c10ac55035486 to your computer and use it in GitHub Desktop.
PowerShell script that calls WMI services on an RDS server to generate the number of reported RDS SALs issues by the server; creates a log file with the one line summary; runs daily.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reference: https://philpug.com/2019/12/15/automating-rds-reports-for-windows-2016-and-2019/ | |
Import-Module RemoteDesktopServices | |
Set-Location -Path rds: | |
Remove-Item RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports\* -Recurse | |
# note: this takes a LONG time if you have a lot of old reports | |
# generate the license report and return the filname generated | |
$fileName = (Invoke-WmiMethod Win32_TSLicenseReport -Name GenerateReportEx).FileName | |
# update to store in a location of your choosing | |
$LogFile = "C:\RDSUsageLogs\$filename.log" | |
# generatethe report and get the summary | |
$summaryEntries = (Get-WmiObject Win32_TSLicenseReport | Where-Object FileName -eq $filename).FetchReportSummaryEntries(0,0).ReportSummaryEntries | |
$Report = "{0}, Issued RDS Licenses: {1}" -f $($filename), $($summaryEntries.IssuedLicenses) | |
$Report > $LogFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you manage Remote Desktop Services and use Per-User licensing and have any variability in the number of users, this script can help you by automating the report generation to give you an accurate issued-license count.