Run command going through a file content

Welcome Forums General PowerShell Q&A Run command going through a file content

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
2 years ago.

  • Author
    Posts
  • #56153

    Participant
    Points: 0
    Rank: Member

    How can I run multiple get-vmreplication for multiple clusters?

    Get-VM –ComputerName(Get-CusterNode (Get-Content C:\Users\a\Desktop\cluster.txt)) | Where-Object { $_.Name -like '*FS*' } | Get-VMReplication | Select Name, State, Health, PrimaryServer

    I want to check the hyper-v replica status of VMs from multiple clusters.
    The txt file looks like this:
    Pxxclus4
    Pxxc1
    Lfdcl1

  • #56180

    Keymaster
    Points: 1,624
    Helping HandTeam Member
    Rank: Community Hero
    Get-Content | 
    ForEach-Object {
      # The $_ placeholder will represent one line at a time from the text file
    }
    

    Something like that?

The topic ‘Run command going through a file content’ is closed to new replies.