Skip to main content
Active reading. Removed meta information (this belongs in comments).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

Mutiple Variables Multiple variables in Foreach Loop [Powershell]loop [PowerShell]

Is it possible to pull two variables into a Foreach loop? 

The following is coded for the PowershellPowerShell ASP. The syntax is incorrect on my Foreach loop, but you should be able to decipher the logic I'm attempting to make. Any suggestions and help will be greatly appreciated!

$list = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty name
$userList = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty LogonName
if ($list.Count -ge 2)
{
    Write-host "Please select the appropriate user.<br>"
    Foreach ($a in $list & $b in $userList)
    {
        Write-host "<a href=default.ps1x?UserID=$b&domain=$domain>$b - $a</a><br>"}
    }
}

Mutiple Variables in Foreach Loop [Powershell]

Is it possible to pull two variables into a Foreach loop? The following is coded for the Powershell ASP. The syntax is incorrect on my Foreach loop but you should be able to decipher the logic I'm attempting to make. Any suggestions and help will be greatly appreciated!

$list = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty name
$userList = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty LogonName
if ($list.Count -ge 2)
{
    Write-host "Please select the appropriate user.<br>"
    Foreach ($a in $list & $b in $userList)
    {
        Write-host "<a href=default.ps1x?UserID=$b&domain=$domain>$b - $a</a><br>"}
    }
}

Multiple variables in Foreach loop [PowerShell]

Is it possible to pull two variables into a Foreach loop? 

The following is coded for the PowerShell ASP. The syntax is incorrect on my Foreach loop, but you should be able to decipher the logic I'm attempting to make.

$list = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty name
$userList = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty LogonName
if ($list.Count -ge 2)
{
    Write-host "Please select the appropriate user.<br>"
    Foreach ($a in $list & $b in $userList)
    {
        Write-host "<a href=default.ps1x?UserID=$b&domain=$domain>$b - $a</a><br>"}
    }
}
Fixed code formatting.
Source Link
Adi Inbar
  • 12.4k
  • 13
  • 60
  • 71

Is it possible to pull two variables into a Foreach loop? The following is coded for the Powershell ASP. The syntax is incorrect on my Foreach loop but you should be able to decipher the logic I'm attempting to make. Any suggestions and help will be greatly appreciated!

        $list = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty name
        $userList = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty LogonName
        if ($list.Count -ge 2)
            {
            Write-host "Please select the appropriate user.<br>"
            Foreach ($a in $list & $b in $userList)
            {
    {
    Write-host "<a href=default.ps1x?UserID=$b&domain=$domain>$b - $a</a><br>"}
                }
            }

Is it possible to pull two variables into a Foreach loop? The following is coded for the Powershell ASP. The syntax is incorrect on my Foreach loop but you should be able to decipher the logic I'm attempting to make. Any suggestions and help will be greatly appreciated!

        $list = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty name
        $userList = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty LogonName
        if ($list.Count -ge 2)
            {
            Write-host "Please select the appropriate user.<br>"
            Foreach ($a in $list & $b in $userList)
                {
    Write-host "<a href=default.ps1x?UserID=$b&domain=$domain>$b - $a</a><br>"}
                }
            }

Is it possible to pull two variables into a Foreach loop? The following is coded for the Powershell ASP. The syntax is incorrect on my Foreach loop but you should be able to decipher the logic I'm attempting to make. Any suggestions and help will be greatly appreciated!

$list = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty name
$userList = Get-QADUser $userid -includeAllProperties | Select-Object -expandproperty LogonName
if ($list.Count -ge 2)
{
    Write-host "Please select the appropriate user.<br>"
    Foreach ($a in $list & $b in $userList)
    {
        Write-host "<a href=default.ps1x?UserID=$b&domain=$domain>$b - $a</a><br>"}
    }
}
edited tags
Link
casperOne
  • 74.7k
  • 19
  • 189
  • 262
Source Link
gp80586
  • 169
  • 2
  • 4
  • 13
Loading