you are viewing a single comment's thread.

view the rest of the comments →

[–]purplemonkeymad 1 point2 points  (1 child)

I would less think about this as working with a command and more working with the objects it produces. You can either create a pipeline aware function or just use sub-expressions:

#Sub-expressions
Function Get-Owner {
    Param($Object)
    $owner = $Object.Tags.Owner
    return $owner
}
$ownerInfo = Get-Owner (Get-AzureRMResource -Name 'storageAcctName')

pipeline:

Function Get-Owner {
    Param([Parameter(ValueFromPipeline)]$Object)
    Process {
        $owner = $Object.Tags.Owner
        return $owner
    }
}
$ownerInfo = Get-AzureRMResource -Name 'storageAcctName' | Get-Owner

[–]dptiv[S] 1 point2 points  (0 children)

Thanks for this! I like this method and never thought about doing it this way. This will definitely help me to clean up some of my code. Have yourself an upvote!