Public/Application/Get-QuickBooksLicense.ps1
|
FUNCTION Get-QuickBooksLicense { <# .SYNOPSIS Retrieves a list of license information used to install QuickBooks on the computer. .DESCRIPTION Retrieves a list of license information used to install QuickBooks on the computer. .EXAMPLE Get-QuickBooksLicense .EXAMPLE Get-QuickBooksLicense .NOTES Get-QuickBooksLicense #> [CmdletBinding()] PARAM ( ) #!PS #Reads the QuickBooks Registration File and navigates into the XML nodes where the registration info lies (Skips over the unnecessary information) $qbInstallations = [XML](Get-Content "C:\ProgramData\COMMON FILES\INTUIT\QUICKBOOKS\qbregistration.dat") | select-xml "//QUICKBOOKSREGISTRATION" | ForEach-Object { $_.node.Version } #Table of all QB Edition unique names. Used to map the registration data to the proper QuickBooks Edition. #The following applies to all version of QuickBooks Enterprise other than the exceptions listed below. #With the Exception of Accountant and General Purpose all editions of QuickBooks Enterprise make 2 entries in the registration file. #General Purpose is used primarily as a "Core" edition of QuickBooks Enterprise. Because of this, there are no field specific features (Pseudo Extensions) installed like with other Editions. #Accountant has a dedicated installer and therefore a "Core" is not needed as it bundled in. #The first entry has the "Flavor Name" of "bel" (General Purpose which always gets installed and is used as a "Core"). #The second entry has a "Flavor Name" that begins with "bel" and has a shorthand for the edition chosen after installation. #An example is the Contractor Edition. The "Flavor Name" for Contractor as can be seen below is "belcontractor". #This is why a good way of thinking of the different Editions of QuickBooks as Extensions. $qbEditions = @( @{ "Version" = "pro" "Name" = "QuickBooks Pro" }, @{ "Version" = "superpro" "Name" = "QuickBooks Premier" }, @{ "Version" = "accountant" "Name" = "QuickBooks Premier Accountant" }, @{ "Version" = "bel" "Name" = "QuickBooks Enterprise General Edition" }, @{ "Version" = "belretail" "Name" = "QuickBooks Enterprise Retail Edition" }, @{ "Version" = "belcontractor" "Name" = "QuickBooks Enterprise Contractor Edition" }, @{ "Version" = "belwholesale" "Name" = "QuickBooks Enterprise Wholesale Edition" }, @{ "Version" = "belnonprofit" "Name" = "QuickBooks Enterprise Non-Profit Edition" }, @{ "Version" = "belprofessional" "Name" = "QuickBooks Enterprise Professional Edition" }, @{ "Version" = "belacct" "Name" = "QuickBooks Enterprise Accountant" } ) #Array used to hold all licensing information while it is being parsed $licenseArray = New-Object System.Collections.Arraylist #Loop over every QuickBooks registration entry and parse the appropriate information foreach ($qbInstallation in $qbInstallations) { $year = [INT]($qbInstallation.number -replace "\.0", "") - 10 foreach ($qbLicense in $qbInstallation.flavor) { $licenseData = [PSCustomObject]@{ "Year" = $year "Edition" = ($qbEditions | Where-Object { $_.Version -eq $qbLicense.name }).name "ProductNumber" = $qbLicense.licensenumber.Trim() "LicenseNumber" = $qbLicense.installid.Trim() } $licenseArray.Add($licenseData) | Out-Null } } #Print out the final licensing information and remove General Purpose entries from the list if there is a specialty version installed $licenseArray = $licenseArray | Sort-Object "License Number" -unique | Sort-Object Year, Editions RETURN $licenseArray } |