Recipient Preview Filter for particular recipient container

Just quick post. You have dynamic distribution group, you need to scope it for special container and you need to preview recipients for that DDL just inside the container. Solution is easy. Use Where condition and with definition of recipient container in for of distinguished name:

 


$x = Get-DynamicDistributionGroup mailNY
GetRrecipient -RecipientPreviewFilter $x.recipientfilter |Where {$_.Distinguishedname -like "*OU=subou,OU=ou,DC=domain,DC=suffix"} |select *city*,distinguishedname

Easy? Yes, but I always forgot how I did it, so that is why I posted it.

SPF validation Powershell script

I have created a script to validate SPF records of your domains against kitterman´s WEB site.

  • Import functions Get-DNS and Validate-SPF into your Powershell profile or Powershell session.
  • Use is very easy. run Validate-SPF <domainname>, it returns if SPF is valid (PASS), invalid (FAIL) or not present (OK) and kittermann´s message as an object.

Update:Requires Windows 8 and newer (Thanks Wojciech)


function Validate-SPF ($domain){
$y = $null
$y = get-dns $domain | where {$_.strings -like "*spf1*"} | select name,strings
$res = $null
$res = "" | select domain,result,message,txt
$res.domain = $domain
if ($y -ne $null){
Write-Host "SPF present: $($y.strings). Checking validity ..." -ForegroundColor Green
$web = Invoke-WebRequest -Uri http://www.kitterman.com/spf/validate.html
$web.forms[0].fields.domain = "$($y.name)"
$result = Invoke-RestMethod http://www.kitterman.com/getspf2.py -Body $web.forms[0].fields
$message = $result.replace("`r`n","--")
$res.message = $result
$res.txt = $message
if ($message -like "*passed*"){
$res.result = "Passed"
} else {
$res.result = "FAIL"}
} else {
$res.message = "N/A"
$res.result = "OK"
$res.txt = "N/A"
}
return $res
}


function Get-DNS ([String]$domain){
resolve-dnsname $domain -type MX
resolve-dnsname $domain -type TXT

}spfvalidator

 

Exchange cmdlets in PowerShell ISE

My colleague made me happy when he described an easy procedure how to import Exchange cmdlets into PowerShell ISE so let me share it here.

  1. Connect to an Exchange server, run Exchange Management Shell and find folder location for Exchange cmdlets by Get-Module and path property.
    8- 10- 2015 7-38-56
  2. Copy the folder to C:\Windows\System32\WindowsPowerShell\v1.0\Modules on your local PC
  3. Restart PowerShell ISE

NirSoft utilities (portable)

Hi, I had to investigate issue at Citrix side without possibility to install troubleshooting tools like Fiddler or Wireshark and I had success to find NirSoft utilities so collection of small and freeware utilities in portable form, hm I would say really nice thing…

http://www.nirsoft.net/utils/index.html

10- 6- 2015 22-55-57

PowerShell Tip: Get string array from your list

Very easy procedure how to get string array from listed items from somewhere (e.g. txt file).

