I am adding members into different tiles with csv file and i have lots of entries in the csv. I want to add the progress acitivty bar in my codes to see the progress
$csv = Import-Csv csv_file_path.csv
foreach ($addmember in $csv) { Add-TeamUser -GroupId $addmember.tilename -User $addmember.useridid -Role Member}
CodePudding user response:
Use the cmdlet Write-Progress
see an example:
$i=1
$Items = 1..10000
foreach ($item in $Items)
{
Write-Progress -Activity "Scanning Items" `
-Status "Items Scanned: $($Items.Count -$i) of $(($Items).Count)" `
-PercentComplete (($i / ($Items.Count)) * 100)
$i
}
CodePudding user response:
To clarify Avshalom's answer:
$csv = Import-Csv csv_file_path.csv
$i = 1
foreach ($addmember in $csv) {
Add-TeamUser -GroupId $addmember.tilename -User $addmember.useridid -Role Member
Write-Progress -Activity "Scanning Items" -Status "Items Scanned: $($csv.Count -$i) of $(($csv).Count)" -PercentComplete (($i / ($csv.Count)) * 100)
$i
}