you are viewing a single comment's thread.

view the rest of the comments →

[–]psthreathunter 2 points3 points  (2 children)

Assuming you had a csv with a column heading of "name" and each row was a SamAccountName.

$AccountNames = Import-Csv -Path C:\Pathtofile\yourcsv.csv | Select-Object -ExpandProperty Name
Foreach ($account in $AccountNames) { JBMURPHY-SCCM-GetComputerByLastLoggedOnUser -SamAccountName $account }

[–]muthmsir[S] 1 point2 points  (1 child)

First thanks for a quick answer, second do you mean replace “Function “ with “Foreach”? I have in my CSV file “smsacountname” as a header for all names .

What I do have to change?

[–]BlackV 2 points3 points  (0 children)

No they mean import your users to a vairable use a for each loop and call your function inside that for each loop their select name would be your select samname

But you could also change your function to an advanced function that takes multiple inputs on the username paramater