-
Notifications
You must be signed in to change notification settings - Fork 17
/
rds-lic-per-device-cal-enumerate.ps1
72 lines (58 loc) · 1.55 KB
/
rds-lic-per-device-cal-enumerate.ps1
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<#
.SYNOPSIS
script to enumerate Windows RDS perdevice cals
.DESCRIPTION
script to enumerate Windows RDS perdevice cals
tested on Windows 2008 r2 and 2012 RDS License server
.NOTES
File Name : rds-lic-per-device-cal-enumerate.ps1
Author : jagilber
Version : 160418
History : 160414 original
.EXAMPLE
Example: .\rds-lic-per-device-cal-enumerate.ps1
#>
$ErrorActionPreference = "Stop"
$activeLicenses = @()
$error.Clear()
cls
write-host "----------------------------------"
write-host "key packs:"
$keyPacks = Get-WmiObject Win32_TSLicenseKeyPack
foreach($keyPack in $keyPacks)
{
write-host "----------------------------------"
$keyPack
}
write-host "----------------------------------"
write-host "----------------------------------"
$licenses = get-wmiobject Win32_TSIssuedLicense
if($licenses -eq $null)
{
write-host "no issued licenses. returning"
return
}
#licenseStatus = 4 = revoked, 1 = temp, 2 = permanent
$activelicenses = @($licenses)
if($activeLicenses.Count -ge 1)
{
foreach ($lic in $activeLicenses)
{
if(($keypacks | Where { $_.KeyPackId -eq $lic.KeyPackId -and $_.ProductType -eq 0 }))
{
write-host "----------------------------------"
$lic
write-host "----------------------------------"
}
else
{
write-host "license is not per device"
}
}
}
else
{
write-host "no licenses to enumerate"
}
write-host "----------------------------------"
write-host "finished"