Hi Team,
I am using below command and i able to view vmdk file.
Get-VM -Name "Test VM" | Get-HardDisk -Name "Hard disk 1" | Select Filename
But i want to view the last written date for the vmdk file.
How may i achieve this.
You could do something like this
$vm = Get-VM -Name $vmName
Get-HardDisk -VM $vm -PipelineVariable hd | ForEach-Object -Process {
$dsName,$path = $hd.Filename.Split(' ')
$dsName
$path
$ds = Get-Datastore -Name $dsName.Trim('[]')
New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root '\' | Out-Null
Get-ChildItem -Path "DS:$path" | select -Property DatastoreFullPath,LastWriteTime
Remove-PSDrive -Name DS -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this
$vm = Get-VM -Name $vmName
Get-HardDisk -VM $vm -PipelineVariable hd | ForEach-Object -Process {
$dsName,$path = $hd.Filename.Split(' ')
$dsName
$path
$ds = Get-Datastore -Name $dsName.Trim('[]')
New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root '\' | Out-Null
Get-ChildItem -Path "DS:$path" | select -Property DatastoreFullPath,LastWriteTime
Remove-PSDrive -Name DS -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD
Can i have your email contact
There is a Contact Form on my blog you can use.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference