Small PowerShell script to retrieve statistics about your current RDS-CAL licenses.
Requirements
PowerShell v2 installed
Run the script on the server where RDS Licensing Manager is installed
Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# Filename of the export $filename = "RDS-CAL-Report.csv" # Import RDS PowerShell Module import-module remotedesktopservices # Open RDS Location Set-Location -path rds: # Remove previous reports (Optional) remove-item RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports\* -Recurse # Create new RDS report $NewReport = new-item -path RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports -Scope DOM -Name Report # Name is automatically generated $NewReportName = $NewReport.name # Get issued licenses $IssuedLicenseCount = get-item RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports\$NewReportName\Win2K8-Win2K8R2\IssuedCount # Count issued licenses $IssuedLicenseCountValue = $IssuedLicenseCount.CurrentValue # Get installed licenses $InstalledLicenseCount = get-item RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports\$NewReportName\Win2K8-Win2K8R2\InstalledCount # Count installed licenses $InstalledLicenseCountValue = $InstalledLicenseCount.CurrentValue # Installed - Issued $Available = $InstalledLicenseCount.CurrentValue - $IssuedLicenseCount.CurrentValue # Show percentage available $AvailablePercent = ($Available /$InstalledLicenseCount.CurrentValue)*100 $AvailablePercent = "{0:N0}" -f $AvailablePercent # Display info Write-host "Installed: $InstalledLicenseCountValue" Write-host "Issued: $IssuedLicenseCountValue" Write-host "Available: $Available [ $AvailablePercent % ]" # Add the information into an Array [System.Collections.ArrayList]$collection = New-Object System.Collections.ArrayList($null) $obj = @{ Installed = $InstalledLicenseCountValue Available = $Available AvailablePercent = $AvailablePercent Issued = $IssuedLicenseCountValue Date = get-date } # Exit RDS location set-location c: # Create PSO Object with the data $collection.Add((New-Object PSObject -Property $obj)); # Export Data into a file $collection | export-csv $filename -NoTypeInformation -Encoding UTF8 |
Results
“Installed”,”Issued”,”Available”,”Date”,”AvailablePercent”
“1205”,”318″,”887″,”6/13/2015 9:06:14 PM”,”74″
You make thgnis so clear. Thanks for taking the time!
Thanks Arno :). Glad it helped.
Hi,
Im getting the following error:
new-item : The path ‘RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports\Report’ does not exist.
At line:1 char:14
+ $NewReport = new-item -path RDS:\LicenseServer\IssuedLicenses\PerUserLicenseRepo …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [New-Item], ItemNotFoundException
+ FullyQualifiedErrorId : ObjectNotFound,Microsoft.PowerShell.Commands.NewItemCommand
Do you have any ideia ?
are you running the script on the RDS server?
Same issue as Nelson on Server 2016? Works fine on a 2008 RDS lic server, I can’t figure out as the env paths are identical on 2016
This must be a bug in RDS 2016?? Anyone confirm?