Set up an SMTP Replay (or smarthost) in Windows 2012 R2 with PowerShell

PowerShell
I just set up for our servers that need to send mail, we have a smart host relay to sendgrid. Part of the setup is done via PowerShell, part through the GUI. If you can direct me on how to configure the additional steps via PowerShell I would be keenly interested and would update this site. Start by setting up the SMTP Server, which is managed by the IIS 6 Admin console, with these commands from an elevated PowerShell prompt: Import-Module ServerManager Add-WindowsFeature SMTP-Server,Web-Mgmt-Console,WEB-WMI Then follow the steps 2-8 on this SpiceWorks Post I would test from every server that must send email. Here's the PowerShell way to send a test email, using splatting by building $params as a hash table for the parameters then passing in @params. Note that…
Read More

Install SQL Express 2014 or 2016 from PowerShell

PowerShell, SQL
This may be useful for some folks out there. While the documentation on SQL Books online for command line installs is extensive, the examples there are limited, and the troubleshooting steps are not described clearly. You will need to download the SQL installer iso or files and mount or extract them, and locate the setup.exe. For SQL 2014 Take note that: This is installing SQL Express, a /FEATURES parameter was not required. Changes will be required if using a different distribution. This creates a default instance of SQL, change MSSQLSERVER to your desired instance name. Local Windows administrators will have SQL access by default The line of PowerShell code below that defines $params has no carriage returns between the single quotes. The results of a successful or failed install can…
Read More

My first book review! SQL Server 2014 with PowerShell v5 Cookbook

Current Events, PowerShell, SQL
Has been a very busy year for me, haven't posted lately, but was very excited to share this. I've had the opportunity to be a technical reviewer for three PowerShell books this year! One that I've really enjoyed reviewing has just been released, and the publisher Packt is offering an end of year sale for $5 eBook editions. Donabel Santos (sqlbelle.com & @sqlbelle) is a wonderful blogger, author, trainer, and Microsoft MVP. This is her second PowerShell cookbook for SQL, and it's an incredibly useful resource for learning the practical details of PowerShell, both in general and when working with SQL Server. All her examples come with code samples so you can leverage her scripts to get productive right away. You can check out the book on the Packt website. It's only $5 for a great PowerShell & SQL…
Read More

Get your Public IP and Geographic Data with PowerShell

PowerShell
  Always fascinated by what can be done very tersely with PowerShell. I saw an interesting tip on PowerShell.com that gives the geopraphic info on a given public IP. They had a post I dug up a couple years back that determines your public IP dynamically, so I connected the Lego blocks... here is a script that determines your public IP and tells you where you are, using a web page and a REST API. [codesyntax lang="powershell"] #Determine Public IP Dynamically $ipaddress = (Invoke-WebRequest 'http://myip.dnsomatic.com' -UseBasicParsing).Content $infoService = "http://freegeoip.net/xml/$ipaddress" #Get Geographic Data based on my IP $geoip = Invoke-RestMethod -Method Get -URI $infoService $geoip.Response #As a One-Liner (Invoke-RestMethod -Method Get -URI "http://freegeoip.net/xml/$(Invoke-WebRequest 'http://myip.dnsomatic.com' -UseBasicParsing)").Response [/codesyntax]  
Read More

PowerShell brain teaser

PowerShell
I've been following the buzz about the PowerShell Scripting Games on Twitter, and came across this PowerShell brain teaser from beefycode. Here's my answer, wish me luck! In PowerShell, when is the following statement true? Explain why.        ( $a -eq $b ) -ne ( $b -eq $a )   The key to this puzzle can be found in PowerShell help:   help about_Comparison_Operators -ShowWindow   Here's the relevant paragraph from the help result:   When the input to an operator is a scalar value, comparison operators return a Boolean value. When the input is a collection of values, the comparison operators return any matching values. If there are no matches in a collection, comparison operators do not return anything.    When we use the -eq operator in PowerShell, most assume…
Read More

Great time at Florida .Net UG in West Palm

PowerShell, Presentations, Speaking
Whew! Presentation on PowerShell for Developers to the Florida .Net user group went well, and it was a very lively group. I went in expecting to dig deep into applying PowerShell for GUI application development, deployment and the like. But we had a lot of folks very new to PowerShell, and we had a very interactive presentation and discussion with lots of good questions.  I instead focused on using the PowerShell 3 ISE as a starting point to new students to PowerShell, and taking advantage of this tool (along with the basic three Get Cmdlets, remember those? :) ) to make those uncomfortable first steps to learning a new technology as easy as possible. It is my hope that many in the group will get excited about learning something that's…
Read More

Presenting PowerShell for Developers to Florida.net UG in West Palm

PowerShell, Presentations, Speaking
I've been asked to present to the Florida.Net user group in West Palm this week, and chose to present on PowerShell for Developers, and here's why. There are incredible possibilities and utility in PowerShell, most of the marketing and discussion on the web is for I.T. administrators, rather than developers (though there are some signs this is changing.) The conventional wisdom (and humor) tells us that people in I.T. must fit into either of these categories. Here's another perspective. As a consultant and trainer, I need broad familiarity with technology. I'm focused on Windows, with some geek love for Linux :). SQL Server is my technology focus, but Windows Server setup and configuration are important to ensure it runs well. I have built and also supported .Net applications that rely on…
Read More

SQL 2012 and PowerShell 3 talk at Florida.Net UG

PowerShell, Presentations, Speaking, SQL
After some tuning I re-presented my talk on SQL 2012 and PowerShell 3 for the Florida.Net user group. They let me ramble on much longer, so I had the chance to do more demos and step through the code more thoroughly. Recieved some really great feedback, and saw more than a few people may have caught the PowerShell bug :) The updated slides are on SlideShare.net. If I get five or more requests via email or my contact form, I'll post the code as well. Just want to check whether this internet thing is working....
Read More