Reputation: 125
I am trying to extract date creation of os-disk in azure portal. I am able to generate os-disk lists from Get-AzureRmDisk cmdlet.
however, when i try to extract timecreation date with -unique parameters. the results shows duplicate values
$disks = Get-AzureRmDisk -ResourceGroupName "testGroup"
$osdisk = $disks.Name -match '-osdisk'
Result :
$datess = $osdisk.TimeCreated | Select-Object -Unique
$datess
Result :
As we can see there is an additional duplicated date which is being displayed. Any suggestions on how i can get date of the particular Azure os disk
Upvotes: 0
Views: 227
Reputation: 6245
You could format the TimeCreated
value into the Date Time format which is easier for comparison and duplicate filtering.
The result of the code below is either True
or False
:
$osdisk = $disks.Name -match '-osdisk'
Please see the suggested changes:
$osdisk = $disks | where {$_.Name -match '_osdisk'}
$datess = $osdisk.TimeCreated | %{Get-Date $_ -f 'yyyy-MM-dd HH:mm:ss'} | Select -Unique
The changes have been tested working.
Upvotes: 1