Monday 20 September 2021

How to delete all content-emails from a mailbox and make it blank in exchange server 2016

Some time you may have a test mailbox and it may have some unwanted emails and you may need to delete all the emails permanently.

 You can use a simple command as below in Exchange PowerShell

Search-Mailbox -Identity "nawaz" -DeleteContent

Please note that the emails will be deleted permanently and you would not able to recover even from the recoverable items.


Resolved: The term 'New-ComplianceSearch' is not recognized as the name of a cmdlet

 Today i was trying to search and delete an email from user's mailboxes in Exchange online/Office 365.

My steps were as below.

1: Connect-EXOPSSession -UserPrincipalName myadmin@mydomain.com

2:

$Search=New-ComplianceSearch -Name "Remove Phishing Message" -ExchangeLocation All -ContentMatchQuery '(Received:4/13/2016..4/14/2016) AND (Subject:"Action required")' Start-ComplianceSearch -Identity $Search.Identity

But were getting the following error

New-ComplianceSearch : The term 'New-ComplianceSearch' is not recognized as the name of a cmdlet, function, script      file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct   and try again.          

Solution:

Run the following command to connect to "Security & Compliance Center PowerShell"

Connect-IPPSSession -UserPrincipalName khan.nawaz@ptcl.net.pk

and after that is was able to run the New-ComplianceSearch command.

As per TechNet article this command is used to connect to Security & Compliance Center PowerShell or standalone Exchange Online Protection PowerShell using modern authentication. The cmdlet works for MFA or non-MFA enabled accounts.

For further detail:

Connect-IPPSSession (ExchangePowerShell) | Microsoft Docs

and 

Search for and delete email messages in your organization - Microsoft 365 Compliance | Microsoft Docs 

                                               

Thursday 16 September 2021

How to migrate Skype for business users from Skype for business online to skype for business on premise with powershell

Some time you need to offboard your skype users from Skype for business online (Office 365) to your Skype for business on premise infrastructure. you can use the Skype for business Control panel or the PowerShell. To use the PowerShell you can follow the following steps. make sure that your FE server have internet access or access at least to Office 365, and also make sure that you have the required privileges to both Office 365 and on your on premise Skype for business environment.

Then Login to your FE server and open the "Skype for business Server management shell" with Run as administrator privileges. 

Then store your credentials with the following command in $cred variable.

$cred=Get-Credential 

(Note: you should use Global Admin or any other admin users with required rights and the user should be like in admin@yourdomain.onmicrosoft.com format )

then use the following command to move for example the user Abc@domain.com.


Move-CsUser -Identity Abc@domain.com -Target SFB15FEPool.domain.com -HostedMigrationOverrideUrl  https://adminxa.online.lync.com/HostedMigration/hostedmigrationService.svc -Credential $cred  -Confirm:$False 


or you can store the URL in a variable and then use following command.

$url="https://admin1a.online.lync.com/HostedMigration/hostedmigrationService.svc"

Move-CsUser -Identity username@contoso.com -Target pool.corp.contoso.com -Credential $cred -HostedMigrationOverrideUrl $url

(Note: store your HostedMigrationOverrideUrl in $url, which you can find from office 365 and may be some thing like in below format. (only the XA may be different for each tenant)

$url=https://adminXA.online.lync.com/HostedMigration/hostedmigrationService.svc)

For further detail look into the following link.

https://docs.microsoft.com/en-us/previous-versions/office/lync-server-2013/lync-server-2013-move-users-to-lync-online?redirectedfrom=MSDN