Deploying the ARM Template using the Powershell, need to fetch the previous AVD Session host number from Azure Portal and from which we can pass the next incremental value in the ARM template by declaring a variable.
#Login-AzAccount
$vminitialnumber= Get-AzWvdSessionHost -HostPoolName infosyswvd -ResourceGroupName avd
New-AzResourceGroupDeployment `
-ResourceGroupName AVD `
-TemplateFile 'D:\Updated-AVD\East US\Template.json' `
-TemplateParameterFile 'D:\Updated-AVD\East US\Parameters.json'
Please check the below workaround:
Install module
Fetch the Latest Session Host
Use the Get-AvdLatestSessionHost to get the Latest Session Host.
syntax
Example to Get the Latest session Host of ADV
Refer this blog to get the session Recent/Old Session Host using the Get-AvdImageVersionStatus Command.