Kaseya Community

Want to create Custom Script to get the Office License info captured

  • Hi,

    I have found a script/ procedure for Office 2013 and updating Windows Activation status but that not all I'm seeking for.

    I have been struggling to create a custom procedure where I can execute these shell commands one by one wherever it find the ospp.vbs file:

    cscript "C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" /dstatus >>C:\ALworking\MSOL.txt
    cscript "C:\Program Files\Microsoft Office\Office14\ospp.vbs" /dstatus >>C:\ALworking\MSOL.txt
    cscript "C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" /dstatus >>C:\ALworking\MSOL.txt
    cscript "C:\Program Files\Microsoft Office\Office15\ospp.vbs" /dstatus >>C:\ALworking\MSOL.txt
    cscript "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" /dstatus >>C:\ALworking\MSOL.txt
    cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /dstatus >>C:\ALworking\MSOL.txt


    Depending on different versions of Microsoft Office version, the directory path is not fixed so I tried to use testFileInDirectoryPath, testFile existence on that path then execute the related shell command. If it can not locate the file or it doesn't exists using Else move to second location and so on...

    I was able to get them executed one by one and get the output transfered to a .txt file and get it copied on a variable defined by the procedure to be sent as a captured info via email but .txt file only gets updated by the last last shell command and returns error of File not found.

    Please help/ assist me to create a procedure to call OSPP.vbs script as a shell command cscript "C:\Program Files (x86)\Microsoft Office\OfficeXX\ospp.vbs" /dstatus >>C:\ALworking\MSOL.txt

    OfficeXX because we can not tell which office is installed on the machine and we want to cover every version on a single procedure. once *License Status* is captured, we would like the admin to be notified and same thing should gets updated to Audit-System Info-Custom Field.

    The shell command will give this output:

    Microsoft (R) Windows Script Host Version 5.812
    Copyright (C) Microsoft Corporation. All rights reserved.

    ---Processing--------------------------
    ---------------------------------------
    PRODUCT ID: XXXXX-XXXXX-XXXXX-AA876
    SKU ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX36
    LICENSE NAME: Office 16, Office16ProPlusVL_MAK edition
    LICENSE DESCRIPTION: Office 16, RETAIL(MAK) channel
    LICENSE STATUS:  ---LICENSED---
    Last 5 characters of installed product key: P9XYB
    ---------------------------------------
    ---------------------------------------
    ---Exiting-----------------------------

  • Procedure Office License test.xml

    I have attached my test procedure for reference.

  • I suggest you do some searches of these forums. This has been discussed many times. e.g. community.kaseya.com/.../94436.aspx

  • Thanks Craig but I already did searched the entire forum and you can blame my lame keywords for the search results that I have not found anything relevant to my requirement. As I mentioned and the link you've provided is specific to Office 2013. And .exe has to be imported to the kserver which we can skip if shellcommand can be executed in right order.

    I need assistance and if someone can verify the procedure we tried to create, as it executes the shell commands one by one and overwrite the same output file and mostly it generates the error:

    Microsoft (R) Windows Script Host Version 5.812
    Copyright (C) Microsoft Corporation. All rights reserved.

    Input Error: Can not find script file "C:\Program Files\Microsoft Office\Office16\ospp.vbs".

    Is there a way that I we can define in a procedure to look for the OSPP.vbs file first and wherever it gets located, execute it from that directory path using the same set of arguments to capture the license info [not just the license number, but the activation status as well]?

    Following commands needs to be triggered only if the said OSPP.vbs file is found on directory path

    cscript "C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" /dstatus >>C:\kworking\MSOL.txt
    cscript "C:\Program Files\Microsoft Office\Office14\ospp.vbs" /dstatus >>C:\kworking\MSOL.txt
    cscript "C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" /dstatus >>C:\kworking\MSOL.txt
    cscript "C:\Program Files\Microsoft Office\Office15\ospp.vbs" /dstatus >>C:\kworking\MSOL.txt
    cscript "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" /dstatus >>C:\kworking\MSOL.txt
    cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /dstatus >>C:\kworking\MSOL.txt

    And if I can include the agent info or machine info on the same output file or email content, that will be a great help as well as it will allow us to isolate the info we will getting on the email.

  • , We will work on this script for you.    I think parsing it out will take too much time, and also it does not appear as if the output actually contains a key.  (Kaseya tries to pull that in the audit, but O365 doesn't show).    I have asked our script guru to create an option to upload the result file to the Kserver, Email it to you, and also write it to the Agent Procedure Log , so you can report on it.

    In my testing, it appears you can have multiple licenses,  one "LICENSED" and others not.    We are only going to pay attention to the first one.

    Once we have it written, I will post a link for you.

    Thanks for the good idea!

  • You can accomplish what I *think* you are looking for with a powershell one-liner, assuming that the file will only exist in *one* of those locations.

    gci -Path 'C:\Program Files (x86)\Microsoft Office\', 'C:\Program Files\Microsoft Office\' -Recurse -ErrorAction SilentlyContinue -include ospp.vbs | foreach { $_.FullName}

    If you grab the output of that into a variable it *should* be the exact full path to the OSPP.VBS that is found.

  • Thanks Jonathan, I was actually able to create a batch file and get it copied over to #vAgentConfiguration.AgentTempDir# to be executed and to create the Output file from where it started to capture the info on an email.

    Now the next challenge is, on a single site we have multiple machines with different versions of Office installed.

    Example:

    Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

     

    ---Processing--------------------------

    ---------------------------------------

    SKU ID: XXXXXXXX-XXXX-XXXX-XXXX-b853aeb6e210

    LICENSE NAME: Office 14, OfficeProfessional-Retail edition LICENSE DESCRIPTION: Office 14, RETAIL channel LICENSE STATUS: ---NOTIFICATIONS--- ERROR CODE: 0xC004F00F ERROR DESCRIPTION: The Software Licensing Service reported that the hardware ID binding is beyond the level of tolerance.

    Last 5 characters of installed product key: D7TC8

    ---------------------------------------

    ---------------------------------------

    ---Exiting-----------------------------

    Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

     

    Input Error: Can not find script file "C:\Program Files\Microsoft Office\Office14\ospp.vbs".

    Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

     

    ---Processing--------------------------

    ---------------------------------------

    SKU ID: XXXXXXXX-XXXX-XXXX-XXXX-4031f5338cb2

    LICENSE NAME: Office 15, OfficeStandardVL_MAK edition LICENSE DESCRIPTION: Office 15, RETAIL(MAK) channel LICENSE STATUS: ---LICENSED--- Last 5 characters of installed product key: X4QBG

    ---------------------------------------

    ---------------------------------------

    ---Exiting-----------------------------

    Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

     

    Input Error: Can not find script file "C:\Program Files\Microsoft Office\Office15\ospp.vbs".

    Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

     

    Input Error: Can not find script file "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs".

    Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

     

    Input Error: Can not find script file "C:\Program Files\Microsoft Office\Office16\ospp.vbs".


    Now what if on a single machine we have different versions of MS Office products installed? Is there any way to isolate them and get the custom field updated accordingly? Cause I was thinking to utilize the custom field for our reports as well where we only have option to get the product keys and count of same key being used?

  • Hi Chris, thanks a lot - I discussed this with Al as well and he's pretty excited to see the outcome of this quest :)

  • , sorry for the delay, we had some back and forth to get where it is now.   Here is the download link from ClubMSP, it is setup as a free download.

    https://clubmsp.com/msp/scripts/ms-office-license-info/

    This script will allow write to the agent procedure log, upload the file to the Get File folder, and give you the option to email it.      With very little effort you could modify it to update a custom field(s).

    Let me know if you have any problems.  Enjoy!



    Sorry, I seemed to have forgotten the script link!
    [edited by: Chris Amori at 3:25 PM (GMT -7) on Jul 27, 2018]
  • Hi Chris,

    Sorry for the delay in response as I was out sick till yesterday…Thanks for the update, but I don’t see any link/ URL and Community in no longer recognizing my credentials to log in on the portal directly.

    Is it possible that you can send the link to me on my email?

  • Hi ,

    Just checking if you can get us the written script next week, that'd be a great help :)

  • Thanks Chris - it works amazingly

    I'm Glad Kyle was able to put right arguments on the PS commad to get what exactly I wanted but I had to modified it a bit and got it update our custom field for License Activation Status at the same time :)