OpsaC - Operating as PowerShell code
published: October 9, 2017 author: Tinu tags: Class - Software categories: PowerShell
Windwos Lizenzierung aus der CimInstance SoftwareLicensingProduct als PowerShell-Class. LicenseStatus 1 = licensed, 0 = not licensed
Class PSSoftwareLicensingProduct{
#region Properties
[object] hidden $SoftwareLicensingProduct = $null
[object]$ID = $null
[object]$ApplicationID = $null
[object]$Name = $null
[object]$Description = $null
[object]$LicenseFamily = $null
[object]$LicenseStatus = $null
[object]$PartialProductKey = $null
[object]$VLActivationInterval = $null
[object]$VLActivationTypeEnabled = $null
[object]$VLRenewalInterval = $null
[object]$RemainingAppReArmCount = $null
#endregion
#region Constructor
PSSoftwareLicensingProduct($Name){
$this.SoftwareLicensingProduct = [PSSoftwareLicensingProduct]::GetSoftwareLicensingProduct($Name)
$this.ID = $this.SoftwareLicensingProduct.ID
$this.ApplicationID = $this.SoftwareLicensingProduct.ApplicationID
$this.Name = $this.SoftwareLicensingProduct.Name
$this.Description = $this.SoftwareLicensingProduct.Description
$this.LicenseFamily = $this.SoftwareLicensingProduct.LicenseFamily
$this.LicenseStatus = $this.SoftwareLicensingProduct.LicenseStatus
$this.PartialProductKey = $this.SoftwareLicensingProduct.PartialProductKey
$this.VLActivationInterval = $this.SoftwareLicensingProduct.VLActivationInterval
$this.VLActivationTypeEnabled = $this.SoftwareLicensingProduct.VLActivationTypeEnabled
$this.VLRenewalInterval = $this.SoftwareLicensingProduct.VLRenewalInterval
$this.RemainingAppReArmCount = $this.SoftwareLicensingProduct.RemainingAppReArmCount
}
#endregion
#region Methods
[object]static GetSoftwareLicensingProduct($Name){
$ret = @{}
$objCimInstance = Get-CimInstance SoftwareLicensingProduct | Where-Object {
($_.LicenseStatus -eq 1 -and $_.Name -match $Name)
}
$ret.ID = $objCimInstance.ID
$ret.ApplicationID = $objCimInstance.ApplicationID
$ret.Name = $objCimInstance.Name
$ret.Description = $objCimInstance.Description
$ret.LicenseFamily = $objCimInstance.LicenseFamily
$ret.LicenseStatus = $objCimInstance.LicenseStatus
$ret.PartialProductKey = $objCimInstance.PartialProductKey
$ret.VLActivationInterval = $objCimInstance.VLActivationInterval
$ret.VLActivationTypeEnabled = $objCimInstance.VLActivationTypeEnabled
$ret.VLRenewalInterval = $objCimInstance.VLRenewalInterval
$ret.RemainingAppReArmCount = $objCimInstance.RemainingAppReArmCount
return $ret
}
#endregion
}
New-Object PSSoftwareLicensingProduct('windows')