A PowerShell function to get Workspace ONE APP install logs

For whatever reason, VMWare decided to shove its App install logs in HKLM:\Software\AirwatchMDM rather than in a text file that gets picked up by the Get Device Log action…. Or importing straight in to UEM.

Anyway, you can use the gui and copy and paste in to notepad to get the log, or you can use this:

Function Get-WS1InstallLog
    {
    <#
    .Description
    This function queries the UEM logs found in HKLM:\Software\AirwatchMDM and outputs the Last Deployment log key

    .PARAMETER Name
    Name of the Application you wish to search for. This is a wildcard search
    .EXAMPLE
    PS> Get-WS1InstallLog -Name Notepad

    #>
    [CmdletBinding()]
    param
        (
        [Parameter(mandatory=$true)]$Name
        )

    $RegKeys=Get-ChildItem hklm:software\AirWatchMDM\AppDeploymentAgent\s* -Recurse #This will grab both the user and system install folders to capture all the applications
    Foreach($Reg in $RegKeys)
        {
        $key=Get-ItemProperty $reg.PSPath
        If($key.name -like "*$name*")
            {
            Write-Host "=============================================================================================================================================" -ForegroundColor Green
            write-host "Name: " -ForegroundColor Cyan -NoNewline
            write-host $key.Name
            write-host "Version: " -ForegroundColor Cyan -NoNewline
            write-host $key.Version
            write-host "Is Installed: " -ForegroundColor Cyan -NoNewline
            write-host $key.IsInstalled
            write-host "LastErrorDesc: " -ForegroundColor Cyan -NoNewline
            write-host $key.LastErrorDesc
            write-host "Last Deployment Time: " -ForegroundColor Cyan -NoNewline
            write-host $key.LastDeploymentTime
            write-host "Last Deployment log:" -ForegroundColor Cyan
            $Log=$key.LastDeploymentLog -split("`r`n")

            foreach($line in $log)
                {
                switch -Wildcard ($line)
                    {
                    {$_ -like "*error*"}
                        {
                        write-host $line -ForegroundColor Red
                        break
                        }
                    {$_ -like "*ExitCode=*"}
                        {
                        If ($line -notlike "*ExitCode=0*")
                            {
                            write-host $line -ForegroundColor Red
                            }
                        else
                            {
                            write-host $line -ForegroundColor Green
                            }
                        break
                        }
                    {$_ -like "*running*"}
                        {
                        write-host $line -ForegroundColor Yellow
                        break
                        }
                    {$_ -like "*Download started*"}
                        {
                        write-host $line -ForegroundColor Yellow
                        break
                        }
                    {$_ -like "*Download request*"}
                        {
                        write-host $line -ForegroundColor Yellow
                        break
                        }
                    {$_ -like "*Trying to install an already installed app*"}
                        {
                        write-host $line -ForegroundColor green
                        break
                        }
                    {$_ -like "*FirstDetection - IsInstalled*"}
                        {
                        write-host $line -ForegroundColor Yellow
                        break
                        }
                    {$_ -like "*FinalDetection => True*"}
                        {
                        write-host $line -ForegroundColor green
                        break
                        }
                    {$_ -like "*FinalDetection => False*"}
                        {
                        write-host $line -ForegroundColor red
                        break
                        }
                    {$_ -like "*FirstDetection => false*"}
                        {
                        write-host $line -ForegroundColor yellow
                        break
                        }
                    {$_ -like "*FirstDetection => True*"}
                        {
                        write-host $line -ForegroundColor Green
                        break
                        }
                   {$_ -like "*Execution complete. ok = True*"}
                        {
                        write-host $line -ForegroundColor Green
                        break
                        }
                   {$_ -like "*Execution complete. ok = False*"}
                        {
                        write-host $line -ForegroundColor Red
                        break
                        }

                       
                         
                    default
                        {
                        write-host $line
                        }

                    }

                }
            
            }

        }
    }

The usesage is pretty straight forward, feed it the Application you want to search for and it will output the log, the search is wildcarded. So “Note” would search for any app with Note in the name. a * will return every App.

I’ve even highlighted some of the lines I think are more important than others.

An Example

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.