<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Powershell Archives - DBAduck</title>
	<atom:link href="https://www.dbaduck.com/category/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbaduck.com/category/powershell/</link>
	<description>DBA</description>
	<lastBuildDate>Mon, 16 Mar 2026 13:58:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.dbaduck.com/wp-content/uploads/2013/12/cropped-dbaducklogo-2-32x32.png</url>
	<title>Powershell Archives - DBAduck</title>
	<link>https://www.dbaduck.com/category/powershell/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>PowerShell for SQL Server DBAs Course is Finally Here!</title>
		<link>https://www.dbaduck.com/powershell-for-sql-server-dbas-course-is-finally-here/</link>
					<comments>https://www.dbaduck.com/powershell-for-sql-server-dbas-course-is-finally-here/#respond</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Fri, 29 Nov 2024 06:02:24 +0000</pubDate>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<guid isPermaLink="false">https://www.dbaduck.com/?p=4769</guid>

					<description><![CDATA[<p>I have finally finished preparing my Fundamentals of PowerShell for SQL Server DBAs Course. You can see the curriculum at this link PowerShell for DBAs Fundamentals &#124; DBADuck Training School. The class is scheduled to be delivered live and the recordings will be available to you for a year as part of the class. The [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/powershell-for-sql-server-dbas-course-is-finally-here/">PowerShell for SQL Server DBAs Course is Finally Here!</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>I have finally finished preparing my Fundamentals of PowerShell for SQL Server DBAs Course.</p>



<p>You can see the curriculum at this link <a href="https://training.dbaduck.com/p/powershell-for-dbas-fundamentals">PowerShell for DBAs Fundamentals | DBADuck Training School</a>. The class is scheduled to be delivered live and the recordings will be available to you for a year as part of the class.  The enrollment link is live and will allow you to enroll, but make sure you use the discount link below.</p>



<p>BLACK FRIDAY special. For 2 weeks there is a coupon <strong><em>BLACKFRIDAY</em></strong> that will get you $2000.00 off the regular price of $2,995.00. Don&#8217;t miss out on this deal before the end of this year.  If you have any questions you can feel free to use the Contact link.</p>
<p>The post <a href="https://www.dbaduck.com/powershell-for-sql-server-dbas-course-is-finally-here/">PowerShell for SQL Server DBAs Course is Finally Here!</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/powershell-for-sql-server-dbas-course-is-finally-here/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PASS Data Community Summit Presentations part 2</title>
		<link>https://www.dbaduck.com/pass-data-community-summit-presentations-part-2/</link>
					<comments>https://www.dbaduck.com/pass-data-community-summit-presentations-part-2/#respond</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Tue, 21 Nov 2023 03:19:01 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[PASS Summit]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQLServer]]></category>
		<guid isPermaLink="false">https://www.dbaduck.com/?p=4753</guid>

					<description><![CDATA[<p>To all who came to my PASS Summit sessions and those that gave feedback about my presentations, I say Thank You! I read the feedback and understand the comments made. Based on the feedback I am adding a Part 2 for both presentations. Add PowerShell to your DBA Toolbox! and SQL Server 2022 Contained Availability [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/pass-data-community-summit-presentations-part-2/">PASS Data Community Summit Presentations part 2</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>To all who came to my PASS Summit sessions and those that gave feedback about my presentations, I say Thank You!</p>



<figure class="wp-block-image size-large is-resized"><img fetchpriority="high" decoding="async" width="1024" height="758" src="https://www.dbaduck.com/wp-content/uploads/2023/11/6d0cca0c10cb6972d8675d3f51581b77-1024x758.jpg" alt="" class="wp-image-4754" style="aspect-ratio:1.3509234828496042;width:273px;height:auto" srcset="https://www.dbaduck.com/wp-content/uploads/2023/11/6d0cca0c10cb6972d8675d3f51581b77-1024x758.jpg 1024w, https://www.dbaduck.com/wp-content/uploads/2023/11/6d0cca0c10cb6972d8675d3f51581b77-300x222.jpg 300w, https://www.dbaduck.com/wp-content/uploads/2023/11/6d0cca0c10cb6972d8675d3f51581b77-768x568.jpg 768w, https://www.dbaduck.com/wp-content/uploads/2023/11/6d0cca0c10cb6972d8675d3f51581b77-1536x1137.jpg 1536w, https://www.dbaduck.com/wp-content/uploads/2023/11/6d0cca0c10cb6972d8675d3f51581b77.jpg 2000w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>I read the feedback and understand the comments made. Based on the feedback I am adding a Part 2 for both presentations. <strong>Add PowerShell to your DBA Toolbox!</strong> and <strong>SQL Server 2022 Contained Availability Groups</strong>. I am going to be completing the presentations on <a href="https://twitch.tv/dbaduck">Twitch.tv/dbaduck</a> on November 27th at 3:00 PM MDT. </p>



<p>The presentations are <a href="https://www.dbaduck.com/presentations/">linked here</a>.</p>



<p>I will be covering a more deep level of PowerShell for DBAs to complete the more basic side of PowerShell that I presented. If you have any questions that are related please post them to <a href="https://pollgab.com/room/dbaduck">https://pollgab.com/room/dbaduck</a> so that I can address them as part of the broadcast. I would love it if you wanted to attend live to ask the questions in the chat window.</p>



<p>As I said before, I thank you all for your feedback and your attendance and this is why feedback is so important. None of it was brutal but sincere and to the point. I appreciate the opportunity to resolve feedback that I received. I hope to see you there.</p>
<p>The post <a href="https://www.dbaduck.com/pass-data-community-summit-presentations-part-2/">PASS Data Community Summit Presentations part 2</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/pass-data-community-summit-presentations-part-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PowerShell for DBAs Office Hours</title>
		<link>https://www.dbaduck.com/powershell-for-dbas-office-hours/</link>
					<comments>https://www.dbaduck.com/powershell-for-dbas-office-hours/#comments</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Wed, 01 Mar 2023 22:55:56 +0000</pubDate>
				<category><![CDATA[Office Hours]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">https://www.dbaduck.com/?p=4713</guid>

					<description><![CDATA[<p>To celebrate PowerShell month with Brent Ozar (b &#124; i ) and his free PowerShell class, I am hosting Office Hours on Twitch.tv and the questions that I will be answering are those posted by you on the Pollgab/dbaduck site. This is my pollgab room that you can add questions to and upvote them for [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/powershell-for-dbas-office-hours/">PowerShell for DBAs Office Hours</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>To celebrate PowerShell month with Brent Ozar (<a href="https://www.brentozar.com/blog/">b</a> |<a href="https://www.instagram.com/brento"> i </a>) and his <a href="https://www.brentozar.com/archive/2023/03/learn-powershell-in-30-minutes-a-day-free-starting-now/">free PowerShell class</a>, I am hosting Office Hours on <a href="https://twitch.tv/dbaduck">Twitch.tv</a> and the questions that I will be answering are those posted by you on the <a href="https://pollgab.com/room/dbaduck">Pollgab/dbaduck</a> site. This is my pollgab room that you can add questions to and upvote them for me to answer. I may be doing more than just speaking the answers, I am going to be trying to show them in PowerShell as well if they are able to be shown.</p>



<p class="has-medium-font-size"><strong>Event Information</strong></p>



<p>Monday, <a href="https://www.timeanddate.com/worldclock/converter.html?iso=20230306T150000&amp;p1=tz_mt">March 6th at 8:00 AM</a> Mountain Time (click the link for your time)</p>



<p>I am excited to get this started, so I hope you will join me for the first of my Office Hours.</p>



<p></p>
<p>The post <a href="https://www.dbaduck.com/powershell-for-dbas-office-hours/">PowerShell for DBAs Office Hours</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/powershell-for-dbas-office-hours/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Agent PowerShell Job Step with #NOSQLPS</title>
		<link>https://www.dbaduck.com/sql-server-agent-powershell-job-step-with-nosqlps/</link>
					<comments>https://www.dbaduck.com/sql-server-agent-powershell-job-step-with-nosqlps/#comments</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Wed, 06 Apr 2022 04:36:20 +0000</pubDate>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">https://www.dbaduck.com/?p=4625</guid>

					<description><![CDATA[<p>In researching some things for a presentation, I was to give at Intersections, Spring 2022, I came across this documentation page for SQL Server PowerShell that in the SQL Server Agent section it indicates that there is a way to get the Agent Job Step to skip loading the SQLPS module and you get to [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/sql-server-agent-powershell-job-step-with-nosqlps/">SQL Server Agent PowerShell Job Step with #NOSQLPS</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In researching some things for a presentation, I was to give at Intersections, Spring 2022, I came across this documentation page for <a href="https://docs.microsoft.com/en-us/sql/powershell/sql-server-powershell?msclkid=8f06e1c7b56011ecb42db58762054e7f&amp;view=sql-server-ver15" target="_blank" rel="noreferrer noopener">SQL Server PowerShell</a> that in the SQL Server Agent section it indicates that there is a way to get the Agent Job Step to skip loading the SQLPS module and you get to use PowerShell natively and can load whichever modules you would like.</p>



<p>What?  Huge News!</p>



<h2 class="wp-block-heading" id="h-how-is-this-done">How is this done?</h2>



<p>According to the documentation page, you simply would put #NOSQLPS in the first line of the SQL Agent PowerShell Job Step as in the image below, and when the job runs, it will NOT load the SQLPS module. <strong><em>This starts in SQL Server 2019</em></strong>, so it has not been back ported to previous versions of SQL Server.</p>



<p>If you want to test this, you can put the #NOSQLPS in the top of the step and then on the second line put &#8216;Get-Module&#8217; without the quotes and then run the job.  When you look at the job output, you will see nothing. If you remove the #NOSQLPS from the job step and put Get-Module in the line, run the job and then look at the output, you will see the SQLPS module be returned.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="696" height="663" src="https://www.dbaduck.com/wp-content/uploads/2022/04/NOSQLPS_PowerShell_JobStep.png" alt="" class="wp-image-4627" srcset="https://www.dbaduck.com/wp-content/uploads/2022/04/NOSQLPS_PowerShell_JobStep.png 696w, https://www.dbaduck.com/wp-content/uploads/2022/04/NOSQLPS_PowerShell_JobStep-300x286.png 300w" sizes="(max-width: 696px) 100vw, 696px" /><figcaption>SQL Server Agent PowerShell Job Step</figcaption></figure>



<p>Hopefully you found this useful.</p>
<p>The post <a href="https://www.dbaduck.com/sql-server-agent-powershell-job-step-with-nosqlps/">SQL Server Agent PowerShell Job Step with #NOSQLPS</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/sql-server-agent-powershell-job-step-with-nosqlps/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Connecting iSCSI LUNs with PowerShell</title>
		<link>https://www.dbaduck.com/connecting-iscsi-luns-with-powershell/</link>
					<comments>https://www.dbaduck.com/connecting-iscsi-luns-with-powershell/#respond</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Mon, 09 Sep 2019 01:46:01 +0000</pubDate>
				<category><![CDATA[iSCSI]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Clustering]]></category>
		<category><![CDATA[FCI]]></category>
		<guid isPermaLink="false">https://dbaduck.com/?p=580</guid>

					<description><![CDATA[<p>When clustering SQL on Windows Server Core, I had the need to configure the ISCSI LUNs to the server without UI.&#160; I know that there is a UI component called iscsicpl.exe that you can run and it will pop up the simple Windows UI to allow you to click through all the configuration, but I [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/connecting-iscsi-luns-with-powershell/">Connecting iSCSI LUNs with PowerShell</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When clustering SQL on Windows Server Core, I had the need to configure the ISCSI LUNs to the server without UI.&nbsp; I know that there is a UI component called <em><span style="color: #ff0000;"><strong>iscsicpl.exe</strong></span></em> that you can run and it will pop up the simple Windows UI to allow you to click through all the configuration, but I wanted to go purist on this one and learn the nuances of configuration via PowerShell the whole way through.</p>



<p>First you would have a SAN LUN configured for iSCSI which would have a IQN like <strong><em><span style="color: #ff0000;">iqn.1991-05.com.microsoft:winsan-winsql1-target.</span></em></strong> This is a unique identifier for the iSCSI resource and this is what you would connect to for the drive.&nbsp; To make this connection you would use the iSCSI module that has the commands you will see.&nbsp; Below is the example of the connection.</p>



<pre class="lang:PowerShell">
# On Client Computer 
$TargetPortal1 = "10.1.1.1" 
$TargetPortal2 = "10.1.2.1" 
$ISCSIIP1 = "10.1.1.2" 
$ISCSIIP2 = "10.1.2.2" 
New-IscsiTargetPortal -TargetPortalAddress $TargetPortal1 -InitiatorPortalAddress $ISCSIIP1  
New-IscsiTargetPortal -TargetPortalAddress $TargetPortal2 -InitiatorPortalAddress $ISCSIIP2 
</pre>



<figure class="wp-block-image"><a href="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_1.png"><img decoding="async" src="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_1_thumb.png" alt="ClientISCSI_1"/></a></figure>



<p><strong>Figure 1.1 – The same as New Discovery Portal in iscsicpl</strong></p>



<p>&nbsp;</p>



<pre class="lang:powershell">
Start-Sleep -seconds 2

Connect-IscsiTarget -NodeAddress "iqn.1991-05.com.microsoft:winsan-winsql1-target" <code>
	-IsPersistent $true -IsMultipathEnabled $true -TargetPortalAddress $TargetPortal1 </code>
	-InitiatorPortalAddress $ISCSIIP1

Connect-IscsiTarget -NodeAddress "iqn.1991-05.com.microsoft:winsan-winsql1-target" <code>
	-IsPersistent $true -IsMultipathEnabled $true -TargetPortalAddress $TargetPortal2 </code>
	-InitiatorPortalAddress $ISCSIIP2
</pre>



<figure class="wp-block-image"><a href="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_2.png"><img decoding="async" src="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_2_thumb.png" alt="ClientISCSI_2"/></a></figure>



<p>&nbsp;</p>



<p><strong>Figure 1.2 – Connecting with MultiPath IO using 2 different Targets and Initiators</strong></p>



<p>Now you have a drive attached, at least in iSCSI.&nbsp; This drive will be a raw drive and using <strong><em>Get-Disk</em></strong>&nbsp; will show them. This cmdlet is in the <strong><em>Storage</em></strong>&nbsp; module in PowerShell.</p>



<figure class="wp-block-image"><a href="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_Get-Disk.png"><img decoding="async" src="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_Get-Disk_thumb.png" alt="ClientISCSI_Get-Disk"/></a></figure>



<p><strong>Figure 1.3 – Get-Disk in action. Showing the newly attached drive</strong></p>



<p>The next task is to online and configure the new drive so that you can use it. You need to initialize the disk, then create a partition of type GPT and finally format the volume with 64KB blocks for use with SQL Server.</p>



<p><pre class="lang:powershell">
Initialize-Disk -Number 1 -PartitionStyle GPT # Data

New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter E 
</pre></p>



<figure class="wp-block-image"><a href="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_Initialize-Disk_New-Paritition.png"><img decoding="async" src="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_Initialize-Disk_New-Paritition_thumb.png" alt="ClientISCSI_Initialize-Disk_New-Paritition"/></a></figure>



<p><strong>Figure 1.4 – Initialize-Disk and New-Partition to make the drive accessible</strong></p>



<p><pre class="lang:powershell">
Get-Volume -DriveLetter E | 
         Format-Volume -FileSystemLabel DATA -AllocationUnitSize (64KB) -FileSystem NTFS `
                -ShortFileNameSupport $false
</pre></p>



<figure class="wp-block-image"><a href="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_Get-Volume_Format-Volume.png"><img decoding="async" src="https://dbaduck.com/wp-content/uploads/2019/09/ClientISCSI_Get-Volume_Format-Volume_thumb.png" alt="ClientISCSI_Get-Volume_Format-Volume"/></a></figure>



<p><strong>Figure 1.5 – Get-Volume and Format-Volume to finish setting up the drive</strong></p>



<p>This concludes this part of the creation of a drive from the iSCSI side of the house.&nbsp; The entire piece of code is available here.</p>



<p>Happy PowerShelling. Onward in the quest to become a SQL PowerShell DBA.</p>
<p>The post <a href="https://www.dbaduck.com/connecting-iscsi-luns-with-powershell/">Connecting iSCSI LUNs with PowerShell</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/connecting-iscsi-luns-with-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Why Become a PowerShell DBA</title>
		<link>https://www.dbaduck.com/why-become-a-powershell-dba/</link>
					<comments>https://www.dbaduck.com/why-become-a-powershell-dba/#comments</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Wed, 20 Feb 2019 21:33:13 +0000</pubDate>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SMO]]></category>
		<guid isPermaLink="false">https://dbaduck.com/?p=386</guid>

					<description><![CDATA[<p>If you find this article valuable and you decide that you want to get your learn on with PowerShell and SQL Server, there is a SQLSkills class that I am teaching this year, please join me to get a great start in how to get your toolset growing by adding PowerShell to your toolbelt. Early [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/why-become-a-powershell-dba/">Why Become a PowerShell DBA</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><em>If you find this article valuable and you decide that you want to get your learn on with PowerShell and SQL Server, there is a <a href="https://www.sqlskills.com/sql-server-training/ieps/" target="_blank" rel="noopener noreferrer">SQLSkills class</a> that I am teaching this year, please join me to get a great start in how to get your toolset growing by adding PowerShell to your toolbelt. Early Bird discount still available until March 10, 2017.</em></p>
<p>I have heard many times from many people that it is not worth learning PowerShell as a DBA.&nbsp; I have been using PowerShell since v1.0 and have found it to be amazingly rewarding. I will illustrate why this is the case in this entry and hopefully some of it will resonate with you and you will find some worth in learning at least a little PowerShell for your DBA job.</p>
<p>First, PowerShell was built to manage Windows Servers and soon manage some part of Linux servers as DotNet Core comes into play.&nbsp; Back in the day, if you were a DBA and wanted to manage SQL Servers, you used a lot of <a href="https://msdn.microsoft.com/en-us/library/ms162557.aspx" target="_blank" rel="noopener noreferrer">SMO (Shared Management Objects)</a> and that meant programming in C# or pseudo C# in PowerShell. Creating objects, managing properties, etc.. That was not for everyone I know. I have a developer background and an IT background so managing servers and Active Directory and building programs to do things was part of my world a long time ago.&nbsp; But what I found was that there were not a lot of tools in the marketplace for doing things against SQL Server with PowerShell then so it was not widely adopted by DBAs.</p>
<p>In the SQL Server 2008 days, Microsoft wrote some PowerShell Snapins that would give us access to some cmdlets (Commands) in PowerShell to manage some things and introduced a PowerShell Provider for SQL Server that turned your SQL Server into a series of Paths (SQLSERVER:\sql\servername\instancename) and that was pretty powerful, at least to a guy like me, looking to automate many repetitive tasks. With those cmdlets and the provider there began to be a way to now use PowerShell to get at SQL Server without writing .NET code. It certainly did not cover the breadth of the product like Exchange had done with their cmdlets, but it was a start of some love. This is where the dawn of becoming a PowerShell DBA began.</p>
<h2>Now Why Investigate</h2>
<p>For a DBA there are many times you want to know information about your server, and there is plenty of TSQL to get that information. You need to know the DMVs or the system tables to get at that information and for a fairly new DBA, that can be a real challenge. Here is where the paradigm begins. In SMO there are objects (methods, properties) that encapsulate the properties of the objects in SQL Server into a class (Object Oriented term). These classes represent the objects by having the appropriate methods and properties to act on those objects.&nbsp; Let me illustrate.</p>
<p>We all know that there is a Database object in SQL Server and there are many TSQL commands that we can use to find out information such as…</p>
<p>SELECT * FROM sys.databases</p>
<p>SELECT * FROM sys.database_files</p>
<p>and many more….</p>
<p>It is a common practice to create a set of TSQL scripts and take them with you as you go. That is one of the values of longevity in the industry is what you have created and built up.&nbsp; There is no argument from me for this mentality. This is where you parallel with the PowerShell mentality in that you can reuse the scripts later on and not have to remember or rebuild them on the fly. But is there a better way? Maybe, but at least there is “<em>another”</em> way.</p>
<h2>Enter PowerShell</h2>
<p>PowerShell in and of itself is a mechanism to do many things. I advocate DBAs learn it because of the way you can change your job by using Automation, Scripting and Information Gathering that is much different than running TSQL Scripts and copy-pasting them into documents or tables. (or even Excel)&nbsp; I will take you through a couple of scenarios to give you a flavor of an additional tool (not advocating replacing SSMS or any other tool with PowerShell, only making you more efficient) with examples.</p>
<p>Say I want to have a list of databases with their name and recovery model.</p>
<h5>TSQL</h5>
<p>SELECT name, recovery_model FROM sys.databases;</p>
<h5>PowerShell</h5>
<p>Get-SqlDatabase –ServerInstance servername&nbsp; | Select Name, RecoveryModel | Format-Table * –AutoSize</p>
<p>We won’t really go into how you get to be able to run these commands, just to compare the commands. They are not much different than each other, one is run in SSMS or sqlcmd and one is run in PowerShell console or ISE or another tool that will execute PowerShell.&nbsp; The results are pretty similar as well.</p>
<p><a href="http://powershelldba.com/wp-content/uploads/2017/03/sys_databases.jpg"><img decoding="async" title="sys_databases" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="sys_databases" src="http://powershelldba.com/wp-content/uploads/2017/03/sys_databases_thumb.jpg" width="410" height="261"></a></p>
<p><a href="http://powershelldba.com/wp-content/uploads/2017/03/PowerShell-Get-SqlDatabase.jpg"><img loading="lazy" decoding="async" title="PowerShell-Get-SqlDatabase" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="PowerShell-Get-SqlDatabase" src="http://powershelldba.com/wp-content/uploads/2017/03/PowerShell-Get-SqlDatabase_thumb.jpg" width="923" height="195"></a></p>
<p>Now that doesn’t look too scary. You get the same results.&nbsp; Here is how you would get it with the provider.</p>
<p><a href="http://powershelldba.com/wp-content/uploads/2017/03/PowerShell-Get-SqlDatabase-Provider.jpg"><img loading="lazy" decoding="async" title="PowerShell-Get-SqlDatabase-Provider" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="PowerShell-Get-SqlDatabase-Provider" src="http://powershelldba.com/wp-content/uploads/2017/03/PowerShell-Get-SqlDatabase-Provider_thumb.jpg" width="942" height="184"></a></p>
<p>Notice that I used a Path-Like structure to get to the Databases in the Provider.&nbsp; I used the –Force parameter to ensure that I got the System Databases. Now that seems the same, other than the tool. So you ask the question, why do I do it?&nbsp; Why do I learn PowerShell to be able to get the same information?&nbsp; Here is the answer.</p>
<h2>Objects are the answer</h2>
<p>In TSQL you get results in a Grid or Text, you copy and paste or you just look at it and read it. You just get some text back either in PowerShell or TSQL or so it seems.&nbsp; In PowerShell everything is an object and they all have (potentially) methods and properties.&nbsp; Let me illustrate something that is an interesting part of PowerShell and objects.</p>
<p>Say I want to change the recovery model to Full on my DBA database.&nbsp; in TSQL I could do it in a couple of ways and it would look something like this.</p>
<p>ALTER DATABASE databasename SET RECOVERY FULL</p>
<p>Let’s take a look at how you do it with PowerShell and why it would be valuable to get this tool in your toolbelt.</p>
<p><a href="http://powershelldba.com/wp-content/uploads/2017/03/PowerShell-AlterDatabase.jpg"><img loading="lazy" decoding="async" title="PowerShell-AlterDatabase" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="PowerShell-AlterDatabase" src="http://powershelldba.com/wp-content/uploads/2017/03/PowerShell-AlterDatabase_thumb.jpg" width="922" height="199"></a></p>
<p>What you see is the retrieving of the Database object in an SMO object (the provider always returns an SMO object) and there is a Property called RecoveryModel that tells me which recovery mode it is. To set it, the property is read/write so I can change it with the words “FULL”, “SIMPLE” or “BULKLOGGED” and then I use the method Alter() as above.&nbsp; The methods have the double parenthesis () after the method name and I could have inserted ($true) in the parenthesis to do a WITH ROLLBACK IMMEDIATE like I would do if I were changing a property that required full access.&nbsp; Now that looks like it may not be very advantageous, but imagine the next scenario.</p>
<p><a href="http://powershelldba.com/wp-content/uploads/2017/03/PowerShell-Function.jpg"><img loading="lazy" decoding="async" title="PowerShell-Function" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="PowerShell-Function" src="http://powershelldba.com/wp-content/uploads/2017/03/PowerShell-Function_thumb.jpg" width="928" height="586"></a></p>
<p>I create a function to change my recovery model.&nbsp; I can use parameters for my SQL Server instance and the database and the RecoveryModel.&nbsp; Now I have a tool that does not require SSMS to be installed and allows me to call a function to change my recovery model.&nbsp; Once this is written and saved (and even put in a module for easy loading), and loaded into my environment, I can use it pretty easily for any database on any server.</p>
<p>Like I said before, this is contrived and works because I have SMO loaded, which is not hard to do, but this entry is all about why, not how to get things loaded.&nbsp; I have a <a href="http://www.sqlservercentral.com/stairway/91327/" target="_blank" rel="noopener noreferrer">SQL PowerShell Stairway</a> at <a href="http://www.sqlservercentral.com" target="_blank" rel="noopener noreferrer">SqlServerCentral.com</a> that you can go and read to help you get that part worked out.&nbsp; Not hard but not the reason for this post.</p>
<p>Join me in the quest to become a PowerShell DBA. Stay tuned for more on this site and join me in a class soon.</p>
<p>The post <a href="https://www.dbaduck.com/why-become-a-powershell-dba/">Why Become a PowerShell DBA</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/why-become-a-powershell-dba/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>PowerShell month in May with DBAduck</title>
		<link>https://www.dbaduck.com/powershell-month-may-dbaduck/</link>
					<comments>https://www.dbaduck.com/powershell-month-may-dbaduck/#respond</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Tue, 02 May 2017 04:06:33 +0000</pubDate>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLSkills]]></category>
		<guid isPermaLink="false">http://dbaduck.wpengine.com/?p=326</guid>

					<description><![CDATA[<p>I am excited for this month. SQLSkills Training Event 1 for this month revolving around PowerShell is May 8-10 at SQLskills.com training in Chicago. I am teaching the first class of the Immersion event on PowerShell for the DBA. You can see the details in the link on the class. I am super humbled and [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/powershell-month-may-dbaduck/">PowerShell month in May with DBAduck</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I am excited for this month.</p>
<h2>SQLSkills Training</h2>
<p>Event 1 for this month revolving around PowerShell is <strong>May 8-10</strong> at <a href="https://www.sqlskills.com/sql-server-training/" target="_blank" rel="noopener noreferrer">SQLskills.com training</a> in Chicago. I am teaching the first class of the <a href="https://www.sqlskills.com/sql-server-training/ieps/" target="_blank" rel="noopener noreferrer">Immersion event on PowerShell for the DBA</a>. You can see the details in the link on the class.</p>
<p>I am super humbled and excited to teach this class for SQLskills and at the time of this writing there are 3 seats left after we opened more seats for the class. Please join me for a great event.</p>
<p>We will be going over how to get started with PowerShell and then dive right in and learn why a DBA should learn PowerShell and <a href="http://powershelldba.com/2017/03/08/why-become-a-powershell-dba/" target="_blank" rel="noopener noreferrer">why you would ever want to become a PowerShell DBA</a>. There are so many reasons and so much value, I cannot contain it all in this type of post. But we will be having a grand time drinking from a firehose and learning while we do. 🙂</p>
<p>I hope you will join me for this iteration, or plan on another iteration another time. I love PowerShell and look forward to meeting all of you who are going to be there.</p>
<h2>PASS Virtual PowerShell Chapter Meeting</h2>
<p>Event 2 for this month will be on <strong>Wednesday, May 17th at 12:00 PM Eastern Time</strong> I will be presenting to the<a href="http://powershell.pass.org/" target="_blank" rel="noopener noreferrer"> group </a>on Gathering Data for Trending using PowerShell.&nbsp; You can <a href="https://attendee.gotowebinar.com/register/638781453447840257" target="_blank" rel="noopener noreferrer">RSVP here</a> . I will be covering a great topic that I spend a lot of time thinking about. There is a lot of data in SQL Server and a lot of Meta-Data that can tell some great stories about your servers and what the behavior looks like.&nbsp; Ever since working at Microsoft with the Community Research team on Newsgroup Behaviors, I have been hooked on looking at things in SQL Server as far as behaviors go, not just about features and such.&nbsp; So I have created some data gathering scripts to get data and put it into tables with snapshots in time and looking at the information in a different light to see if I can derive how things are working in SQL Server.&nbsp; Join me for a great time and register for the <a href="https://attendee.gotowebinar.com/register/638781453447840257" target="_blank" rel="noopener noreferrer">webinar here</a>.</p>
<h2>SQL Intersection</h2>
<p>Event 3 will be a PreCon at <a href="http://sqlintersection.com" target="_blank" rel="noopener noreferrer">SQLIntersection</a> on <strong>May 20th in Orlando at the Disney Swan Hotel</strong>.&nbsp; If you are going to be there, I hope you will join me and if you are thinking about going, please register and join me there.&nbsp; It is my well-liked PreCon that takes you from 0-60 in using PowerShell as a DBA and a professional that wants to manage SQL Server from a command line instead of clicking your way through everything.&nbsp; I will be teaching how to leverage the shell as well as balancing the use between SSMS and PowerShell to gain another tool in your toolbelt.</p>
<p>This will be a great month focused on PowerShell.</p>
<p>&nbsp;</p>
<p>The post <a href="https://www.dbaduck.com/powershell-month-may-dbaduck/">PowerShell month in May with DBAduck</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/powershell-month-may-dbaduck/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Join me at SQL Intersections in October 2016</title>
		<link>https://www.dbaduck.com/join-sql-intersections-october-2016/</link>
					<comments>https://www.dbaduck.com/join-sql-intersections-october-2016/#respond</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Thu, 29 Sep 2016 03:40:51 +0000</pubDate>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<guid isPermaLink="false">http://dbaduck.wpengine.com/?p=274</guid>

					<description><![CDATA[<p>In October, I will be at SQLintersection at the MGM Grand in Las Vegas, Nevada. You can visit the site to see the full lineup of sessions and workshops. I&#8217;m going to be presenting four, count them 4 sessions on SQL Server topics and 2 Workshops on PowerShell in SQL: Be Friendly to SQL Server with [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/join-sql-intersections-october-2016/">Join me at SQL Intersections in October 2016</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" style="float: right; !important; margin: 0px 0px 10px 20px;" src="http://dbaduck.wpengine.com/wp-content/uploads/2016/09/sql_sp2015_300x250_v2.gif" alt="SQLintersection" /><br />
In October, I will be at <a href="http://sqlintersection.com/" target="_blank" rel="noopener noreferrer">SQLintersection</a> at the MGM Grand in Las Vegas, Nevada.</p>
<p>You can visit the site to see the full lineup of <a href="http://sqlintersection.com/#!/SQL-Conference/sessions" target="_blank" rel="noopener noreferrer">sessions</a> and <a href="http://sqlintersection.com/#!/SQL-Conference/workshops" target="_blank" rel="noopener noreferrer">workshops</a>. I&#8217;m going to be presenting four, count them 4 sessions on SQL Server topics and 2 Workshops on PowerShell in SQL:</p>
<p><strong>Be Friendly to SQL Server with TSQL Best Practices</strong><br />
TSQL is a necessity when interacting with SQL Server so knowing can be half the battle. Performance is always good as the database starts to grow, but building in resilience when you begin is a greater advantage than refactoring. I will go over 5 key things to know when you write TSQL, use DataTypes and/or variables in comparisons and you will also learn about the procedure cache and how to avoid pitfalls there. This is a beginners session but the concepts in this session are a great foundation to begin with. If you are looking for a solid foundation to build on and need the basics to start, this session is definitely for you.</p>
<p><strong>SQL Server Filestream Implementation and Management</strong><br />
Filestream was introduced in SQL 2008 and has been a part of the engine since then. The reasons to use Filestream over BLOB has been talked about in many different ways and for many different reasons. I will take you through how to get SQL Server configured to use Filestream, what that means and how to implement a column that is of Filestream type. I will also go over where the files live and how to stream them outside of the SQL engine instead of pulling them through the engine. Join me for an in depth discussion on this technology. We will also touch on FileTables which was new in SQL 2012.</p>
<p><strong>Managing Availability Groups with PowerShell</strong><br />
Today Availability Groups are all the rage. Being a PowerShell guy I prefer to manage things with PowerShell.  The SQL team has granted us a great toolset in the SQLPS/SqlServer module that allows you to fully manage Availability Groups simply. Join me for a fun filled hour of PowerShell and Availability Groups, you won&#8217;t look at them the same way after we are finished.</p>
<p><strong>SQL Server on Server Core with PowerShell</strong><br />
Ever wondered what the craze of Server Core is all about? There is a lot of power in Core and with it comes the admin challenge of NO GUI.  But there are settings that you want to change in the OS, how do you do that? This session will take you through some of the challenges that are not really challenges when you know. We will use the builtin method of making some changes and also use PowerShell and commandline tools to get you where you want to be with Core. I built a 6 node cluster on Server Core and created it with PowerShell (Cluster and all) and it runs very nicely with a little footprint in RAM for the effort.</p>
<p><strong>WORKSHOP ON TUESDAY, OCTOBER 25, 2016</strong></p>
<p><strong>PowerShell for the DBA from 0-60 in a Day</strong><br />
Think of how many servers or instances you maintain. Putting tools in your toolbox becomes a critical part of your life as a DBA. How many clicks can be reused? We will be taking you from 0&#8211;60 and everywhere in between with how PowerShell fits into a DBA’s day in the life. We will go from getting PowerShell connected to SQL Server to walking away with a toolbox starter kit that will help you get automated and allow you to focus on harder problems than modifying database options or getting information from SQL Server and storing it away for later analysis. The toolbox alone will make it well worth your attendance.</p>
<p><strong>WORKSHOP ON SATURDAY, OCTOBER 29, 2016</strong></p>
<p><strong>PowerShell for the DBA from 60-120 in a Day</strong><br />
This is the next installment of becoming a PowerShell DBA. Now that you have been introduced to PowerShell and have an idea of what you can do, we take it to the next level and start you thinking about tool building and using PowerShell to actually manage instances. We take a look at modules you can use every day and then we talk about building your own modules. PowerShell is becoming more prevalent in the world of DBAs but still has not come to a level that I would like to see in our careers of working smarter not harder. We will be looking at practical items that you can use PowerShell to enhance because DBA work can contain a mass amount of clicking around if you only use Management Studio. We will take the challenge to remove as many clicks as possible from your daily management of databases and database servers. We cover Database Maintenance, monitoring and data gathering. We talk about managing SQL Server instances with PowerShell and last but not least, we will see how to use it to manage Jobs and SQL Server Agent. Join me in the quest to become an effective PowerShell DBA.</p>
<p>Join me in the quest to become a PowerShell DBA.</p>
<p>Hope to see you there!</p>
<p>The post <a href="https://www.dbaduck.com/join-sql-intersections-october-2016/">Join me at SQL Intersections in October 2016</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/join-sql-intersections-october-2016/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Utah Code Camp 2015 Presentations</title>
		<link>https://www.dbaduck.com/utah-code-camp-2015-presentations/</link>
					<comments>https://www.dbaduck.com/utah-code-camp-2015-presentations/#respond</comments>
		
		<dc:creator><![CDATA[dbaduck]]></dc:creator>
		<pubDate>Mon, 23 Mar 2015 02:21:39 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Powershell]]></category>
		<guid isPermaLink="false">http://dbaduck.wpengine.com/?p=190</guid>

					<description><![CDATA[<p>Sorry I am so late, but Thanks to all those that attended my sessions at the Code Camp. Utah Geek Events has been good to me and I want to make sure that everyone gets the presentation materials and the demo files. Links are below. Hope you enjoy. See you again next year. Starting Out [&#8230;]</p>
<p>The post <a href="https://www.dbaduck.com/utah-code-camp-2015-presentations/">Utah Code Camp 2015 Presentations</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sorry I am so late, but Thanks to all those that attended my sessions at the Code Camp.  <a href="http://www.utahgeekevents.com" title="Utah Geek Events" target="_blank" rel="noopener noreferrer">Utah Geek Events</a> has been good to me and I want to make sure that everyone gets the presentation materials and the demo files. Links are below.  Hope you enjoy.<br />
See you again next year.</p>
<p><a href="https://s3.amazonaws.com/stodayfiles/Starting+Out+with+PowerShell.zip" title="Starting out with PowerShell" target="_blank" rel="noopener noreferrer">Starting Out with PowerShell</a></p>
<p><a href="https://s3.amazonaws.com/stodayfiles/Be+Friendly+to+SQL+Server+Demo+Scripts.zip" title="Be Friendly to SQL Server" target="_blank" rel="noopener noreferrer">Be Friendly to SQL Server</a></p>
<p>The post <a href="https://www.dbaduck.com/utah-code-camp-2015-presentations/">Utah Code Camp 2015 Presentations</a> appeared first on <a href="https://www.dbaduck.com">DBAduck</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbaduck.com/utah-code-camp-2015-presentations/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
