Scenario: You have a large CSV file that you need to import and perform specific PowerShell commands against. You need the results in a hurry and you want to split up the CSV so you can run multiple PowerShell sessions at once to pull the results in parallel. Instead of creating separate CSV files to import for each PowerShell session, you can tell PowerShell which rows of the import you want to target.
Code Example: In each PowerShell you can import the CSV file. When calling the variable for the loop you can specify the rows you want to target. In this example we are going to set customattribute1 to the string “MigrateME” for the first 1000 (well 1001) entries in the csv file in one PowerShell session. In a second PowerShell session I would import the code but change [0..1000] to [1001..2000], and repeat the increment for each additional PowerShell session.
$users = Import-csv C:TempAll_Mailboxes.csv
$users[0..1000] | Select -expandproperty alias | %{ set-mailbox $_ -customattribute1 “MigrateMe”}