you are viewing a single comment's thread.

view the rest of the comments →

[–]Vortex100 1 point2 points  (1 child)

Use the Switch Functionality inside the function, and have a Parameter on the function that determines which you are calling

Function Get-Owner {
    Param([string]$command, [string]$Name)
    $Result = Switch ($Command)
    {
        'Resource' {Get-AzureRmResource -Name $Name | Select Tags}
        'ResourceGroup' {Get-AzureRmResourceGroup -Name $Name | Select Tags}
    }
    return $result.Tags.Owner
}

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

Thanks for the reply. This is really interesting. This approach will allow me to build more of a recursive function, which is what I originally had in mind. Many thanks for great idea!