SubSun
asked on
Need help with powershell script
Hi I am using the following script to disable OWA for a list of users, how can I generate a result log file for actions like error warning and success while running this script?
I would like to get the following in log with respect to the result of command.
For each Successful operation print - OWA disabled for user $username
For each Warning print - OWA disabled for user $username with warning
For each Error print - Not able to disable OWA for user $username
Thanks in advance.
I would like to get the following in log with respect to the result of command.
For each Successful operation print - OWA disabled for user $username
For each Warning print - OWA disabled for user $username with warning
For each Error print - Not able to disable OWA for user $username
Thanks in advance.
$UserList = get-content userlist.txt
foreach ($Username in $UserList) `
{
set-casmailbox -identity $UserName `
-OWAEnabled $false `
-POPEnabled $false `
-ActiveSyncEnabled $false `
-ImapEnabled $false
}
ASKER
Sorry I am a novice in powershell programming. I could not make out the correct code to print the logs. I will wait and see, if some once can help me with the codes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the late response, I will try this and let you know the result..
ASKER
I can use this as a work around, since i did not receive any other answer, i will close this question by accepting your response..
http://huddledmasses.org/trap-exception-in-powershell/
http://weblogs.asp.net/adweigert/archive/2007/10/10/powershell-try-catch-finally-comes-to-life.aspx