Link to home
Start Free TrialLog in
Avatar of SubSun
SubSunFlag for India

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.
$UserList = get-content userlist.txt

foreach ($Username in $UserList) `
{ 
set-casmailbox -identity $UserName `
-OWAEnabled $false `
-POPEnabled $false `
-ActiveSyncEnabled $false `
-ImapEnabled $false
}

Open in new window

Avatar of FDiskWizard
FDiskWizard
Flag of United States of America image

Sorry, I can't give a solid answer. I tried to dive into error handling with one script since starting Powershell in December. Take a look at these links:

http://huddledmasses.org/trap-exception-in-powershell/
http://weblogs.asp.net/adweigert/archive/2007/10/10/powershell-try-catch-finally-comes-to-life.aspx
Avatar of SubSun

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
Avatar of FDiskWizard
FDiskWizard
Flag of United States of America image

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 SubSun

ASKER

Sorry for the late response, I will try this and let you know the result..
Avatar of SubSun

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..