Do script block based on more than 1 condition?

Welcome Forums General PowerShell Q&A Do script block based on more than 1 condition?

Viewing 4 reply threads
  • Author
    Posts
    • #232063
      Participant
      Topics: 2
      Replies: 2
      Points: 33
      Rank: Member

      Hey all

      How can I change the below to include an “and” ( eg to complete, once both capabilities have been installed?

      do {

      Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 -ErrorAction Ignore | Out-Null
      Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0 -ErrorAction Ignore | Out-Null
      }
      until ((Get-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0).State -eq ‘Installed’)

      Thanks.

    • #232078
      Participant
      Topics: 12
      Replies: 525
      Points: 1,233
      Helping Hand
      Rank: Community Hero
      do {
          Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 -ErrorAction Ignore | Out-Null
          Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0 -ErrorAction Ignore | Out-Null
          Start-Sleep -Seconds 1
      }
      until (
          (Get-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0).State -eq ‘Installed’ -and
          (Get-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0).State -eq ‘Installed’
      )
      
    • #232852
      Participant
      Topics: 2
      Replies: 2
      Points: 33
      Rank: Member

      Thank you Sam exactly what I was looking for.

       

       

    • #232897
      js
      Participant
      Topics: 31
      Replies: 829
      Points: 2,572
      Helping Hand
      Rank: Community Hero

      These commands run in the background?

    • #232939
      Participant
      Topics: 2
      Replies: 2
      Points: 33
      Rank: Member

      Yes we have a weird intermittent issue on our Firewall, this gets around it/workaround.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.