I’m working with a script for managing computers in our AD.
At the moment we have a script that contains info about each type of computer, the model name, default password and OU. But that means that each time we add a new type of computer we have to edit directly in the script. Which feels off.
Instead I’ve created a csv containing a row for each computer type containing the following columns: modelName ; model ; pwd ; ou
Basically I’d want to test if the first column in the csv (modelName) matches with $modelID which i get with:
$modelID = (Get-CimInstance -Class:Win32_ComputerSystem).Model
If so I would like to add the the three next columns (model, pwd, ou) in that row to variables of the same name ($model, $pwd, $ou), so I can basically run whichever function is needed with these values.
I’ve used “Import-Csv | ForEach-Object” before, but since I don’t really need to do something with each post but rather just do the comparison and then grab the contents of the rest of that row, I’m not really sure how best to go about this.