Wednesday, 13 October 2021

How to Migrate Skype for business on premise users to skype for business online

 As we know that Microsoft have deprecated skype for business online, so we have to connect Microsoft Teams for migration of skype for business on premise users. 

We have to user Skype for business Power shell on the FE server having internet access.

First save the credentials in a variable $cred.

$cred=Get-Credential

then connect to teams:

Type Connect-MicrosoftTeams and enter the credentials

Place the skype HostedMigrationOverrideUrl in a variable $url

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

Then use the following command

Move-CsUser -Identity nawaz@domain.com -Target sipfed.online.lync.com -Credential $cred -HostedMigrationOverrideUrl $url

then you should get the prompt for confirmation, after entering "Y" the command should be successful and the user should be migrated.

Note: in the skype HostedMigrationOverrideUrl the two yellow highlighted characters (1e) will be different for each organization.

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

How to restore deleted emails in office 365 through powershell

 You may use different commands, for example you want to restore 1 day emails of a user


New-MailboxSearch -Name "Nawaz11-Oct-DeletedEmails" -SourceMailboxes Nawaz@domain.com -TargetMailbox khan@domain.com -StartDate "10/10/2021" -EndDate "10/10/2021"

Friday, 1 October 2021

How to identify the proxy server in Azure AD Password Protection on premise environment

Environment:

Have Active directory 2016 environment, synchronized with Azure AD. Few months back got a requirement from the management to deploy "Azure AD password protection policy for cloud and on-premise". The deployment was completed successfully.

Issue:

Today the management asked for the detail of servers in this environment.

We know that we had installed the agents on all DCs but we also had one Azure AD Password Protection Proxy server as well but lost its name.

Solution:

Could search in the inventory but the easy/quick way was to run the following command. 

 PS C:\Windows\system32> Get-AzureADPasswordProtectionProxy

ServerFQDN      : ap1.domain.com

SoftwareVersion : 1.2.172.0

Domain          : domain.com    

Forest          : domain.com

HeartbeatUTC    : 10/1/2021 10:27:49 AM

AzureTenant     : domain.com

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@pt.net.com

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 

Saturday, 10 July 2021

Resolved: The subscription file failed to load for the following reason: The direct trust certificate of the subscribed Edge Transport server with thumbprint is a duplicate of the certificate of one of the HubTransport servers. Sharing the same certificate between Edge and Hub Transport

Issue:

Due to some issues, i had to re subscribe the edge server.

After creating the edge subscription file on the edge server with the following command.

New-EdgeSubscription –FileName “c:\EdgeSubFile.xml”

then copied the file "EdgeSubFile" to one mailbox server. and tried the following command.

New-EdgeSubscription -FileData ([byte[]]$(Get-Content -Path "c:\EdgeSubFile.xml" -Encoding Byte -ReadCount 0)) -Site "sitename"


 Getting the following Error:

The subscription file failed to load for the following reason: The direct trust certificate of the subscribed Edge Transport server with thumbprint

<Thumprint> is a duplicate of the certificate of one of the HubTransport servers. Sharing the same certificate between Edge and Hub Transport

servers is not allowed.

    + CategoryInfo          : InvalidOperation: (:) [New-EdgeSubscription], InvalidOperationException

Solution:

as mentioned in the error, the issue was with the SSL certificate, So after some searching on some forums, tried the following steps and the issue was resolved/successfully subscribed the edge.

On the edge server

  1. copy/backup of the currently used SSL certificate for SMTP services.
  2. delete that SSL
  3. import another SSL certificate to the personal store of that edge
  4. Enable that SSL for SMTP services
  5. i.e (Enable-ExchangeCertificate -Thumbprint <34434kklkjlkjkdkfjk> -Services SMTP) 
  6. restart the "Microsoft Exchange ADAM" service
  7. create the subscription file again (New-EdgeSubscription –FileName “c:\EdgeSubFile1.xml”)
  8. copy the file maibox server
on mailbox server
in exchange management shell use the following command for new sub subscription.
New-EdgeSubscription -FileData ([byte[]]$(Get-Content -Path "c:\EdgeSubFile.xml" -Encoding Byte -ReadCount 0)) -Site "sitename"
was successfully able to resubscribe
On the edge server

  1. delete the SSL certificate which we imported and assigned to SMTP services before for edge subscription
  2. So open mmc and delete that certificate.
  3. import the valid certificate which we want to use for SMTP services 
  4. enable that new certificate for smtp services 
  5. i.e (Enable-ExchangeCertificate -Thumbprint <34fdsf434kklkfdfjlkjkdkfjk> -Services SMTP)
  6. restart the "Microsoft Exchange ADAM" service on the edge server
on the mailbox server 
restart the Microsoft Exchange Transport and Microsoft Exchange EdgeSync services
Test the subscription with the following power shell commands 

Start-EdgeSynchronization -ForceUpdateCookie -ForceFullSync
should have result as success or inprogress like as below.
Result         : Success
Type           : Configuration
or 
Result         : InProgress
Type           : Recipients

Test-EdgeSynchronization
should have syncstatus Normal, like as below.
RunspaceId                  : 58fdsfad-dfds-4123-adf1-39a802dcd2bd
SyncStatus                  : Normal
UtcNow                      : 7/10/2021 3:55:35 PM

check mailflow/Queue
with get-Queue poweshell command