Skip to content

Commit f612499

Browse files
committed
fine tune powershell code for getting keycreationtime and checking for null
1 parent 1405de3 commit f612499

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

articles/storage/common/storage-account-get-info.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,19 @@ To display the creation time of the account access keys for a storage account in
189189

190190
# [PowerShell](#tab/powershell)
191191

192-
To return the creation time of the account access keys for a storage account with PowerShell, make sure you have installed the [Az.Storage](https://www.powershellgallery.com/packages/Az.Storage) module. Next, call the [Get-AzStorageAccount](/powershell/module/az.storage/get-azstorageaccount) command to get the **keyCreationTime** property, which includes the creation time for both keys. In the sample code below we get the **keyCreationTime** for both keys and display the value of each. We also test whether each value is null to distinguish a blank string value from a null value:
192+
To return the creation time of the account access keys for a storage account with PowerShell, make sure you have installed the [Az.Storage](https://www.powershellgallery.com/packages/Az.Storage) module. Next, call the [Get-AzStorageAccount](/powershell/module/az.storage/get-azstorageaccount) command to get the **keyCreationTime** property, which includes the creation time for both keys. In the sample code below we get the **keyCreationTime** for both keys and test whether each value is null:
193193

194194
```azurepowershell
195195
$rgName = <resource-group>
196196
$accountName = <storage-account>
197197
198+
# Get the keyCreationTime property of the storage account
198199
$keyCreationTime = (Get-AzStorageAccount -ResourceGroupName $rgName -Name $accountName).keyCreationTime
199-
$keyCreationTime.key1
200-
$keyCreationTime.key1 -eq $null
201-
$keyCreationTime.key2
202-
$keyCreationTime.key2 -eq $null
200+
# Display the value for both keys
201+
$keyCreationTime
202+
# Check both properties for null values
203+
Write-Host 'keyCreationTime.key1 is null = ' ($keyCreationTime.key1 -eq $null)
204+
Write-Host 'keyCreationTime.key2 is null = ' ($keyCreationTime.key2 -eq $null)
203205
204206
```
205207

0 commit comments

Comments
 (0)