VMware Cloud Community
dbutch1976
Hot Shot
Hot Shot
Jump to solution

Confirm snapshots have been scheduled

Hello,

I have a simple script which schedules several snapshots of VMs from a .csv file. I'm able to see that the tasks have been creating by getting a list of all scheduled tasks:

Get-VM $VM.Name | (Get-View ScheduledTaskManager).ScheduledTask | %{(Get-View $_).Info} | Select Name,NextRunTime

How do I only get scheduled tasks for the VMs in the csv file? I'm thinking something along these lines:

$VMs = Import-Csv E:\output\VMs.csv

foreach ($VM in $VMs){
     Get-VM $VM.Name | (Get-View ScheduledTaskManager).ScheduledTask | %{(Get-View $_).Info} | Select Name,NextRunTime
}

However this does not work. Any suggestions?
Thanks.

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this

$VMs = Import-Csv E:\output\VMs.csv

$vmObj = Get-VM -Name $VMs.Name

Get-View -Id (Get-View ScheduledTaskManager).ScheduledTask |
Where-Object { $_.Info.Entity -in $vmObj.Id } |
Select-Object @{N='Name';E={$_.Info.Name}}, @{N = 'NextRunTime'; E = { $_.Info.NextRunTime } }


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

View solution in original post

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

You could do something like this

$VMs = Import-Csv E:\output\VMs.csv

$vmObj = Get-VM -Name $VMs.Name

Get-View -Id (Get-View ScheduledTaskManager).ScheduledTask |
Where-Object { $_.Info.Entity -in $vmObj.Id } |
Select-Object @{N='Name';E={$_.Info.Name}}, @{N = 'NextRunTime'; E = { $_.Info.NextRunTime } }


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

Reply
0 Kudos