azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Get-AzureRmAutomationJobOutputRecord should return concrete Value type

Open MiYanni opened this issue 8 years ago • 3 comments

Cmdlet(s)

Get-AzureRmAutomationJobOutputRecord

PowerShell Version

5.1.16299.98

Module Version

4.1.1

OS Version

10.0.16299.98

Description

Currently, Get-AzureRmAutomationJobOutputRecord returns a JobStreamRecord. This class contains a Value property. This property holds the information for the output record. Meaning, the information that is useful if you are trying to gather the logs yourself from an automation job.

The problem is, Value is a Hashtable. So, it has no concrete properties. The values in this hashtable change depending on the Type property. This indicates the type of stream (Output, Error, Warning, Verbose, etc.). So, since there isn't a concrete class, you need to explore each stream type to see what possible values you might want/need. It might be easier to show a code snippet from a PowerShell script:

foreach($stream in $streams) {
    $content = switch ($stream.Type) {
        'Output' {
            $stream.Value.value
        } 'Error' {
            $stream.Value.Exception
            $stream.Value.ScriptStackTrace
        } 'Warning' {
            $stream.Value.Message
            $stream.Value.InvocationInfo
        } 'Verbose' {
            $stream.Value.Message
        }
    }
    ...
}

Basically, I have to figure out what each of these Types potentially return. Then, make this switch to get that information, which none of the stream types have the same way to access their message. Having some basic class that contains Message and then derived types for each stream type would help immensely. It shouldn't be on the hands of the user to explore each Hashtable based on Type to figure out how to get information.

At very minimum, add some documentation to Get-AzureRmAutomationJobOutputRecord to indicate how a user should work with the output of the command.

MiYanni avatar Jan 03 '18 22:01 MiYanni

@vrdmr can you take a look?

markcowl avatar Jan 04 '18 17:01 markcowl

Triaged: Considering adding documentation.

andyw248 avatar Jun 15 '19 17:06 andyw248

Won't fix

GaneshMSAzure avatar Oct 15 '19 23:10 GaneshMSAzure