Link to home
Start Free TrialLog in
Avatar of Raymond Peng
Raymond PengFlag for United States of America

asked on

Powershell Script: Disable OWA access using a list of users

Hello,

I'm pretty new at Powershell and have been tasked with forming a script that feeds a list of users and disable OWA access for those users
this is what i'm thinking. will this do the trick and what do you experts propose?

$Users = Import-CSV c:\temp\users.csv
 
# For each user set the mailbox for user and disable OWA
foreach ($usr in $Users) {
$sAMAccountName = $usr.samaccountname
Write-host -NoNewLine "Modifying $sAMAccountName / Mailbox Identity Properties...."
Set-CASMailbox $SamAccountName -OWAEnabled $False
Write-host "Done!"
}
SOLUTION
Avatar of Anthony Carter
Anthony Carter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Anthony Carter
Anthony Carter

If you want to test prior to actually doing the change:

Import-CSV c:\temp\users.csv | Foreach-Object{
  Write-host -NoNewLine "Modifying $_.samaccountname / Mailbox Identity Properties...."
 }

Which will print you out all the samaccountnames from the CSV
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try that, and if it is not working inform me and I will send a script that I use.