Category Archives: Powershell

Exchange Database is in Dirty Shutdown State Error – Learn to Fix

In this article, we are going to discuss exchange database is in dirty shutdown state. We will also discuss the solution to recover exchange from dirty shutdown which would be applicable for Exchange 2016, 2013, 2010 & 2007. As you might know that Exchange Server database is completely based on JET engine where log files are responsible for maintaining the track of input as well as output operations in the database file. It utilizes the concept of database cache mailbox to decrease the count of input and output operation. When the operation is loaded the cache memory then, it is not committed the information storage, the JET engine marks it as DIRTY. Until all the pending transactions are committed to the database then, it is not measured as updated. Moreover, until the time all the dirty pages are there in the database that is considered as inconsistent. Until the transaction is completed, if the machine shuts down accidentally then, database stay attached to the log file because of which “Exchange Database is in Dirty Shutdown State” error is received on screen. Continue reading Exchange Database is in Dirty Shutdown State Error – Learn to Fix

How To Recover Corrupt Exchange 2016 Database?

In this write up you will learn about how we can recover corrupt Exchange 2016 database files. You will find this process very simple after going through this article. As you might know that Exchange Server users face situation of file corruption many times. After that they all look for the manual procedures and software for recovering the Exchange database. This common problem is called as user mailbox damage and it comes by logical errors in the Exchange Server. There are two types of database (EDB) files in Exchange Server. First, is EDB that contains private data and second, is EDB that contains public folders. EDB is an Exchange Server data repository that contains all the data in a structured manner. Continue reading How To Recover Corrupt Exchange 2016 Database?

Skip CA Checks during Powershell Remoting

Powershell remoting is really a cool thing to have for an administrator. If you can allocate only few bytes in your brain to remember that New-PSSession syntax it can help managing your entire Windows based infrastructure without logging on to a server.

One of my colleagues was trying to logon a Lync box today and he kept getting an error:

 

 

    + CategoryInfo          : OpenError: (System.Manageme….RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException

    + FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed

New-PSSession : [lyncserver.exchange.local] Connecting to remote server lyncserver.exchange.local failed with the

following error message : The server certificate on the destination computer (lyncserver.exchange.local:443) has the

following errors:

The SSL certificate could not be checked for revocation. The server used to check for revocation might be unreachable.

For more information, see the about_Remote_Troubleshooting Help topic.

At line:1 char:12

+ $Session = New-PSSession -ConnectionUri https://lyncserver.exchange.local/ocspo

 

This can happen when the powershell cannot check the revocation status of the certificate on a remote server. In a way it is a good thing to prevent anything malicious and a good sign to trigger an alarm to your security guys. But in some cases if your CA is really offline and you know that. It can become a little problematic situation. Fortunately the way to fix it pretty simple. In fact it is a workaround.

Just use below two lines to get over this

$SessionOptions = New-PSSessionOption –SkipCACheck –SkipCNCheck –SkipRevocationCheck

$Session =  $Session = New-PSSession -ConnectionUri https://lyncserver.exchange.local/ocspowershell –Credential (Get-Credential) –SessionOption $SessionOptions

and then import the session usual way by Import-Session $Session.

Powershell Password Obfuscator

While writing powershell scripts you may have needed to store the username and password inside the script. There are couple of ways to do so. Either you export the password to a text or xml file and then call it inside the script every time the script runs or generate the password combination using another script and save it inside the main script.

Second way of doing it is much easier but requires another powershell script to be run for generation of credentials.

While working on some script I needed to store the credentials inside the same powershell script. Although there was no need of doing so; someone wanted it that way.

This script generates the code that can be directly pasted inside the main script where you want to save your credentials.

Just enter the username (in the format you want) and enter the password associated with that username and click on generate button. That is all! The code you needed is ready in the text box below:

image

This really simple script can be handy in your toolbox if you are a  powershell developer or you do some scripting stuff for fun.

A download of this script is made available at Technet Gallery. You can download the script just by clicking this button 

Script: Finding IIS Servers in Domain

One of our customers is getting ready for a security audit of their critical servers. Indeed Exchange is one of those but there are lot others running IIS on them and exposed to internet through a firewall or some other technology.

Challenge was to find out how many servers in the data center have IIS installed and not in their knowledge. Doing something like this really becomes a challenge when someone has hundreds of servers running inside that cold, noisy and windy storage room Smile with tongue out (Data Center)

Here is a simple script that can help you find the number of IIS servers in an AD domain.

$Error.Clear()
Clear-Host

#$Servers = Get-ADComputer -Filter * -ResultSetSize $null -Properties OperatingSystem | ? { ($_.OperatingSystem -like "Windows Server*") -and ($_.Name -like "BLR-*")}
Foreach ($Server in $Servers) {
Write-Host "Connecting to" $Server.DNSHostName -ForegroundColor Blue
if (Get-WmiObject -ComputerName $Server.DNSHostName -Namespace root -Class __NameSpace -Filter "name=’MicrosoftIISv2’" -ErrorAction SilentlyContinue)
{
    $Found = $Server.DNSHostName
    $Found | Out-File E:\Reports\ServersWithIIS.txt -Force -Append

}

else{
Write-host $Server.DNSHostName + "does not seem to have IIS on it" -ForegroundColor Green
}
}

Again, it is the simplest code that could come upon searching for a ready made script on internet but failing to find one. Hope this helps others too.