Author Posts

January 10, 2017 at 10:50 am

Hi Gents

so i have a small script (not finished yet) to create some room mailboxes (approx 600) i would like to add a progress bar to show how far the script is along in % (for the creation of the MB, then the remaining sleep time). something im struggling with is applying the examples around to my own situation, im sure once i see it in action with my own process everything will click.


###Set Variables###

$data = Import-Csv "H:\EMEA Messaging\Meeting Rooms\test Data.csv"
$ou = "contoso.com/Move-Objects/SG-Test"
$PWD = "MeetingRoom01"

## Only set while exchange is spread across DBs##
$DB = "EU_DAG1_db3"

###Create Meeting Rooms###

$data | ForEach-Object {

New-Mailbox -Name $_.displayname -Alias $_.alias -UserPrincipalName $_.upn -Org $ou -Password (ConvertTo-SecureString $PWD -AsPlainText -Force) -Database $DB -room

}

###Hides Rooms from Address Book###


Sleep -Seconds 90 -Verbose

Get-mailbox -OrganizationalUnit $OU | Set-Mailbox -HiddenFromAddressListsEnabled $TRUE

##Set-Calendarprocessing CDMlets for resourcing options####


TIA

January 10, 2017 at 12:43 pm

something like this ?

$data = 1..100 # demo data
$data | ForEach-Object -Begin {
  $i=0
} -Process {
  $i++
  Write-Progress -Activity "Activity around $_" -Status "Invoking ..." -PercentComplete ($i/$data.Count*100)
  start-sleep -Seconds 1
}

January 10, 2017 at 3:46 pm

hi max im still unsure how to integrate this to the script ?

January 11, 2017 at 6:14 am

place it here and modify messages to your needs

# [...] your code
$i=0
$data | ForEach-Object {
# progress bar addition start
$i++
Write-Progress -Activity "Activity around $_" -Status "Invoking ..." -PercentComplete ($i/$data.Count*100)
# progress bar addition end

New-Mailbox -Name $_.displayname -Alias $_.alias -UserPrincipalName $_.upn -Org $ou -Password (ConvertTo-SecureString $PWD -AsPlainText -Force) -Database $DB -room

}
# [...] your code

January 11, 2017 at 12:49 pm

Thanks Max, Think i have gotten in my head how this works now