The script shown in the first and last screenshot is available here.
Categories: Exchange Server, PowerShell
Tags: Exchange 2010, PowerShell
Comments: No Comments.
The script shown in the first and last screenshot is available here.
This it the output, refreshed every 5 seconds:
An example of when databases are actually doing something:
It’s quick and easy but keep in mind this does not set a default for PowerShell sessions. You’ll have to enter this command in each window you want to specify a DC in.
Set-ADServerSettings –PreferredServer <fqdn>
On the same subject, it’s easy to find out what DC & GC you’re using in a particular PowerShell session. Just execute the following command:
Get-ADServerSettings | fl
Something new I learned today is how to remotely create a registry key using remote PowerShell. You can also modify, query, etc.. See TechNet for a reference on the use of the reg command including valid value types, examples and such.
Invoke-Command -ComputerName <server fqdn> -ScriptBlock {reg add <registry path> /v <value name> /t <value type> /d <data in the key>}
Let me know if you see anything obviously wrong with it. Use at your own risk! :)
#################################
#Copyright 2009 Cohesive Logic LLC
#SCR Health Check Script
#Description – Determines if any of the storage groups on the SCR target server are in an unhealthy state.
##################################Options – Specify the following options for the target Enviroment
#################################
#SCR Target Server – Specify the FQDN SCR Target server to be analyzed
$SCRTarget = “Target Server”
#Exchange Mailbox Server – Specify the FQDN for the Exchange Mailbox Server Source for your SCR Target
$MailboxServer = “Source Mailbox Server”
#SMTP Server – Specify FQDN of a local SMTP server that can be used to relay the warning email
$SMTPServer = “SMTP SEERVER NAME by DNS or IP” -
#EmailRecipient – Specify the email address where the warning email shoudl be sent.
$EmailRcpt = “JoeDoe@server.com”
##################################The email function used to transmit email over using an SMTP relay
function Send-Email([string]$rcpt,$smtpServer,$body) {$msg = New-Object net.Mail.MailMessage
$smtp = New-Object net.Mail.SmtpClient($smtpServer)$msg.From = “ExchangeSCR@Domain.com”
$msg.To.Add($rcpt)
$msg.Subject = “SCR HEALTH WARNING”$msg.Body = $body
$smtp.Send($msg)
}
#The Check-SCR function determines if replication on any of strorage groups of the SCR target server are in an unhealthy state.
#If any storage groups are found to be unheathy
function Check-SCR($MBX,$SCR,$SMTP,$rcpt) {
$MessageBody = $NULL
$ReplicatedSG = Get-StorageGroup -Server $MBX | where {$_.StandbyMachines -ne $NULL} | Select Identity
foreach($SG in $ReplicatedSG) {
if((Get-StorageGroupCopyStatus $SG.Identity -StandbyMachine $SCR).SummaryCopyStatus -ne “Healthy”){
$MessageBody += Get-StorageGroupCopyStatus $SG.Identity -StandbyMachine $SCR | Select Identity,SummaryCopyStatus,CopyQueueLength,ReplayQueueLength LastInspectedLogTime,ServiceDown,Failed,Suspend
}
}
if($MessageBody -ne $NULL){
Send-Email $rcpt $SMTP $MessageBody
}
}Check-SCR $MailboxServer $SCRTarget $SMTPServer $EmailRcpt