Reading Time: 2 minutes

Hello, everyone it’s been some time now that I have not posted here in my blog but I’ve been through some tough situations, lost a member of the family, and hence I didn’t have the time nor the mental clarity to work on the blog. Nonetheless, I’ve been sharing news and such over my social media channels.

So, back to business and this time I’m coming with a very small tip when it comes to formatting output in PowerShell. I’m touching a tiny bit on the ARM WVD deployment process, but I will create a different post for this, with step-by-step instructions.


I wanted to use PowerShell to deploy an Azure Resource Manager (not the classic flavor) Windows Virtual Desktop deployment.

So, I started with the command:

New-AzWvdHostPool `
    -ResourceGroupName $rg `
    -Location $location `
    -Name $ahp `
    -WorkspaceName $ws `
    -DesktopAppGroupName $dag `
    -HostPoolType "Pooled" `
    -LoadBalancerType "DepthFirst" `
    -MaxSessionLimit 20 `
    -PreferredAppGroupType "RailApplications"

Side-tip: -PreferredAppGroupType can take: None, Desktop, and RailApplications. I tend to believe that the lack of documentation on this parameter is deliberately to keep us on our toes 😛

The main setup for the WVD is set and I needed to add some Session Host VMs in the application host pool that I just created.

The next thing you should do, is create a token for registering the VMs as part of the application pool.

New-AzWvdRegistrationInfo -ResourceGroupName $rg -HostPoolName "ahp-ESP0021" -ExpirationTime $((get-date).ToUniversalTime().AddHours(2).ToString('yyyy-MM-ddTHH:mm:ss.fffffffZ'))

and the reply from ARM was:

well it may not be visible there at the end of the script, so let me zoom in there for you:

the “…”

I need a way to get the whole token without it being cut-off at the end for presentation reasons.

The Tip: the -Wrap magic

Anyone been using PowerShell knows "Format-Table" but do you know the -Wrap option that comes along with it?

Let me introduce you to it:

    New-AzWvdRegistrationInfo `
        -ResourceGroupName $rg `
        -HostPoolName $ahp `
        -ExpirationTime $((get-date).ToUniversalTime().AddHours(2).ToString('yyyy-MM-ddTHH:mm:ss.fffffffZ')) `
        | Format-Table -Property "Token" -Wrap

The outcome:

This you can select and copy-paste to the agent to proceed with the installation of the Session Host VMs.

At this point I have hit another issue, but I will blog about it in a different post.

Stay tuned!