Querying IIS SMTP Smarthost Settings

Had a request to throw something together to query multiple machines and find the smarthost server that IIS was configured to use.  All I had time for was ‘quick and dirty’ so this is what I came up with;

 

get-adcomputer -filter * | Select-Object dnshostname >c:\servers.txt
Get-WmiObject -Namespace “root\MicrosoftIISv2” -Class “IISSMTPServerSetting” -Filter “Name =’SmtpSvc/1′” -comp (Get-Content c:\servers.txt) | Select-Object smarthost,defaultdomain | export-csv c:\servers.csv -NoTypeInformation

Obvious problem with the above is there is no connectivity check in place so any servers not being enabled for PS Remoting or firewalls in the way will just generate an error

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s