Loading

Create

Skip Feed
  1. DUJ Status powershell

     

    Hello all,

     

    I'm sure we all have seen the new DUJ status indicator in the SLM Web UI

    dujstatus 

    There is also already an idea in the ideas board to restrict visibility for this:

    https://ideas.snowsoftware.com/ideas/IDEAS-I-1519

     

    I was wondering where this information comes from and the answer is so easy.

    There is a new url in the API for this: http(s)://snowserver:port/api/duj

    This results in

    DUJStatus1 

    So, I thought I'd like to monitor this using a powershell script and ended up with this (please note that this is not the "best" powershell scripting, my focus was to demonstrate how it works):

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

    function SLMGetDUJStatus {

       param()

     

       #region Settings TEST, optional use this as parameters in the function

           $SLMAccountName = "YourSLMAPIAccountName"

           $SLMAccountPW = "YourSLMAPIPassword"

           $SecurePassword = ConvertTo-SecureString $SLMAccountPW -asPlainText -Force

           $SLMServerName = "http://YourSLMServer:port"

       #endregion TEST

     

    Write-Verbose "SLMGetDUJStatus: Start"

     

       #region Credential and base uri to Snow License Manager

           $credential = New-Object Management.Automation.PSCredential ($SLMAccountName,$SecurePassword)

           $apiUri = "$SLMServerName/api/duj"

       #endregion TEST

     

       try {

           # Get status from Snow License Manager

           $SLMDUJ = Invoke-RestMethod -Uri ("$apiUri" + '?$format=json') -Credential $credential

     

           #create object to return values

           $return = New-Object PsObject         # create object for result

           # Add properties to the Object for DUJ Status

           $null = $return | Add-Member -Type NoteProperty -Name "DUJState" -Value "$($SLMDUJ.Body.state)" -Force

           $null = $return | Add-Member -Type NoteProperty -Name "DUJLastExec" -Value "$($SLMDUJ.Body.LastStartTime)" -Force

           $null = $return | Add-Member -Type NoteProperty -Name "DUJLastDuration" -Value "$($SLMDUJ.Body.LastExecutionTime)" -Force

           $null = $return | Add-Member -Type NoteProperty -Name "DUJIsRunning" -Value "$($SLMDUJ.Body.IsRunning)" -Force                       

     

           # Send object to the pipeline, so that it is returned

           $return

     

       } #try

       catch {

           Write-Verbose -verbose "Unable to get information. Exception: $($_.Exception.Message)"

       } #catch

    } # end function

     

    $status = SLMGetDUJStatus

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

     

    The result written to $status will be the object as defined:

    DUJStatus2 

    Hope this helps a little to understand SLM API and possibilities 😊

     

    Kine regards,

    Axel

    Expand Post

End of Feed
1 Chatter Feed Items
ALL CONVERSATIONS
UNSOLVED
ARTICLES
1 Post

Related Topics

    Loading
    Create | Flexera