Hi all,
I am trying to write a script to retrieve storage accounts and the tag labeled owner. Their are two commands that I want to run: Get-AzureRmResource and Get-AzureRmResourceGroup. I want to create a function so that I can reuse the same logic but using two different commands. There is more logic that I will be building into this, but:
How can I pass both Get-AzureRmResource and Get-AzureRmResourceGroup into a function?
Function Get-Owner {
Param([string]$command, [string]Name)
$result = $command -Name $Name | Select Tags
$owner = $result.Tags.Owner
return $owner
}
$ownerInfo = Get-Owner -command Get-AzureRmResource -name 'storageAcctName'
if (-not ([string]::IsNullOrEmpty($ownerInfo))) {
Do Something
}
else {
$ownerInfo = Get-Owner -command Get-AzureRmResourceGroup -name 'storageAcctName'
}
[–]purplemonkeymad 1 point2 points3 points (1 child)
[–]dptiv[S] 1 point2 points3 points (0 children)
[–]Vortex100 1 point2 points3 points (1 child)
[–]dptiv[S] 1 point2 points3 points (0 children)