Friday, January 1, 2016

[EX2010] Search Mailbox


Need to assign the management Roles to perform the search-mailbox for the user account from which we are running the cmdlet in exchange 2010 SP1 or greater


Roles:
Mailbox Import Export
Mailbox Search

example:
new-managementroleassignment -Name "test" -role "Mailbox Import Export" -User "username"
new-managementroleassignment -Name "test1" -role "Mailbox Search" -User "username" 


1)To search the emails older than 01/26/2011 from a particular user's mailbox
Search-Mailbox –identity “Usr name” -SearchQuery ‘kind:email AND received:<01/26/2011’

2)To search the emails older that 01/01/2011 from a perticluar user's mailbox and delete them.
Search-Mailbox –identity “Usr name” -SearchQuery ‘kind:email AND received:<01/26/2011’ -DeleteContent -Force  

3)To search the emails from the specific mailbox database which are older than 01/26/2011.
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’

4)To search the emails from the specific mailbox database which are older than 01/26/2011 and delete them.
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’ –DeleteContent  -Force  

5)To delete messages from all the users on a server which are older than 01/26/2011.
Get-mailbox –server “servername” –resultsize unlimited | Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’ –DeleteContent  -Force  

6)To search the emails from the specific mailbox database from a perticlar folder in the mailbox
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘In:"folder name"

7)Below example searches the mailbox of myuser and copies the search results to the DiscoveryMailbox in the folder my_user_data.
Search-Mailbox -Identity myuser -SearchQuery 'Subject:”project report”' -TargetMailbox "DiscoveryMailbox" -TargetFolder my_user_data

8)Below example searches Myuser's mailbox for messages that contain the words "project details" in the subject and deletes the messages from the source mailbox.
Search-Mailbox -Identity "Myuser" -SearchQuery 'Subject:"project details"' -DeleteContent
 Note: you can add the delete content at the end to delete all the searched content.

Please find the some key list of AOS search.
To Restrict by File Type:                Use                                        Example
All file types                                 everything                          kind:everything
Communications                           communications                 kind:communications
Contacts                                      contacts                               kind:contacts
E-mail                                         email                                     kind:email
Instant Messenger                        conversations im                    kind:im
Meetings                                      meetings                             kind:meetings
Tasks                                           tasks                                      kind:tasks
Notes                                           notes                                    kind:notes
Documents                                   docs                                       kind:docs
Text documents                            text                                        kind:text
Spreadsheets                               spreadsheets                    kind:spreadsheets
Presentations                               presentations                    kind:presentations
Music                                          music                                    kind:music
Pictures                                       pics                                        kind:pics
Videos                                         videos                                   kind:videos
Folders                                        folders                                  kind:folders
Folder name                                 foldername or in              foldername:mydocs or in:mydocs
Favorites                                      favorites                              kind:favorites

Programs                                     programs                             kind:programs

Thursday, December 31, 2015

[EX2010] Connect Remote EMS to Exchange Server




  • Enable the Windows Integrated authentication in the Powershell virtual directory




    • Use your network logon account to connect to a remote Exchange 2010 server


$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://FQDNofExchangeServer>/PowerShell/ -Authentication Kerberos

Import-PSSession $Session



    • Use a user account that you specify to connect to a remote Exchange 2010 server


$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://FQDNofExchangeServer/PowerShell/ -Authentication Kerberos -Credential $UserCredential

Import-PSSession $Session



Thursday, December 24, 2015

[OFF] Remove Office installation




Fixit to remove Office 2007, 2010: https://support.office.com/en-us/article/Uninstall-or-remove-Microsoft-Office-2010-suites-90635a1d-aec8-4653-b358-67e1b766fc4d

Fixit to remove Office 2013, 2016 and 365: http://support.microsoft.com/kb/2739501/pt-br


For licensing issues:

Apply the correspondent fixit
rename the file token.dat in "C:\Windows\System32\spp\store\2.0\tokens.dat"
Restart the workstation and install Office again

[EX2010] Export Mailboxes to PST



Get-Mailbox –OrganizationalUnit domain.ca/OUName | foreach { New-MailboxExportRequest -Mailbox $_.Alias -FilePath (‘\\server\share\’ + ($_.alias) + ‘.pst’) }

Tuesday, December 8, 2015

[WSRV] Create shortcut to "Find" in ADUC




C:\Windows\System32\rundll32.exe dsquery.dll,OpenQueryWindow

Monday, December 7, 2015

[O365] Migrating mailbox to cloud


$LiveCred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection

Import-PSSession $Session

---------------

$OnPremCreds = Get-Credential

$MigrationEndpointOnPrem = New-MigrationEndpoint -ExchangeRemoteMove -Name OnpremEndpoint -Autodiscover -EmailAddress henwal@azurelab.dk -Credentials $OnPremCreds

In this example, we will migrate all users listed in a CSV file located on our system partition:

$OnboardingBatch = New-MigrationBatch -Name MigrationBatch1 -SourceEndpoint $MigrationEndpointOnprem.Identity -TargetDeliveryDomain azurelab.mail.onmicrosoft.com -CSVData ([System.IO.File]::ReadAllBytes("C:\MigrationBatch1.csv"))

Start-MigrationBatch -Identity $OnboardingBatch.Identity

[ADFS] Web Application Proxy fails with Error Code 0x8007520C


Cannot authenticate WAP in ADFS, after change main settings in either side

We will see the event ID 422 in Event Viewer on WAP server:



Additional Data:

Trust Certificate Thumbprint:
090D9BB9B0471127EDE9CEA66C2AE79223E349FC

Status Code:
Unauthorized

Exception details:
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()

at Microsoft.IdentityServer.Management.Proxy.StsConfigurationProvider.GetStsProxyConfiguration

In ADFS server, we can see event ID 276:

The federation server proxy was not able to authenticate to the Federation Service.
User Action
Ensure that the proxy is trusted by the Federation Service. To do this, log on to the proxy computer with the host name that is identified in the certificate subject name and re-establish trust between the proxy and the Federation Service using the Install-WebApplicationProxy cmdlet.
Additional Data
Certificate details:
Subject Name:
<null>
Thumbprint:
<null>
NotBefore Time:
<null>
NotAfter Time:
<null>

We need to check the certificate: dir Cert:\LocalMachine\My

Using the thumbprint of the certificate that I want the WAP to use, I am prompted for the service account credentials when I use the following command.
Install-WebApplicationProxy -CertificateThumbprint ’36E56E2F7ECE610C330EE370125454BBE5735A74′ -FederationServiceName ‘adfs.techrede.net’