#
# Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 2009
#
# NAME: massPwdChg.ps1
#
# AUTHOR: Erik Enger , PointBridge
# DATE : 11/03/2009
#
# COMMENT: Use this script to perform a mass password change of BPOS accounts
#
# Note: This script requires the Microsoft Exchange Transporter snapin
# Modify the default PowerShell profile to add the Quest Snap-In
#
# c:\windows\system32\windowspowershell\v1.0\profile.ps1
#
# add-pssnapin Microsoft.Exchange.Transporter
# ==============================================================================================
cls
# Get the login ID for the BPOS admin account
write-host 'Enter the username for the MS Exchange Online admin (i.e. admin@contoso.com): '
$bposlogin = Read-Host
# Get the password for the BPOS admin account in a secure fashion (display * for password)
write-host 'Enter the password for the MS Exchange Online admin (i.e. admin@contoso.com): ' -foregroundcolor yellow -BackgroundColor darkmagenta
$bpospwd = read-host -assecurestring
Write-Host
# Form the BPOS encrypted credential information and store it in a variable to be passed to upcoming commands
$bposcred = new-object -typename System.Management.Automation.PSCredential -argumentlist $bposlogin, $bpospwd
Write-Host
write-host "`n`n`n"
"************************************************************************************************"
import-csv c:\migration\massPwdChg.csv | foreach {
## Start a Transcript
$file="C:\Migration\ScriptLogs\"
$file+= $_.name +"-massPwdChg.log"
"************************************************************************************************"
Start-Transcript -Path $file -NoClobber:$false
Write-Host "Resetting BPOS password for:" $_.name
Date
"************************************************************************************************"
# Set the password and prompt for change on next logon
Set-MSOnlineUserPassword -Identity $_.mail -Password $_.passwd -ChangePasswordOnNextLogon:$true -Credential $bposcred -Verbose
## Stop the log
Date
Stop-Transcript
"************************************************************************************************"
Write-Host `n`n`n
}