Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assuming the CSV file contains two columns named "Column1" and "Column2", and the two distinct commands to be executed are "Command1" and "Command2", the following PowerShell script can be created:

$data = Import-Csv "path\to\file.csv"
foreach ($row in $data) {
    $value1 = $row.Column1
    $value2 = $row.Column2
    Command1 $value1
    Command2 $value2
}

Explanation:

  1. The Import-Csv cmdlet is used to read the CSV file and store the data in the $data variable.
  2. The foreach loop is used to iterate through each row in the $data variable.
  3. The two values in each row are stored in separate variables ($value1 and $value2).
  4. The Command1 and Command2 are executed with the respective values from each row.

Note: Replace "Command1" and "Command2" with the actual commands to be executed, and replace "path\to\file.csv" with the actual path to the CSV file.