VMware Cloud Community
paullee92
Enthusiast
Enthusiast
Jump to solution

vmdk last written date

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this

$vmName = 'MyVM'

$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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

You could do something like this

$vmName = 'MyVM'

$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

Reply
0 Kudos
paullee92
Enthusiast
Enthusiast
Jump to solution

Hi LucD

Can i have your email contact

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

There is a Contact Form on my blog you can use.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos