Get-OMEApplicationInfo.ps1

Function Get-OMEApplicationInfo
{

    <#
    .SYNOPSIS
        Gets information about the Version OME server.
    .DESCRIPTION
        Gets information about the Version OME server.
    .PARAMETER Session
        Specifies the Session Id for the OME server.
 
    .EXAMPLE
        Get-OMEApplicationInfo
 
        BuildNumber : 2056
        URL : https://omeserver.example.com:2607/Web/Default.aspx
        Description : Dell OpenManage Essentials is a web-based one-to-many hardware management application that allows you to
                      manage Dell devices in your network
        Version : 2.2.0
        GUID : f2adfa731-bfdf-4aab-8366-98d8a723bf8f8
        Name : Dell OpenManage Essentials
        Vendor : Dell Inc.
         
    .NOTES
        Author: Mike Khar
    .LINK
        http://www.dell.com/support/home/us/en/04/product-support/product/dell-openmanage-essentials-v2.2/research
        https://$Server:$Port/api/OME.svc/Application
    #>
  

    [CmdletBinding(
    )]
    Param(
        $Session="OMEConnection.DefaultOMESession"
    )
    
    Begin
    {
        $CurrentSession = Get-Variable -Scope Global -Name $Session -ErrorAction SilentlyContinue -ValueOnly
        If (!$CurrentSession) {
            Write-Warning "Please use Set-OMEConnection first"
            Break
            Return
        }
        else {
            $BaseUri="https://"+$CurrentSession.Server+":"+$CurrentSession.Port+"/api/OME.svc"
        }
    }
    
    Process
    {    
        Try {
            $uri=$BaseUri+"/Application"
            if ($CurrentSession.Credentials) {
                $result = Invoke-WebRequest -Uri $uri -Credential $CurrentSession.Credentials
            }
            else {
                $result = Invoke-WebRequest -Uri $uri -UseDefaultCredentials
            }
            if ($result.StatusCode -ne 200) {
                Out-OMEException -Exception $_
                return
            }
            else {
                Write-Debug "HTTP request: $uri HTTP status code: $($result.StatusCode)"
                [xml]$xml=$result.Content
                $result=$xml.GetApplicationDetailsResponse.GetApplicationDetailsResult
                $Application=Convert-XMLtoPSObject -xml $result -ObjectType "OME.Application"
                $Application.PSObject.Properties.Remove('i')
                return $Application
            }
        }
        Catch {
            Out-OMEException -Exception $_
        }
    }
    
    End{}                
}