question

LankyDoodle-7423 avatar image
0 Votes"
LankyDoodle-7423 asked IanXue-MSFT answered

PowerShell, Hyper-V, Checkpoint-VM

Hi,

I have all AD computer objects in various groups. These groups match their monthly update schedule:

Week1-Day1
Week1-Day4
Week2-Day2
Week2-Day5

...and so on. These groups are used in Patch Management tool to control when they get updates pushed.

I would like to schedule the snapshots of these VMs 30 minutes prior to patches being pushed.

I can work with Get-VM, Checkpoint-VM and Get-ADGroupMember cmdlets individually, but I cannot quite work out the Pipeline. What I am trying to do is have lots of Scheduled Tasks setup (one for each AD group basically) which:

Gets all VMs from the AD group used in the Get-ADGroupMember
Connects to the Hyper-V Cluster using Get-VM with -ClusterObject
Checkpoints the VMs in the supplied AD group only

Get-VM -ClusterObject (Get-ClusterResource -Cluster <CLUSTERNAME> | Checkpoint-VM -SnapshotName "Monthly update cycle"
Get-ADGroupMember -Identity "<ADGROUPNAME>" | Select Name

Where do I put Get-ADGroupMember in the Get-VM pipeline so that only those VMs get snapshotted

Thanks

windows-server-powershellwindows-server-hyper-v
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

Hi,

You can pass the names of the AD computers to the Get-VM cmdlet.

 (Get-ADGroupMember -Identity "<ADGROUPNAME>").Name | Get-VM | Checkpoint-VM

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.