core/Resources/Scripts/get_vm_details.ps1

Param(
    [string]$ResourceGroupName,
    [string]$ScriptsFolderPath = ".\Resources\Scripts"
)

. "$ScriptsFolderPath\common.ps1"

$resourceGroup = $null
$vms = $null

function ExecuteCommand {
    $global:resourceGroup = CheckIfEnvironmentExits -Environment $ResourceGroupName
    NCacheNonActivatedServers
}

function NCacheNonActivatedServers {
    $global:vms = GetNCacheServers -rgName $($global:resourceGroup.ResourceGroupName)
}


function GetVmDetails {
    $global:resourceGroup.Tags["ServerCount"] = $global:vms.Count
    return  $global:resourceGroup.Tags 
}


if (-not (Get-AzContext)) {
    Connect-AzAccount
    if (Get-AzContext) {
        ExecuteCommand
    }
}
else {
    ExecuteCommand
}
return GetVmDetails