az cosmosdb create command works but terminal flashes forever

When I run the following command that is part of a .ps1 file the cosmos db account is created in Azure but the terminal just presents a blinking cursor and does not move on to the rest of the commands in the script. I know it can take some time to create the cosmos account but in the portal I can see it is online but the powershell terminal is stuck forever. Converting the command to one line makes no difference.

How can I script this so it finishes and subsequent actions also run?

az cosmosdb create `     --resource-group $  cosmosResourceGroupName `     --name $  cosmosDbAccountName `     --kind GlobalDocumentDB `     --locations "East US=0" "West US=1" `     --default-consistency-level "Session"