-2

I created two response files and I want to create a batch file were one of the two response files gets used depending on the computer name. To get the name of a computer, I have been using

wmic computersystem get name

I am thinking I have to use IF THEN but I am not so sure.

1 Answers1

2

You could do it like this with a switch in PowerShell:

switch($env:COMPUTERNAME){
    "COMPUTER-1" {
        # use response file for COMPUTER-1
    }
    default {
        # use default response file
    }
}

A traditional if/else statement in PowerShell would look like this:

if($env:COMPUTERNAME -eq "COMPUTER-1"){
    # use response file for COMPUTER-1
}
else {
    # use default response file 
}
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206