PowerShell, Hyper-V, Checkpoint-VM

Lanky Doodle 226 Reputation points
2022-05-06T10:57:33.61+00:00

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

Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,560 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 30,376 Reputation points Microsoft Vendor
    2022-05-23T07:29:31.01+00:00

    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.

    0 comments No comments