Kaseya Community

Windows & Office License Validation & Kaseya

  • I put this script together with a little tip from one of our customers in Australia. It will identify the status of any WGA-enabled Windows or Office license key (E.g. if it is pirated and a blocked VLK, you'll be able to find out.)



    Perhaps this is something you could use for your own prospects who are trying your service if they happen to care if they're using illegal software.



    I have never seen any software that can do this, so if there are better business cases for it I'd love to hear them from YOU guys in the field!



    I'll just paste the standalone script below for you to import.



    I will update the thread later with screenshots of sample reports to go along with the script.



    Someone please fix my vbscript, I know the code isn't the best.



    For those who didnt see it mentioned in my NMAP network scan thread, I'm a Sales Engineer for Kaseya and any scripts I put together are done on my own accord and are nothing official from the company. I would have loved to see us add this to our basic system audit functionality but of course I'm biased towards my own scripts Wink



    Script Name: Validate Windows & Office License

    Script Description: This script validates Windows and Office licenses.

    Run the "License Validation" report under Logs to see the license statuses.



    You will need to place this once in your VSASharedFiles folder on your Kaseya Server

    mgadiag.exe: http://go.microsoft.com/fwlink/?linkid=56062



    If you require more detail about the results (e.g. "Unsupported OS") please see the following website or contact Microsoft:



    http://www.microsoft.com/genuine/downloads/FAQ.aspx



    Thanks to Barry Harriman at Linkware in Australia for the initial idea!



    Benjamin Lavalley

    Senior Sales Engineer, Kaseya

    benjamin.lavalley@kaseya.com





    IF True

    THEN

    Get URL

    Parameter 1 : http://go.microsoft.com/fwlink/?linkid=52012

    Parameter 2 : #vAgentConfiguration.agentTempDir#\mgadiag.exe

    Parameter 3 : 3

    OS Type : 13

    Write File

    Parameter 1 : #vAgentConfiguration.agentTempDir#\mgadiag.exe

    Parameter 2 : VSASharedFiles\MGADiag.exe

    OS Type : -1

    Execute File

    Parameter 1 : #vAgentConfiguration.agentTempDir#\mgadiag.exe

    Parameter 2 : /f #vAgentConfiguration.agentTempDir#\licenseresults.txt

    Parameter 3 : 3

    OS Type : 13

    Get File

    Parameter 1 : #vAgentConfiguration.agentTempDir#\licenseresults.txt

    Parameter 2 : licenseresults.txt

    Parameter 3 : 1

    OS Type : 13

    Get URL

    Parameter 1 : http://files.kaseya.com/sftp/readlicense.vbs

    Parameter 2 : #vAgentConfiguration.agentTempDir#\readlicense.vbs

    Parameter 3 : 3

    OS Type : 13

    Execute File

    Parameter 1 : %windir%\system32\wscript.exe

    Parameter 2 : "#vAgentConfiguration.agentTempDir#\readlicense.vbs" #vAgentConfiguration.agentTempDir#\licenseresults.txt

    Parameter 3 : 3

    OS Type : 13

    Get Variable - (Continue on Fail)

    Parameter 1 : 0

    Parameter 2 : HKEY_LOCAL_MACHINE\SOFTWARE\Kaseya\Kaseya Agent\WindowsLicenseValid

    Parameter 3 : windowsstatus

    OS Type : 13

    Get Variable - (Continue on Fail)

    Parameter 1 : 0

    Parameter 2 : HKEY_LOCAL_MACHINE\SOFTWARE\Kaseya\Kaseya Agent\WindowsLicenseType

    Parameter 3 : licensetype

    OS Type : 13

    Get Variable - (Continue on Fail)

    Parameter 1 : 0

    Parameter 2 : HKEY_LOCAL_MACHINE\SOFTWARE\Kaseya\Kaseya Agent\OfficeLicenseValid

    Parameter 3 : officestatus

    OS Type : 13

    Get Variable - (Continue on Fail)

    Parameter 1 : 0

    Parameter 2 : HKEY_LOCAL_MACHINE\SOFTWARE\Kaseya\Kaseya Agent\Officename

    Parameter 3 : officename

    OS Type : 13

    Get Variable - (Continue on Fail)

    Parameter 1 : 0

    Parameter 2 : HKEY_LOCAL_MACHINE\SOFTWARE\Kaseya\Kaseya Agent\WindowsName

    Parameter 3 : windowsName

    OS Type : 13

    Get Variable - (Continue on Fail)

    Parameter 1 : 0

    Parameter 2 : HKEY_LOCAL_MACHINE\SOFTWARE\Kaseya\Kaseya Agent\WindowsKey

    Parameter 3 : windowskey

    OS Type : 13

    Write Script Log Entry - (Continue on Fail)

    Parameter 1 : Windows License Key Status: #windowsstatus#

    OS Type : 13

    Write Script Log Entry - (Continue on Fail)

    Parameter 1 : Windows License Key Type: #licensetype#

    OS Type : 13

    Write Script Log Entry - (Continue on Fail)

    Parameter 1 : Windows License Key: #windowskey#

    OS Type : 13

    Write Script Log Entry - (Continue on Fail)

    Parameter 1 : Windows License Key Version: #vMachine.OsType# #vMachine.OsInfo#

    OS Type : 13

    Write Script Log Entry - (Continue on Fail)

    Parameter 1 : Office License Key Status: #officestatus#

    OS Type : 13

    Write Script Log Entry - (Continue on Fail)

    Parameter 1 : Office License Key Version: #officename#

    OS Type : 13

    Get File

    Parameter 1 : #vAgentConfiguration.agentTempDir#\licenseresults.txt

    Parameter 2 : ..\Docs\licenseresults.txt

    Parameter 3 : 1

    OS Type : 13

    Write Script Log Entry

    Parameter 1 : Mac OS X license validation not supported.

    OS Type : 12

    ELSE





    Legacy Forum Name: Windows & Office License Validation & Kaseya,
    Legacy Posted By Username: Benjamin.Lavalley@kaseya.com
  • ***********

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: CeruleanBlue
  • Anyone gooten this to run yet?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: boudj
  • CeruleanBlue
    Tip: Wrapping scripts in CODE tags fixes some spacing issues. See: licenseresults .txt && readlicense.vbs


    Script Name: Validate Windows & Office License
    Script Description: This script validates Windows and Office licenses.
    Run the "License Validation" report under Logs to see the license statuses.
    ........


    Fixed my original post -- thanks!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Benjamin.Lavalley@kaseya.com
  • Sample Exec Report:




    Sample detail report for an Invalid Windows/Office license:




    Associated "Change Rows"




    How to create detail report:


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Benjamin.Lavalley@kaseya.com
  • I modified the script a bit to generate a ticket if a blocked VLK is found. It's working beautifully. Unfortunately we found a few pc's that our clients acquired with such keys on them. They of course will be replaced shortly. Thanks so much for this!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: kroberts210
  • kroberts210
    I modified the script a bit to generate a ticket if a blocked VLK is found. It's working beautifully. Unfortunately we found a few pc's that our clients acquired with such keys on them. They of course will be replaced shortly. Thanks so much for this!


    That is what I like to hear! Thanks for the feedback.

    I'll tweak the scripts and re-post them so they create event log entries if bad license keys are found.

    I have to tweak the VB script when I get the time. It isn't consistently detecting the version of Office that is installed.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Benjamin.Lavalley@kaseya.com
  • I've just tested this and I must say, this is AMAZINGLY awesome. So very very cool.

    Many thanks Benjamin!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: LANWorx
  • Benjamin,

    Very cool script, thansk for sharing.

    And, it is also great to see some Kaseya staff participating in the Forum!!

    I would like to ask a question about the script... are both STEP1 and STEP2 required? It looks like STEP1 downloads mgadiag.exe from microsoft.com, and it looks like STEP2 downloads mgadiag.exe from the kserver.

    Any issue with deleting one of these steps?

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • Step two is set to run on 'Disable Step'.

    Does this mean this step is skipped?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: LANWorx
  • lwolf
    Benjamin,

    Very cool script, thansk for sharing.

    And, it is also great to see some Kaseya staff participating in the Forum!!

    I would like to ask a question about the script... are both STEP1 and STEP2 required? It looks like STEP1 downloads mgadiag.exe from microsoft.com, and it looks like STEP2 downloads mgadiag.exe from the kserver.

    Any issue with deleting one of these steps?

    Lloyd


    You should put mgadiag and the VB script on your server in case MS ever takes down the links or the agent for some reason cannot connect directly to the internet (e.g. proxy). I leave the "write file" there so you can easily do just that.

    I've been meaning to post these things for a long time and decided to make a real effort this week to do it. It isn't that I don't want to post here, it is just that we're all extremely busy.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Benjamin.Lavalley@kaseya.com
  • This is a fantastic script, thank you for sharing it with us.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: captplanit
  • Thank you for your time and effort in building these great scripts!


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: nevesis
  • Great script, it works great... most of the time and then it fails in step 2. My step 2 is the original step 3 as I took the first step, download the file from url, out. Anybody have ideas on this?

    It is executing the following:
    #vAgentConfiguration.agentTempDir#\mgadiag.exe
    /f #vAgentConfiguration.agentTempDir#\licenseresults.txt
    execute as system and wait for completion

    I tried changing the script and saving the file to a different location, basically re-wrote half the script and it still fails at that step.
    When I say it fails, so far this has occured on around 10 of 100 machines so a 90% success is still outstanding.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JonJohnston
  • What is the error written to the script log when it fails? Is it possible that these machines haven't finished completely writing the file to disk before the next script command starts trying to execute? I've run into this a few times. Might try adding a pause for a few seceonds between the "Write File" and the "Execute" to allow for any write and scan operations to finish. But again this is just a guess without knowing any of the errors.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: kroberts210