How do I restore an Outlook mailbox to an Active Directory user that was deleted and then successfully restored? - powershell

everyone. Sorry if this is difficult to understand, but I accidentally deleted a user profile/account in Active Directory (AD) in Windows Server 2012 R2. I successfully restored the user profile/account to its original state, which was confirmed by the user (They were able to access their previous files and software, while they could not before the restore). The only problem is that their email is having issues. We use Outlook 2016 and Exchange Server 2013. I need to restore the original mailbox to the original Active Directory user. After I restored the original user profile/account, they now have a new mailbox that is empty. They need their original mailbox with their old emails in it and any archived emails for that mailbox. I have found numerous cmdlets to use in PowerShell, but I don’t want to cause any unintentional data loss.
I believe I have found the original mailbox using PowerShell to list any deleted/disabled mailboxes that haven’t been purged after 30 days, and the proper attributes are there (the original shows “Disabled” while the new and empty one has a blank attribute. However, I would love some assistance in this to ensure a successful restoration of the original Active Directory user and their Outlook 2016 mailbox. Can anyone out there please offer some tips or advice? Thank you so much in advance, and I know pictures would help, but I don’t want to post anything unnecessary.

Have a look here:
https://learn.microsoft.com/en-us/exchange/recipients-in-exchange-online/delete-or-restore-mailboxes
Provided you have the appropriate Exchange permissions, you’ll be fine.

Related

Is it possible with PowerShell to find an author in Sharepoint and change it?

A little more context, I'm trying to use PowerShell to search through SharePoint for any files which have a particular Author.
We have an issue where if someone tries to delete a file that is authored by an ex-employee it alerts a different person that they did not have permission for the file to go to recycle bin for some reason and makes them permanently delete it instead. Below is a link of what they get:
Microsoft won't support it as they say they won't supply custom scripts so I was wondering if anyone here had any ideas?

Powershell Script help - Add User and Copy Permissions from Folder

I've tried around a bit, but haven't come up with a good result yet. My powershell skills are also a bit rusty.
What do I have in mind?
I want to read all security groups from a folder. For each security group I search in a domain (Active Directory) for the group and get all users contained in it.
Afterwards I add the user with the same rights again extra to the folder.
Reason: I search for the group or the user in another domain. Both domains are accessible from the same server. The groups will be removed at some point.
How can I do this? I have already tried a bit to read out groups (Get-Acl) etc, but I do not get further.
I do not ask for a complete solution, but just need hints how I could do this. Possibly also how this is then called in Powershell etc.

OneDrive keeps creating copies of new files

I drop a new file into a Onedrive folder which had been shared with me and it instantly starts to create copies of it. For example if I drop in a test.xlsl I instantly start to see:
test.xlsl
test-1.xlsl
test-2.xlsl
test-3.xlsl
test-4.xlsl
test-5.xlsl
...
...
test-124.xlsl
and it goes on and on. Has somebody encountered this anomaly as well?
Okay, I've finally managed to get the answer: I was simply logged in with a different e-mail address into my Microsoft account, not the same which one got the folder shared with.

Office 365 Powershell Empty Deleted Items folder

We currently use Office 365 in the office and I would like to delete all emails from Deleted items folder for a specific users.
I've tried using following command, but it doesn't appear to delete emails in Deleted Items folder
Search-Mailbox "Mailbox.Name" -SearchDumpsterOnly -DeleteContent
Is there any other way to do it?
PS. I have found references on how to do this with cmdlets that no longer exist [export-mailbox for example].
O365 notwithstanding as the same thing would apply to Exchange on-premises.
Search for and delete messages in Exchange 2016
Learn how to search for and purge messages from Exchange 2016 mailboxes.
You can use the New-ComplianceSearch and New-ComplianceSearchAction cmdlets to search for and delete an email message from all mailboxes in your organization. This can help you find and remove potentially harmful or high-risk email, such as:
https://technet.microsoft.com/en-us/library/ff459253(v=exchg.160).aspx
https://support.office.com/en-us/article/Search-for-and-delete-email-messages-in-your-Office-365-organization-Admin-Help-3526fd06-b45f-445b-aed4-5ebd37b3762a
The SearchDumpster = Search recoverable items (Emails that were deleted from the Trash), not the deleted folder.
AS specifically defined in the Exchange cmdlet online help...
-SearchDumpster
The SearchDumpster parameter specifies whether to search the Recoverable Items folder, which is the storage location in which items deleted from the Deleted Items folder or hard-deleted items are stored until they're purged from the mailbox database.
-SearchDumpsterOnly
The SearchDumpsterOnly switch specifies that only the Recoverable Items folder of the specified mailbox be searched. You can also use this switch with the DeleteContent switch to delete messages from the Recoverable Items folder and reduce the size of the folder.
If you are just trying to clear mail because of mail quota issues. Rather than doing this with PoSH, it would be better for you to set a retention policy on the Deleted or other folder as needed to purge content.
The other approach is use the Search cmdlet, to target a folder by date range and delete those.
Your other option is to write a bit more code and use the EWS API to delete items.
Deleting items by using EWS in Exchange
Find out how you can use the EWS Managed API or EWS in Exchange to delete items either by moving them to the Deleted Items folder or to the dumpster.
Have you ever asked yourself what the difference is between moving items to the Deleted Items folder, and moving them to the dumpster? You might be curious about the different options for handling deleted items and how to implement those options in your application. Exchange Web Services (EWS) includes three options for handling deleted items. This article will hopefully clear up any confusion you might have about the differences between them.
https://msdn.microsoft.com/en-us/library/office/dn424760(v=exchg.150).aspx

Is it possible to record the open emails in Outlook 2010 with PowerShell so that they can be opened again later?

This question is very similar to https://stackoverflow.com/questions/6839516/outlook-2010-reopen-messages which was closed as not being a question.
I have a bad habit of keeping emails open in Outlook 2010 as a reminder of what needs to be done during the day since I am constantly interrupted. What I would like to do is use PowerShell to get a list of the open emails so that if I need to close Outlook I know what I was working on before.
I am not worried about Outlook crashing, Outlook normally reopens all of the emails I had been working on automatically; the use case I am dealing with is when I have to manually close Outlook for a patch or to address some other issue.
What I would like to do is query the running Outlook process and see what messages are open; opening a new Outlook process via COM won't work since it would have a different list of open messages.
Does anyone know of a way to do this in PowerShell? I can use another language if needed, but have been attempting to standardize on PowerShell where possible so that other people here can reuse any code I write.
One possibility I have considered is to launch Outlook via PowerShell so that I have a way to interact with the running process.
First of all, you need to get a reference to the running Outlook instance.
$outlook = [System.Runtime.InteropServices.Marshal]::GetActiveObject('Outlook.Application')
Using the application object you then
Iterate through the outlook.Inspectors collection
Ask each individual Inspector for its CurrentItem
Store whatever properties you need from this item (date? subject? entry id?)