Tuesday, 20 October 2020

Solved: Unable to activate Windows server 2016 though GUI. getting error "This Edition Cannot Be Upgraded"

Issue:
1:
Windows server 2016 was rebooting again and again
2:
Unable to activate Windows server 2016 "Microsoft Windows Server 2016 Standard Evaluation" Edition, though GUI to Standard edition. getting error "This Edition Cannot Be Upgraded"

Solution:

Dism /online /Set-Edition:ServerStandard /AcceptEula /ProductKey:12345-qwert-asdfg-zxcvb-qazws

Other findings:
  1. The server was running in VMWare environment.
  2. The server was rebooting again and again.
  3. After looking into the event viewer for the reboot cause found the error "The kernel power manager has initiated a shutdown transition.  Shutdown Reason: Kernel API"
  4. The Dism /online set-edition:serverstand.... command took more than 30 minutes to complete
  5. The server rebooted more than one time after running the DISM command.
  6. the cleaning up process took few hours to complete



Saturday, 17 October 2020

Resolved: [{LED=451 4.4.395 Target host responded with error. -> 421 4.4.1 Connection timed

 Mails stuck in queue, with the following error in queue.

[{LED=451 4.4.395 Target host responded with error. -> 421 4.4.1 Connection timed

the solution was:

Enable-ExchangeCertificate -ThumbPrint "thumbprint of the required new certificate" -services SMTP

Detail:

After updating SSL certificate in Exchange Server 2016 environment, including mailbox servers and edge servers, the mails were getting stuck in queue with the error "[{LED=451 4.4.395 Target host responded with error. -> 421 4.4.1 Connection timed"

after looking into it further, it was found that the new certificate was not enabled for the SMTP service.

So by enabling the new Certificate for the SMTP service, the issue was resolved.

Enable-ExchangeCertificate -ThumbPrint "thumbprint of the required new certificate" -services SMTP

 


Thursday, 30 July 2020

How to import an SSL certificate in the personal store on windows machine

you can use the following command to import an SSL certificate in the personal store for logged in user account on windows machine

certutil -user -p pfxpassword -importPFX pathofCert\abc.pfx


To import an SSL certificate in the personal store for computer account on windows machine

certutil -p pfxpassword -importPFX pathofCert\abc.pfx

P.S: pfxpassword: while generating/exporting the pfx certificate from the CA server or any other machine one which the certificate is already there, you would have given the pfxpassword.
so keep that password noted as you will need it while importing on any machine with the above command or through console. 

Saturday, 18 July 2020

Resolved: "Remove-ADUser : The directory service can perform the requested operation only on a leaf object"

I was trying to delete user object from active directory, which had mailbox, skype for business user, etc..etc. But was getting the error "Remove-ADUser : The directory service can perform the requested operation only on a leaf object" After search on internet i found the i should use the Remove-Adobject command, also need to use the user distinguish name and then with -recursive attribute. Remove-ADobject (Get-ADUser sAMAccountName).DistinguishedName -Recursive I you want to avoid any confirmation for deletion of the user object then can use -confirm attribute as below. Remove-ADobject (Get-ADUser sAMAccountName).DistinguishedName -Recursive -Confirm:$false

Friday, 10 July 2020

How to search and delete email from users mailboxes in office 365

Before proceeding on this task you have To create and run a Content Search, you have to be a member of the

eDiscovery Manager

Compliance Search management role.

To delete messages, you have to be a member of the

Organization Management role group or

Be assigned the Search And Purge management role




Open "Microsoft Exchange Online Powershell Module" with run as admin permission  and first you have to Connect to Security and Compliance via PowerShell

Connect-IPPSSession -UserPrincipalName Nawaz@mydomain.com



and then run the commands below to create the compliance Search and save the result in a veriable ($Search).



$Search=New-ComplianceSearch -Name "RemovePhishingMessage" -ExchangeLocation All -ContentMatchQuery '(Received:4/13/2020..4/14/2020) AND (Subject:"Subject of the email")'



Now you must Start the complainceSearch with the following command


Start-ComplianceSearch -Identity $Search.Identity




You can confirm the status of the complianceSearch with the following command



PS C:\Users\Nawaz> Get-ComplianceSearch ""RemovePhishingMessage

It will show the status like, not started, inprogress, completed.

If completed, you can run the following command which will show you the number of items found through the compliance search, as mentioned in our case is 32.



PS C:\Users\Nawaz> get-ComplianceSearch "RemovePhishingMessage" | fl                                          



RunspaceId                            : 4bef9a2a-4a98-46a4-8e57-f593a43b1

Language                              :

StatusMailRecipients                  : {}

LogLevel                              : Suppressed

IncludeUnindexedItems                 : True

ContentMatchQuery        : (Received:07/09/2020..07/10/2020) AND (Subject:" Notice Password")

SearchType                            : EstimateSearch

HoldNames                             : {}

SearchNames                           : {}

RefinerNames                          : {}

Region                                :

Refiners                              :

Items                                 : 32

Size                                  : 2911505

UnindexedItems                        : 28319

UnindexedSize                         : 79987919058

SuccessResults                        : {Location: abit@mydomain.com, Item count: 7, Total size: 608342,

                                        Location: MUI@mydomain.com, Item count: 4, Total size: 324402,

                                        Location: Mash@mydomain.com, Item count: 3, Total size: 316067,

                                        Location: Irfa@mydomain.com, Item count: 3, Total size: 299224,

                                        Location: Moh@mydomain.com, Item count: 3, Total size: 298679,

                                        Location: athed@mydomain.com, Item count: 3, Total size: 285691,

                                        Location: Nawaz@mydomain.com, Item count: 3, Total size: 280505,

                                        Location: Shahzad.Khurram@mydomain.com, Item count: 6, Total size: 259699,



Run the command below if you want to soft delete the emails.

New-ComplianceSearchAction -SearchName "RemovePhishingMessage" -Purge -PurgeType SoftDelete



Run the command below if you want to hard delete the emails. 

New-ComplianceSearchAction -SearchName "RemovePhishingMessage" -Purge -PurgeType HardDelete

To show the status of all search

Get-ComplianceSearchAction 
to confirm the status.
Get-ComplianceSearchAction -Identity "FromAl_purge" | Format-Table Searchname, JobStartTime, JobProgress, Status

Thursday, 11 June 2020

How to set Database Activation Preference number for a Database in Exchange server 2016

I was working in a project, had to migrate the Exchange Sever 2013 environment to Exchange 2016. The environment was consist of PR (4 servers) and DR (3 servers), Total of 30 databases.

At one point i had to play with the DAG failover/switchover, in which i found that every time i activate any of the DBs on any desired server, after some time (1-2 hours) the DBs automatically move/activate back on the first server in the PR site.

After looking into it more i noticed that the "ActivationPreference" value on that server was lowest, set to "1".
So as per the default behavior of the DAG, every time if there is any issue in the DAG/database copies, the DAG will activate the DB on the server which has the most healthy copy. If all the servers have the healthy copies then the copy on the server with the lowest "ActivationPreference" number , i.e "1", will be activated.

So now i have to change the "ActivationPreference" number of all the 30 DBs but you know from the ECP it was a lengthy task so i followed the following steps in the Exchange management shell and performed it very easily and in a very short time.

First i had to check the current status (ActivationPreference value) of each of the DB with the following command.

Get-MailboxDatabase service1603 | fl servers, ActivationPreference


Then i used the following command to set the "ActivationPreference" value as per my requirement.

Set-MailboxDatabaseCopy -identity ‘service1603\MBS03’ -ActivationPreference 1

To check/verify the changes use the following command again but it took some time to show the updated value but in ECP the update value was appearing. 

Get-MailboxDatabase service1603 | fl servers, ActivationPreference
so you should give it some time or check in ECP the updated values. 


Tuesday, 9 June 2020

How to export last password reset date of Azure AD/office 365 users through powershell

To get the Azure AD or office 365 etc. last password reset date i use the following steps in windows powershell.
1)
login to Azure AD
$credential = Get-Credential

(once prompt for credentials, use your username/password i.e nawaz@mycompany.com/password)

Then you may use one of the following command to connect Azure AD.

2)
Connect-AzureAD -Credential $credential
OR
Connect-MsolService -Credential $credential

Now you should be connected with Azure AD, to confirm you may use type the first few characters of any Azure AD command and press Tab key, if the command showing any suggested command then it means you are connect.

3)
Get the required detail of one user and then get/use the same command for all users.
so lets use

PS C:\Windows\system32> Get-MsolUser -UserPrincipalName nawaz@mycommany.com | select displayname, lastpasswordchangetimestamp                                                                                                               
DisplayName                                                        LastPasswordChangeTimestamp
-----------                                                        ---------------------------
Nawaz Khan System engineer           2/26/2020 7:59:58 AM

Now that we got the desired details for a single user, so we can use the same command, just replacing the -UserPrincipalName with -all switch and exporting the output to a CSV.

Get-MsolUser -All | select DisplayName,LastPasswordChangeTimeStamp >c:\path\LastPasswordChangeDate.csv

Now you may have to wait for the command to complete, it may get time to complete, as per your number of users in Azure.