Above hyperlink is the output image.
Hi All,
I want to convert the whole output in a single line result in powershell.Below is my code,
$containername = "testoutput"
$storageAccKey = (Get-AzStorageAccountKey -ResourceGroupName
$rgname -AccountName $storageAccountName)[0].value
$storagecontext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccKey
New-AzStorageContainer -Name $containername -Context $storagecontext -Permission Off
Write-Output "Container $($containername) created"
2
Answers
Assuming that this is what you’re looking for:
Either Write-Host or Write-Output can be used. The multiple lines you’re seeing is the result of New-AzStorageContainer. Now, I have assigned it to a variable called $result and used in Write-Output.
One way to achieve your requirement is to use if-else condition and check
New-AzStorageContainer -Name $containername -Context $storagecontext -Permission Off
doesn’t result null. Below is the complete code that worked for me.RESULTS: