<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Powershell on cjsommer.com</title><link>https://www.cjsommer.com/tags/powershell/</link><description>Recent content in Powershell on cjsommer.com</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 02 Mar 2018 20:00:00 +0000</lastBuildDate><atom:link href="https://www.cjsommer.com/tags/powershell/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Saturday 723, March 24, 2018 in Rochester, NY. Join us and kick your SQL Server knowledge up a notch!</title><link>https://www.cjsommer.com/post/2018-03-02-speaking-at-sqlsaturday-723/</link><pubDate>Fri, 02 Mar 2018 20:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2018-03-02-speaking-at-sqlsaturday-723/</guid><description>&lt;p&gt;If you are a SQL Server professional and are interested in spending a day with a bunch of other like-minded individuals, SQL Saturday is for you. It’s a day chock full of SQL Server related presentations given by other members of the community.&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;This year I&amp;rsquo;m excited to give 2 presentations!&lt;/p&gt;
&lt;p&gt;Painting with PowerShell. I&amp;rsquo;ve given this presentation before and am excited to be able to do it here again.
&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;</description></item><item><title>SQL Saturday 622. Join me July 29, 2017 in Albany, NY and learn to Paint with PowerShell!</title><link>https://www.cjsommer.com/post/2017-06-13-speaking-at-sqlsaturday-622/</link><pubDate>Tue, 13 Jun 2017 20:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2017-06-13-speaking-at-sqlsaturday-622/</guid><description>&lt;p&gt;If you are a SQL Server professional and are interested in spending a day with a bunch of other like-minded individuals, SQL Saturday is for you. It’s a day chock full of SQL Server related presentations given by other members of the community.&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;Here is a glimpse of my presentation on SQL Server Automation using PowerShell taken from the SQL Saturday event page.&lt;/p&gt;</description></item><item><title>SQL Saturday 619. Join me April 29, 2017 in Rochester, NY and learn to Paint with PowerShell!</title><link>https://www.cjsommer.com/post/2017-03-27-speaking-at-sqlsaturday-619/</link><pubDate>Mon, 27 Mar 2017 20:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2017-03-27-speaking-at-sqlsaturday-619/</guid><description>&lt;p&gt;If you are a SQL Server professional and are interested in spending a day with a bunch of other like-minded individuals, SQL Saturday is for you. It’s a day chock full of SQL Server related presentations given by other members of the community.&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;Here is a glimpse of my presentation on SQL Server Automation using PowerShell taken from the SQL Saturday event page.&lt;/p&gt;</description></item><item><title>Convert User Friendly Retention to DateTime value with PowerShell</title><link>https://www.cjsommer.com/post/2016-10-25-convert-user-friendly-retention-to-datetime-value-with-powershell/</link><pubDate>Tue, 25 Oct 2016 12:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2016-10-25-convert-user-friendly-retention-to-datetime-value-with-powershell/</guid><description>&lt;!-- raw HTML omitted --&gt;
&lt;p&gt;I think the title is fairly descriptive so let me put a little context around it for you. In my SQL Server environment we backup our databases to local disk. Unfortunately we don&amp;rsquo;t have unlimited storage for backups, which means we have to delete the old backups on a regular basis. A very typical practice in the SQL DBA world.&lt;/p&gt;
&lt;p&gt;I was writing a new cmdlet for &lt;!-- raw HTML omitted --&gt;dbatools.io&lt;!-- raw HTML omitted --&gt; (Remove-DbaBackup to be released in October) and needed to decide how I wanted users to provide the retention for their SQL backups. I&amp;rsquo;ve seen a very wide range of backup retention requirements in my career (hours, days, weeks, months, years). I could have coded to the least common denominator of hours and greatly simplified my work, but I wanted to find a more flexible and elegant solution. The last thing I wanted was for people to have to fire up calc.exe, or worse yet having to take off their shoes to figure out how many hours were in a month. This is the function I came up with to create a more user friendly experience with my cmdlet.&lt;/p&gt;</description></item><item><title>Speaking at SQL Saturday 513 in Albany, NY on July 30th - PowerShell and SQL Server</title><link>https://www.cjsommer.com/post/2016-07-18-speaking-at-sql-saturday-513-in-albany-ny-on-july-30th-powershell-and-sql-server/</link><pubDate>Mon, 18 Jul 2016 14:39:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2016-07-18-speaking-at-sql-saturday-513-in-albany-ny-on-july-30th-powershell-and-sql-server/</guid><description>&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;If you are a SQL Server professional and are interested in spending a day with a bunch of other like-minded individuals, SQL Saturday is for you. It’s a day chock full of SQL Server related presentations given by other members of the community.&lt;/p&gt;
&lt;p&gt;Here is a glimpse of my presentation on SQL Server Automation using PowerShell taken from the SQL Saturday event page.&lt;/p&gt;</description></item><item><title>Comparing databases using SSDT</title><link>https://www.cjsommer.com/post/2016-06-23-comparing-databases-using-ssdt/</link><pubDate>Thu, 23 Jun 2016 13:05:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2016-06-23-comparing-databases-using-ssdt/</guid><description>&lt;p&gt;Another Twitter-born blog post! I love getting new ideas from the community. Real world ideas for solving real world problems!&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;
The original question was &amp;ldquo;&lt;!-- raw HTML omitted --&gt;Does SQL Compare or others prods allow me to compare 1 &amp;ldquo;gold&amp;rdquo; db to the 57 &amp;ldquo;identical&amp;rdquo; databases in prod at once? asking for a friend ;)&lt;!-- raw HTML omitted --&gt;&amp;rdquo;. The original question and link to the twitter feed is off to the right.&lt;/p&gt;</description></item><item><title>Painting with PowerShell SQL Server Administration</title><link>https://www.cjsommer.com/post/2016-06-06-painting-with-powershell-sql-server-administration/</link><pubDate>Mon, 06 Jun 2016 13:04:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2016-06-06-painting-with-powershell-sql-server-administration/</guid><description>&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;This blog post is just a quick follow from my presentation last week for the SQL PASS &lt;!-- raw HTML omitted --&gt;PowerShell Virtual Chapter&lt;!-- raw HTML omitted --&gt;.&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;Here is a link to the &lt;!-- raw HTML omitted --&gt;YouTube Video&lt;!-- raw HTML omitted --&gt; of the presentation.&lt;/p&gt;</description></item><item><title>Speaking at SQL Saturday 526 in Rochester on May 14, 2016</title><link>https://www.cjsommer.com/post/2016-04-12-speaking-at-sql-saturday-526-in-rochester-on-may-14-2016/</link><pubDate>Tue, 12 Apr 2016 11:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2016-04-12-speaking-at-sql-saturday-526-in-rochester-on-may-14-2016/</guid><description>&lt;!-- raw HTML omitted --&gt;
&lt;p&gt;If you are a SQL Server professional and are interested in spending a day with a bunch of other like-minded individuals, SQL Saturday is for you. It&amp;rsquo;s a day chock full of SQL Server related presentations given by other members of the community.&lt;/p&gt;
&lt;p&gt;Here is a glimpse of my presentation on SQL Server Automation using PowerShell taken from the SQL Saturday event page.&lt;/p&gt;
&lt;!-- raw HTML omitted --&gt;
&lt;p&gt;If PowerShell isn&amp;rsquo;t your thing that&amp;rsquo;s OK. There are plenty of other topics to choose from. With sessions geared toward Database Development, Database Administration, Business Intellignece, Database Security and even Professional Development, SQL Saturday offers a wide variety of content for everyone.&lt;/p&gt;</description></item><item><title>Use PowerShell to script existing Availability Group creation scripts!</title><link>https://www.cjsommer.com/post/2016-04-04-use-powershell-to-script-existing-availability-group-creation-scripts/</link><pubDate>Mon, 04 Apr 2016 10:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2016-04-04-use-powershell-to-script-existing-availability-group-creation-scripts/</guid><description>&lt;p&gt;Scripts that write scripts! One of my favorites!&lt;/p&gt;
&lt;p&gt;So last night I was up working on an issue with an Availability Group. For whatever reason the cluster resource for the AG would not come online. Looking in SSMS the AG&amp;rsquo;s on both replicas were stuck in &amp;ldquo;Resolving&amp;rdquo;. I beat on the keyboard for almost 2 hours before deciding that rebuilding the AG was my best option. The databases were down and the birds were starting to chirp and I needed to get them back online.&lt;/p&gt;</description></item><item><title>Speaking at SQL Saturday 487 in Ottawa on April 16, 2016</title><link>https://www.cjsommer.com/post/2016-04-03-speaking-at-sql-saturday-487-in-ottawa-on-april-16-2016/</link><pubDate>Sun, 03 Apr 2016 13:42:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2016-04-03-speaking-at-sql-saturday-487-in-ottawa-on-april-16-2016/</guid><description>&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&amp;lt;img alt=&amp;rsquo;&amp;rsquo; class=&amp;lsquo;alignright size-full wp-image-1238 &amp;lsquo;src=&amp;rsquo;/img/2016/04/img_570152b22dc45.png&amp;rsquo; /&amp;gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;If you are a SQL Server professional and are interested in spending a day with a bunch of other like-minded individuals, SQL Saturday is for you. It&amp;rsquo;s a day chock full of SQL Server related presentations given by other members of the community.&lt;/p&gt;
&lt;p&gt;Here is a glimpse of my presentation on SQL Server Automation using PowerShell taken from the SQL Saturday event page.&lt;/p&gt;</description></item><item><title>Running Parameterized Queries against SQL Server using PowerShell</title><link>https://www.cjsommer.com/post/2015-10-13-running-parameterized-queries-against-sql-server-using-powershell/</link><pubDate>Tue, 13 Oct 2015 09:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-10-13-running-parameterized-queries-against-sql-server-using-powershell/</guid><description>&lt;p&gt;For many years I didn&amp;rsquo;t really think about the implications of how I was retrieving data from my SQL Servers in PowerShell. I was just happy that I was able to retrieve the data! As I learned more about SQL Server I started to think of things like SQL injection and using parameterized queries to promote plan reuse.&lt;/p&gt;
&lt;p&gt;I went back and looked at some of the old PowerShell scripts that I had written and found that I was way off! Most of the old scripts would be prime candidates for SQL Injection. I wasn&amp;rsquo;t really concerned early on because I was the one running my scripts and passing in the parameters, but as my scripts became more automated and database driven, they became more vulnerable to SQL Injection. And parameterized queries? What the heck is a parameterized query? I had no clue when I first started out.&lt;/p&gt;</description></item><item><title>How many errors can the PowerShell error buffer hold?</title><link>https://www.cjsommer.com/post/2015-08-04-how-many-errors-can-the-powershell-error-buffer-hold/</link><pubDate>Tue, 04 Aug 2015 09:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-08-04-how-many-errors-can-the-powershell-error-buffer-hold/</guid><description>&lt;!-- raw HTML omitted --&gt;
&lt;p&gt;PowerShell stores errors that it encounters in a circular error buffer variable named $Error. $Error also contains a count property to count the number of errors in the buffer. To figure out how many errors we could hold was pretty straight forward. All I had to do was create a script that generated an error and see how high $error.count got. At this point I didn&amp;rsquo;t even know if there was a maximum or not.&lt;/p&gt;</description></item><item><title>Present at SQL Saturday</title><link>https://www.cjsommer.com/post/2015-07-28-present-at-sql-saturday-386-achievement-unlocked/</link><pubDate>Tue, 28 Jul 2015 08:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-07-28-present-at-sql-saturday-386-achievement-unlocked/</guid><description>&lt;!-- raw HTML omitted --&gt;
&lt;p&gt;I have nothing but wonderful things to say about the SQL Saturday 386 leadership and the army of volunteers they brought along. It was a very well run event. The venue was nice, everything was very well organized, the people were amazingly helpful and friendly, and it made the perfect place for me to turn my presentation up a notch. It&amp;rsquo;s amazing how much of a calming effect can be felt when you are surrounded by such an inviting and amazing group of people. That&amp;rsquo;s really something that I love about the SQL Server community in general.&lt;/p&gt;</description></item><item><title>T-SQL Tuesday 68 - Just Say No to Defaults</title><link>https://www.cjsommer.com/post/2015-07-14-t-sql-tuesday-68-just-say-no-to-defaults/</link><pubDate>Tue, 14 Jul 2015 08:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-07-14-t-sql-tuesday-68-just-say-no-to-defaults/</guid><description>&lt;!-- raw HTML omitted --&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;
Here is a link to the official #tsql2sday invitation from &lt;!-- raw HTML omitted --&gt;Andy Yun&amp;rsquo;s Blog&lt;!-- raw HTML omitted --&gt;. This month&amp;rsquo;s subject is &amp;ldquo;Just Say No to Defaults&amp;rdquo;. If you&amp;rsquo;ve read my blog at all you will know that I have a slight obsession with SQL Server and PowerShell. As far as I am concerned PowerShell is the new gold standard when it comes to scripting and automation in the Windows environment. Add a sprinkle of SQL Server with the SQL Server PowerShell module (SQLPS) and you have a deadly combination as a DBA.&lt;/p&gt;</description></item><item><title>SQL Agent Job Wrapper Part 3 - Handing the Errors in the Wrapper Script</title><link>https://www.cjsommer.com/post/2015-05-26-sql-agent-job-wrapper-part3-error-handling/</link><pubDate>Tue, 26 May 2015 08:15:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-05-26-sql-agent-job-wrapper-part3-error-handling/</guid><description>&lt;p&gt;This is the 3rd installment in a small series of blog posts on how to create a PowerShell wrapper for running SQL Server Agent Jobs. Here are the links to the 2 previous posts and I recommend reading them because all of the posts build on the previous one.&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;Creating a SQL Agent Job Wrapper with PowerShell and SMO - Part 1&lt;!-- raw HTML omitted --&gt;
&lt;!-- raw HTML omitted --&gt;SQL Agent Job Wrapper Part 2 – Adding Error Generation to the Cmdlet&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;</description></item><item><title>SQL Agent Job Wrapper Part 2 - Adding Error Generation to the Cmdlet</title><link>https://www.cjsommer.com/post/2015-05-20-sql-agent-job-wrapper-part2-error-generation/</link><pubDate>Wed, 20 May 2015 08:15:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-05-20-sql-agent-job-wrapper-part2-error-generation/</guid><description>&lt;p&gt;Last week I posted &lt;!-- raw HTML omitted --&gt;Creating a SQL Agent Job Wrapper with PowerShell and SMO&lt;!-- raw HTML omitted --&gt;. In that post I created a couple PowerShell scripts that run a SQL Agent job and wait for it to complete before exiting. That process could be called from the command line, or even from a 3rd party job scheduler if you were so inclined. I recommend checking it out before you continue, because this is a continuation of that post.&lt;/p&gt;</description></item><item><title>Creating a SQL Agent Job Wrapper with PowerShell and SMO</title><link>https://www.cjsommer.com/post/2015-05-13-creating-a-sql-agent-job-wrapper-with-powershell-and-smo/</link><pubDate>Wed, 13 May 2015 08:00:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-05-13-creating-a-sql-agent-job-wrapper-with-powershell-and-smo/</guid><description>&lt;!-- raw HTML omitted --&gt;
&lt;p&gt;I&amp;rsquo;ve seen this question asked a number of times over the past couple weeks and I thought I would share an approach using PowerShell and SMO. But first, let&amp;rsquo;s take a step back and try to understand why someone would want to do this. What&amp;rsquo;s wrong with SQL Agent?&lt;/p&gt;
&lt;p&gt;Well there&amp;rsquo;s really nothing wrong with SQL Agent. The main reason I have seen people asking this question is because their company is looking into using an enterprise job scheduler. An enterprise job scheduler gives an operations group a single location to manage jobs across their whole environment. It allows them to see all the moving parts from a batch processing perspective, even across dissimilar platforms. It also allows them to create more complex workflows across multiple platforms.&lt;/p&gt;</description></item><item><title>Using PowerShell to Export SQL Data to CSV. How well does it perform?</title><link>https://www.cjsommer.com/post/2015-04-28-using-powershell-to-export-sql-data-to-csv-how-well-does-it-perform/</link><pubDate>Tue, 28 Apr 2015 08:15:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-04-28-using-powershell-to-export-sql-data-to-csv-how-well-does-it-perform/</guid><description>&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;So here we are at week 4 of the #SQLNewBlogger challenge. Earlier in the week I responded to the following post on Twitter #sqlhelp, and after I posted my response I thought that this would make a fun blog post. I have used PowerShell to export SQL Server tables to CSV files before so I know that my suggestion works, but I was wondering if I could determine how performance would be for a larger table.&lt;/p&gt;</description></item><item><title>Modify SQL Agent Jobs using PowerShell and SMO</title><link>https://www.cjsommer.com/post/2015-04-14-modify-sqljobs-powershell-smo/</link><pubDate>Tue, 14 Apr 2015 08:15:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-04-14-modify-sqljobs-powershell-smo/</guid><description>&lt;p&gt;So here we are, week 2 of the &lt;!-- raw HTML omitted --&gt;#SQLNewBlogger Challenge&lt;!-- raw HTML omitted --&gt;. This is a follow on to last weeks post &lt;!-- raw HTML omitted --&gt;Monitoring SQL Agent Jobs when you work for Mr Krabs&lt;!-- raw HTML omitted --&gt; where I showed you how to go about monitoring SQL Server agent jobs using PowerShell and SMO. This can be very helpful if you are on a limited budget and can&amp;rsquo;t afford any fancy monitoring tools. &lt;/p&gt;</description></item><item><title>Monitoring SQL Agent Jobs when you work for Mr Krabs</title><link>https://www.cjsommer.com/post/2015-04-01-mrkrabs-sqlagent-job-monitoring/</link><pubDate>Wed, 01 Apr 2015 21:13:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-04-01-mrkrabs-sqlagent-job-monitoring/</guid><description>&lt;p&gt;For those of you who don&amp;rsquo;t know who Mr. Krabs is, he is a character in the TV show Sponge Bob Square Pants. Mr. Krabs owns the Krusty Krab restaurant and is a very frugal business owner. Every decision he makes is driven completely on how it will impact his bottom line.&lt;/p&gt;
&lt;p&gt;Thinking about Mr. Krabs reminds me of one of my first SQL Server DBA jobs. I was starting just as the old DBA was leaving and there wasn&amp;rsquo;t a lot of time for turnover. I was the only DBA on staff, my servers were old, the CPU&amp;rsquo;s slow, the disk drives were small, and none of it was being monitored! Yikes! Monitoring was one thing I knew I had to address right away, but I didn&amp;rsquo;t have a budget to work with! The business just wasn&amp;rsquo;t willing to spend the money on a fancy monitoring application. They were my Mr. Krabs!&lt;/p&gt;</description></item><item><title>Intro to SQL Server Automation with PowerShell</title><link>https://www.cjsommer.com/post/2015-03-30-intro-to-sql-server-automation-with-powershell/</link><pubDate>Mon, 30 Mar 2015 18:17:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-03-30-intro-to-sql-server-automation-with-powershell/</guid><description>&lt;p&gt;March 26th, 2015, a date which will live in infamy!&lt;/p&gt;
&lt;p&gt;Well, at least for me it will. March 26th, 2015 marks the date I gave my first presentation at my local SQL PASS user group meeting. Here is the picture as proof!&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;I was very excited to be able to share some of my knowledge with everyone who showed up. I hope to be able to do it again some time.&lt;/p&gt;</description></item><item><title>Gotcha! PowerShell Array Initialization, Difference between PowerShell 2.0 and 4.0</title><link>https://www.cjsommer.com/post/2015-03-24-posh-20-array-gotcha/</link><pubDate>Tue, 24 Mar 2015 18:24:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-03-24-posh-20-array-gotcha/</guid><description>&lt;p&gt;I like to initialize my arrays by strongly typing my variable as an array, and setting it to null. PowerShell doesn&amp;rsquo;t require strongly typed variables, so why would I want to do this?&lt;/p&gt;
&lt;p&gt;The primary reason is because it allows me to deal with an expected object type later in the code. For arrays it gives me access to a count property, which I don&amp;rsquo;t get with strings, int&amp;rsquo;s or other non-collection type objects.&lt;/p&gt;</description></item><item><title>Using New-TimeSpan to convert friendly time</title><link>https://www.cjsommer.com/post/2015-03-24-new-timespan/</link><pubDate>Tue, 24 Mar 2015 18:16:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-03-24-new-timespan/</guid><description>&lt;p&gt;The question was this:&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;p&gt;This is just a quick/fast snippet in response to that question, but I can think of a ton of enhancements that could made. Hopefully it will be useful as a starting point for someone to customize for their own use.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; Convert-FriendlyTime
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;param&lt;/span&gt; (
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [&lt;span style="color:#66d9ef"&gt;string&lt;/span&gt;]$FriendlyTime 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; )
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; $Converted = $FriendlyTime.Split(&lt;span style="color:#e6db74"&gt;&amp;#34; &amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;switch&lt;/span&gt; ($Converted[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;days&amp;#34;&lt;/span&gt; { $parms = @{&lt;span style="color:#e6db74"&gt;&amp;#34;days&amp;#34;&lt;/span&gt;=$Converted[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]}; &lt;span style="color:#66d9ef"&gt;break&lt;/span&gt; ;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;hours&amp;#34;&lt;/span&gt; { $parms = @{&lt;span style="color:#e6db74"&gt;&amp;#34;hours&amp;#34;&lt;/span&gt;=$Converted[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]}; &lt;span style="color:#66d9ef"&gt;break&lt;/span&gt; ;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;minutes&amp;#34;&lt;/span&gt; { $parms = @{&lt;span style="color:#e6db74"&gt;&amp;#34;minutes&amp;#34;&lt;/span&gt;=$Converted[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]}; &lt;span style="color:#66d9ef"&gt;break&lt;/span&gt; ;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;seconds&amp;#34;&lt;/span&gt; { $parms = @{&lt;span style="color:#e6db74"&gt;&amp;#34;seconds&amp;#34;&lt;/span&gt;=$Converted[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]}; &lt;span style="color:#66d9ef"&gt;break&lt;/span&gt; ;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;default&amp;#34;&lt;/span&gt; { $parms = $null; &lt;span style="color:#66d9ef"&gt;break&lt;/span&gt; ;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; ($parms) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; New-TimeSpan @parms
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; } &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;Throw&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Invalid unit of time &amp;#39;&lt;/span&gt;$FriendlyTime&lt;span style="color:#e6db74"&gt;&amp;#39;. Please use days, hours, minutes or seconds.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Convert-FriendlyTime -FriendlyTime &lt;span style="color:#e6db74"&gt;&amp;#34;2 days&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Convert-FriendlyTime -FriendlyTime &lt;span style="color:#e6db74"&gt;&amp;#34;68 hours&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Convert-FriendlyTime -FriendlyTime &lt;span style="color:#e6db74"&gt;&amp;#34;68 InvalidUnits&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;!-- raw HTML omitted --&gt;</description></item><item><title>Configure SQL Server Agent using SMO</title><link>https://www.cjsommer.com/post/2015-03-24-sql-agent-smo/</link><pubDate>Tue, 24 Mar 2015 18:05:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-03-24-sql-agent-smo/</guid><description>&lt;p&gt;Saw this on twitter and thought I would throw it up on the blog. Easier than responding on twitter.&lt;/p&gt;
&lt;p&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;!-- raw HTML omitted --&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[&lt;span style="color:#66d9ef"&gt;System.Reflection.Assembly&lt;/span&gt;]::LoadWithPartialName(&lt;span style="color:#e6db74"&gt;&amp;#34;Microsoft.SqlServer.Smo&amp;#34;&lt;/span&gt;) | Out-Null;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$SQLServerInstance = &lt;span style="color:#e6db74"&gt;&amp;#34;MSSQLSERVER&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$srv = New-Object &lt;span style="color:#e6db74"&gt;&amp;#34;Microsoft.SqlServer.Management.Smo.Server&amp;#34;&lt;/span&gt; $SQLServerInstance
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$srv.JobServer.MaximumHistoryRows = &lt;span style="color:#ae81ff"&gt;1002&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$srv.JobServer.Alter()
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can manipulate most if not all SQL Server configurations through SMO. This simple post has inspired me a bit. I think it would be useful to show how I came to find the information I needed to modify this setting. The cool thing about PowerShell is that it&amp;rsquo;s in there. All the tools you need already exist. Look back for an expansion of this post in the near future.&lt;/p&gt;</description></item><item><title>Get-DiskSpace</title><link>https://www.cjsommer.com/post/2015-03-24-get-diskspace/</link><pubDate>Tue, 24 Mar 2015 17:40:00 +0000</pubDate><guid>https://www.cjsommer.com/post/2015-03-24-get-diskspace/</guid><description>&lt;p&gt;My cheap and dirty PowerShell script for dumping the disk space usage for a Windows machine. It was originally some snippets I found on the Internet, which I threw into a script and made it my own.&lt;/p&gt;
&lt;p&gt;It uses a simple WMI call to return a set of objects for you to use as you see fit. Most of the time I just pipe it to Format-Table to see the output, but it could be used for other things. Throw in a pipe to Where-Object and you could use it to monitor low disk space. Feel free to bind, spindle or mutilate as you see fit.&lt;/p&gt;</description></item></channel></rss>