Link to home
Start Free TrialLog in
Avatar of ITguy565
ITguy565Flag for United States of America

asked on

Powershell Scripting

Ladies and Gents,

I am looking to modify this script to add logic to it.

$content = get-content "c:\test.txt"

foreach ($user in $content)
{export-mailbox $user -IncludeFolders "\Inbox","\Sent Items","\Deleted Items" -pstfolderpath c:\$user._Mailbox.pst}

Open in new window


(The logic I would like to add would be a check)

To make sure that I have full mailbox rights prior to attempting the export mailbox command.

add-mailboxpermission -Id “$user” -User “testadmin” -AccessRights FullAccess -Deny:$false

Open in new window


If FullAccess is found to be false then run the above command and make it true.

I need the logic statement listed above to be a  challenge statement at the beginning of the script

Note the $user var at the top. This data will be pulled from an external source called test.txt
Avatar of ITguy565
ITguy565
Flag of United States of America image

ASKER

I would also like to add code that will export the entire output to a log file in the same file location. (c:\exportMailbox.log}
ASKER CERTIFIED SOLUTION
Avatar of Rajitha Chimmani
Rajitha Chimmani
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
Thanks for the fast reply, that was exactly what I needed.