Raymond Peng
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!"
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try that, and if it is not working inform me and I will send a script that I use.
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