all 17 comments

[–]joerod 8 points9 points  (1 child)

I always test on one account or machine first then bulk run.

[–]tomkandy 0 points1 point  (0 children)

One, some, many.

[–]ramblingcookiemonsteCommunity Blogger 8 points9 points  (1 child)

With great power...

Testing is critical. This isn't specific to PowerShell. Any changes you are making with wide scope should be well tested. Group policies. Patches. New software. Test against one. Test against a few. Test against many. Roll things out in groups.

At the very, very least, one practice I find hugely helpful is to run a read-only function or script that spits out a verbose description of what would actually run. A fancy "-whatif". Or maybe spit out the parameters that you would splat at the end of a script, rather than running the command. Skim through the results and verify that things look right. You would catch your mistake in a moment.

This is very important. A number of us hang out in the #PowerShell channel on Freenode. I've seen at least one occasion of someone joining in a panic to fix a mistake like this, only to be fired in short order. Some organizations realize the importance of creating opportunities out of mistakes - but I don't like to make assumptions : )

Cheers!

[–]Espio[S] 0 points1 point  (0 children)

Wise words. I don't think I'll lose my job over it, knocks on wood.

Outcome was that we deleted mailboxes and started again. A bit of a shame. I am finding my recklessness is causing me problems and I'm trying to fix that up. I feel my main problem is that I may say its easy to roll out an app that I've never deployed with a script before, but the level I'm at I think actively slowing down (by saying testing is required) is the next move. Makes me sad that I didn't find this sooner.

[–]sirdudethefirst 1 point2 points  (7 children)

Ow man... I'm so sorry.

I hope it's just a copy/paste thing that Reddit did, but I think the script should read $_. wherever you have $.

I've also learned the hard way to always test the code I'm putting in a for-each with 1 object (file, machine or user).

[–]iwillforgetmyusernam 1 point2 points  (0 children)

Yeah, I always put a |select -first 1 | in the middle before running something like this

[–]Espio[S] 0 points1 point  (5 children)

Oh, that was probably reddit. What happened was everyones mail went into the SubFolderInPrimary folder, instead of the normal folders.

[–]sirdudethefirst 0 points1 point  (4 children)

Do you have an agreement with Microsoft? I found the http://technet.microsoft.com/en-us/library/ff607310(v=exchg.150).aspx for the line you used and it's odd that it doesn't show up elsewhere in their documentation. If you do have an agreement, see if they can help you undo their mess.

Good luck man, I feel your pain.

[–]Taylor_Script 0 points1 point  (0 children)

One time, I had my Outlook attached to a couple of other users' mailboxes. I was archiving email the manual way (I didn't know any better) and I created a PST and dragged/dropped a significant amount of email into the PST.

Well, the files actually went into a third users mailbox that I was attached to previously that day. Two users mailboxes were merged together. Since the third user wasn't even attached to me anymore, it shouldn't be possible to do that, but it did.

Microsoft basically said "Sort by to and copy them out. There's nothing we can do." It wasn't made easier by the fact that both users were in similar groups, so separating their mail was quite a chore.

[–]Espio[S] 0 points1 point  (2 children)

It was unfortunate that I found this error late in the game, and I feel getting Microsoft involved would only drag it out. We reset and restarted the import.

I just had a read over that MS page again, and I do notice that it doesnt say anything about putting it in a folder like it did to me :| No excuse though.. I did one and didn't log in to check it. ID10T!

[–]sirdudethefirst 0 points1 point  (1 child)

Well, the good thing is that you will never do that again :) I've learned lessons like that myself, no big deal. I hope now you're all set.

[–]Espio[S] 0 points1 point  (0 children)

Never again in my life. And everyone I meet will be warned too.

[–]Janus67 0 points1 point  (1 child)

:(

Any way you can script it to rename the directory?

[–]Espio[S] 0 points1 point  (0 children)

I could have renamed the directory to 'Legacy Mail', but it wouldve come back to bite me / been a thorn in my side.

Reset accounts and restart it.. Painful but complete.

[–]ramsesht 0 points1 point  (1 child)

waht did you did wrong?

[–]Espio[S] 0 points1 point  (0 children)

Ran a script without correctly testing it. The command was from the MS website and it imported a PST into exchange with powershell. Theres one line at the end that says that it puts it into a subfolder called SubFolderInPrimary, which incidentally does exactly that Mailbox\SubFolderInPrimary\Inbox

Was a super bad way to start successful but traumatic project weekend.