Well, run PS, declare a variable like $something=” paste your lines then close it by ” and convert it into the array $something=something.split(“`n”)

26- 5- 2015 22-31-55

26- 5- 2015 22-28-41

Of course there are a lot of other possibilities how to declare the same array e.g. $array = @(“10.10.10.26″,”10.10.10.35″,”10.10.10.44”), but anyway the paste option is useful thing😉.

Remote Migration And (500) Internal Server Error

Experience with Exchange 2010 based hybrid and the following remote migration failure (move requests/test cmdlet):

  • Microsoft.Exchange.Migration.MigrationServerConnectionFailedException: The connection to the serve
    r ‘mail.ficility.net’ could not be completed. —> Microsoft.Exchange.MailboxReplicationService.Remote
    TransientException: The Mailbox Replication Service could not connect to the remote server because
    the remote server encountered an internal error.
  • The remote server returned an error: (500) Internal Server Error.. –> The content type
    text/html of the response message does not match the content type of the binding (application/soap
    +xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is
    implemented properly.
PS C:\> Test-MigrationServerAvailability -ExchangeRemoteMove -RemoteServer mail.ficility.net -Credentials $GetOnpremCred

RunspaceId : 4da526a1-2d3a-4ec7-b484-c39e436c4bcc
Result : Failed
Message : The connection to the server 'mail.ficility.net' could not be completed.
ConnectionSettings :
SupportsCutover : False
ErrorDetail : Microsoft.Exchange.Migration.MigrationServerConnectionFailedException: The connection to the serve
 r 'mail.ficility.net' could not be completed. ---> Microsoft.Exchange.MailboxReplicationService.Remote
 TransientException: The Mailbox Replication Service could not connect to the remote server because
 the remote server encountered an internal error. The call to 'https://mail.ficility.net/EWS/mrsproxy.
 svc' failed. Error details: The content type text/html of the response message does not match the
 content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be s
 ure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the re
 sponse were: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML dir=ltr><HEAD><TITLE>The page cannot be displayed</TITLE>
 <STYLE id=L_defaultr_1>A:link {
 FONT: 8pt/11pt verdana; COLOR: #ff0000
 }
 A:visited {
 FONT: 8pt/11pt verdana; COLOR: #4e4e4e
 }
 </STYLE>
 <META content=NOINDEX name=ROBOTS>
 <META http-equiv=Content-Type content="text-html; charset=UTF-8">
 <META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
 <BODY bgColor=#ffffff>
 <TABLE cellSpacing=5 cellPadding=3 width=410>
 <TBODY>
 <TR>
 <TD id=L_defaultr_0 valign=middle align=left width=360>
 <H1 id=L_defaultr_2 style="FONT: 13pt/15pt verdana; COLOR: #000000"><ID id=L_defaultr_3><!--
 Problem-->The page cannot be displayed
 </ID></H1></TD></TR>
 <TR>
 <TD width=400 colSpan=2><FONT id=L_defaultr_4
 style="FONT: 8pt/11pt verdana; COLOR: #000000"><ID id=L_defaultr_5><B>Explanation: </B>There
 is a problem with the page you are trying to reach and it cannot be displayed.</ID></FONT></TD></
 TR>
 <TR>
 '. --> The remote server returned an error: (500) Internal Server Error.. --> The content type
 text/html of the response message does not match the content type of the binding (application/soap
 +xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is
 implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE HTML PUBLIC "-//W3C//
 DTD HTML 4.0 Transitional//EN">
 <HTML dir=ltr><HEAD><TITLE>The page cannot be displayed</TITLE>
 <STYLE id=L_defaultr_1>A:link {
 FONT: 8pt/11pt verdana; COLOR: #ff0000
 }
 A:visited {
 FONT: 8pt/11pt verdana; COLOR: #4e4e4e
 }
 </STYLE>
 <META content=NOINDEX name=ROBOTS>
 <META http-equiv=Content-Type content="text-html; charset=UTF-8">
 <META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
 <BODY bgColor=#ffffff>
 <TABLE cellSpacing=5 cellPadding=3 width=410>
 <TBODY>
 <TR>
 <TD id=L_defaultr_0 valign=middle align=left width=360>
 <H1 id=L_defaultr_2 style="FONT: 13pt/15pt verdana; COLOR: #000000"><ID id=L_defaultr_3><!--
 Problem-->The page cannot be displayed
 </ID></H1></TD></TR>
 <TR>
 <TD width=400 colSpan=2><FONT id=L_defaultr_4
 style="FONT: 8pt/11pt verdana; COLOR: #000000"><ID id=L_defaultr_5><B>Explanation: </B>There
 is a problem with the page you are trying to reach and it cannot be displayed.</ID></FONT></TD></
 TR>
 <TR>
 '. --> The remote server returned an error: (500) Internal Server Error. ---> Microsoft.Exchang
 e.MailboxReplicationService.RemoteTransientException: The call to 'https://mail.ficility.net/EWS/mrspr
 oxy.svc' failed. Error details: The content type text/html of the response message does not match
 the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder,
 be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of th
 e response were: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML dir=ltr><HEAD><TITLE>The page cannot be displayed</TITLE>
 <STYLE id=L_defaultr_1>A:link {
 FONT: 8pt/11pt verdana; COLOR: #ff0000
 }
 A:visited {
 FONT: 8pt/11pt verdana; COLOR: #4e4e4e
 }
 </STYLE>
 <META content=NOINDEX name=ROBOTS>
 <META http-equiv=Content-Type content="text-html; charset=UTF-8">
 <META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
 <BODY bgColor=#ffffff>
 <TABLE cellSpacing=5 cellPadding=3 width=410>
 <TBODY>
 <TR>
 <TD id=L_defaultr_0 valign=middle align=left width=360>
 <H1 id=L_defaultr_2 style="FONT: 13pt/15pt verdana; COLOR: #000000"><ID id=L_defaultr_3><!--
 Problem-->The page cannot be displayed
 </ID></H1></TD></TR>
 <TR>
 <TD width=400 colSpan=2><FONT id=L_defaultr_4
 style="FONT: 8pt/11pt verdana; COLOR: #000000"><ID id=L_defaultr_5><B>Explanation: </B>There
 is a problem with the page you are trying to reach and it cannot be displayed.</ID></FONT></TD></
 TR>
 <TR>
 '. --> The remote server returned an error: (500) Internal Server Error.. ---> Microsoft.Exchan
 ge.MailboxReplicationService.RemotePermanentException: The content type text/html of the response
 message does not match the content type of the binding (application/soap+xml; charset=utf-8). If u
 sing a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The
 first 1024 bytes of the response were: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional/
 /EN">
 <HTML dir=ltr><HEAD><TITLE>The page cannot be displayed</TITLE>
 <STYLE id=L_defaultr_1>A:link {
 FONT: 8pt/11pt verdana; COLOR: #ff0000
 }
 A:visited {
 FONT: 8pt/11pt verdana; COLOR: #4e4e4e
 }
 </STYLE>
 <META content=NOINDEX name=ROBOTS>
 <META http-equiv=Content-Type content="text-html; charset=UTF-8">
 <META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
 <BODY bgColor=#ffffff>
 <TABLE cellSpacing=5 cellPadding=3 width=410>
 <TBODY>
 <TR>
 <TD id=L_defaultr_0 valign=middle align=left width=360>
 <H1 id=L_defaultr_2 style="FONT: 13pt/15pt verdana; COLOR: #000000"><ID id=L_defaultr_3><!--
 Problem-->The page cannot be displayed
 </ID></H1></TD></TR>
 <TR>
 <TD width=400 colSpan=2><FONT id=L_defaultr_4
 style="FONT: 8pt/11pt verdana; COLOR: #000000"><ID id=L_defaultr_5><B>Explanation: </B>There
 is a problem with the page you are trying to reach and it cannot be displayed.</ID></FONT></TD></
 TR>
 <TR>
 '. ---> Microsoft.Exchange.MailboxReplicationService.RemotePermanentException: The remote serve
 r returned an error: (500) Internal Server Error.
 --- End of inner exception stack trace ---
 --- End of inner exception stack trace ---
 --- End of inner exception stack trace ---
 at Microsoft.Exchange.MailboxReplicationService.MailboxReplicationServiceFault.<>c__DisplayClas
 s1.<ReconstructAndThrow>b__0()
 at Microsoft.Exchange.MailboxReplicationService.ExecutionContext.Execute(Action operation)
 at Microsoft.Exchange.MailboxReplicationService.MailboxReplicationServiceFault.ReconstructAndTh
 row(String serverName, VersionInformation serverVersion)
 at Microsoft.Exchange.MailboxReplicationService.WcfClientWithFaultHandling`2.<>c__DisplayClass1
 .<CallService>b__0()
 at Microsoft.Exchange.Net.WcfClientBase`1.CallService(Action serviceCall, String context)
 at Microsoft.Exchange.Migration.MigrationExchangeProxyRpcClient.CanConnectToMrsProxy(Fqdn serve
 rName, Guid mbxGuid, NetworkCredential credentials, LocalizedException& error)
 --- End of inner exception stack trace ---
 at Microsoft.Exchange.Migration.DataAccessLayer.ExchangeRemoteMoveEndpoint.VerifyConnectivity()
 at Microsoft.Exchange.Management.Migration.TestMigrationServerAvailability.InternalProcessEndpo
 int(Boolean fromAutoDiscover)
IsValid : True
Identity :
ObjectState : New

Reason:

Mail.ficility.net pointed to TMG with enabled custom web security filter.

TMG:

26- 5- 2015 22-17-08

The filter disabled and then:

PS C:\> Test-MigrationServerAvailability -ExchangeRemoteMove -RemoteServer mail.ficility.net -Credentials $GetOnpremCred

RunspaceId : 0e75133c-e53f-4dec-86cb-f87eb68bbf5c
Result : Success
Message :
ConnectionSettings : <ExchangeConnectionSettings HasAdminPrivilege="True" HasAutodiscovery="False" HasMrsProxy="True" A
 utodiscoverUrl="" IncomingEmailAddress="" IncomingRPCProxyServer="mail.ficility.net" IncomingExchangeS
 erver="mail.ficility.net" IncomingNSPIServer="" IncomingDomain="europe" IncomingUserName="x98490" Encr
 yptedIncomingPassword="AAAAAQXEWAAEEC2a321JsEZNpm0sI75meOsGCWCGSAFlAwQCAQYJYIZIAWUDBAIBBglghkgBZQM
 EAQIEIH0n3HnypPK+ASyxgq4uJEXHwgGP7SSaO0gnsudrdL+wBBCEzLR+aCScgC21Yo5AUc3eIEBhgAiNca5RquKktuEWNqZZc
 4oJHPOZXfz6RRUrYMZaWd5M/XPUawKeIdj10bPj/W0xvzt5R2hsHyYsj1wd4dLq" IncomingAuthentication="Basic" Se
 rverVersion="" TargetDomainName="" SourceMailboxLegDn="" PublicFolderDatabaseServerLegacyDN="" />
SupportsCutover : False
ErrorDetail :
IsValid : True
Identity :
ObjectState : New