Get-AzureRmAutomationJobOutputRecord should return concrete Value type
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.
@vrdmr can you take a look?
Triaged: Considering adding documentation.
Won't fix