<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Buck Woody : DBA, PowerShell</title><link>http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/PowerShell/default.aspx</link><description>Tags: DBA, PowerShell</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>PowerShell PowerPack Download</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/04/07/powershell-powerpack-download.aspx</link><pubDate>Wed, 07 Apr 2010 13:30:20 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:24123</guid><dc:creator>BuckWoody</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/24123.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=24123</wfw:commentRss><description>&lt;p&gt;I read &lt;a href="http://redmondmag.com/articles/2010/04/01/pack-some-power-in-your-shell.aspx" target="_blank"&gt;Jeffery Hicks’ article in this month’s Redmond Magazine&lt;/a&gt; on a new add-in for Windows PowerShell 2.0. It’s called the PowerShell Pack and it has a some great new features that I plan to put into place on my production systems as soon as I finished learning and testing them.&lt;/p&gt;  &lt;p&gt;You can &lt;a href="http://code.msdn.microsoft.com/PowerShellPack" target="_blank"&gt;download the pack here if you have PowerShell 2.0&lt;/a&gt;. I’m having a lot of fun with it, and I’ll blog about what I’m learning here in the near future, but you should check it out. The only issue I have with it right now is that you have to load a module and then use get-help to find out what it does, because I haven’t found a lot of other documentation so far.&lt;/p&gt;  &lt;p&gt;The most interesting modules for me are the ones that can run a command elevated (in &lt;strong&gt;PSUserTools&lt;/strong&gt;), the task scheduling commands (in &lt;strong&gt;TaskScheduler&lt;/strong&gt;) and the file system checks and tools (in &lt;strong&gt;FileSystem&lt;/strong&gt;). There’s also a way to create simple Graphical User Interface panels (in ). I plan to string all these together to install a management set of tools on my SQL Server Express Instances, giving the user “task buttons” to backup or restore a database, add or delete users and so on. Yes, I’ll be careful, and yes, I’ll make sure the user is allowed to do that.&lt;/p&gt;  &lt;p&gt;For now, I’m testing the download, but I thought I would share what I’m up to. If you have PowerShell 2.0 and you download the pack, let me know how you use it.&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;" class="MsoNormal"&gt;&lt;font face="Calibri"&gt;&lt;b&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;span style="color:maroon;font-size:10pt;mso-bidi-font-size:11.0pt;mso-bidi-font-family:calibri;mso-ansi-language:en;"&gt;Script Disclaimer, for people who need to be told this sort of thing: &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;span style="color:maroon;font-size:10pt;mso-bidi-font-family:calibri;mso-ansi-language:en;"&gt;           &lt;p&gt;&lt;/p&gt;         &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;span style="color:maroon;font-size:10pt;mso-bidi-font-family:calibri;mso-ansi-language:en;"&gt;&lt;font face="Calibri"&gt;Never trust any script, including those that you find here, until you understand exactly what it does and how it will act on your systems. Always check the script on a test system or Virtual Machine, not a production system. Yes, there are always multiple ways to do things, and this script may not work in every situation, for everything. It’s just a script, people. All scripts on this site are performed by a professional stunt driver on a closed course. Your mileage may vary. Void where prohibited. Offer good for a limited time only. Keep out of reach of small children. Do not operate heavy machinery while using this script. If you experience blurry vision, indigestion or diarrhea during the operation of this script, see a physician immediately.&lt;/font&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=24123" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Administration/default.aspx">Administration</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Downloads/default.aspx">Downloads</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Web/default.aspx">Web</category></item><item><title>Process Improvement and the Data Professional</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/04/06/process-improvement-and-the-data-professional.aspx</link><pubDate>Tue, 06 Apr 2010 13:23:48 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:24098</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/24098.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=24098</wfw:commentRss><description>&lt;p&gt;Don’t be afraid of that title – I’m not talking about &lt;a href="http://en.wikipedia.org/wiki/Six_Sigma" target="_blank"&gt;Six Sigma&lt;/a&gt; or anything super-formal here. In many organizations, there are more folks in other IT roles than in the Data Professional area. In other words, there are more developers, system administrators and so on than there are the “DBA” role. &lt;/p&gt;  &lt;p&gt;That means we often have more to do than the time we need to do it. And, oddly enough, the first thing that is sacrificed is process improvement – the little things we need to do to make the day go faster in the first place. Then we get even more behind, the work piles up and…well, you know all about that.&lt;/p&gt;  &lt;p&gt;Earlier I challenged you to find 10-30 minutes a day to study. Some folks wrote back and asked “where do I start”? Well, why not be super-efficient and combine that time with learning how to make yourself more efficient? Try out a new scripting language, learn a new tool that automates things or find out ways others have automated their systems. In general, find out what you’re doing and how, and then see if that can be improved. It’s kind of like doing a performance tuning gig on yourself!&lt;/p&gt;  &lt;p&gt;If you’re pressed for time, look for bite-sized articles (&lt;a href="http://www.informit.com/guides/content.aspx?g=sqlserver&amp;amp;seqNum=253" target="_blank"&gt;like the ones I’ve done here for PowerShell and SQL Server&lt;/a&gt;) that you can follow in a “serial” fashion. In a short time you’ll have a new set of knowledge you can use to make your day faster.&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=24098" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Administration/default.aspx">Administration</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Career/default.aspx">Career</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category></item><item><title>Open the SQL Server Error Log with PowerShell</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/03/29/open-the-sql-server-error-log-with-powershell.aspx</link><pubDate>Mon, 29 Mar 2010 13:35:52 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:23836</guid><dc:creator>BuckWoody</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/23836.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=23836</wfw:commentRss><description>&lt;p&gt;Using the Server Management Objects (SMO) library, you don’t even need to have the SQL Server 2008 PowerShell Provider to read the SQL Server Error Logs – in fact, you can use regular old everyday PowerShell. Keep in mind you &lt;strong&gt;will&lt;/strong&gt; need the SMO libraries – which can be installed separately or by installing the Client Tools from the SQL Server install media. You could search for errors, store a result as a variable, or act on the returned values in some other way.&lt;/p&gt;  &lt;p&gt;Replace the Machine Name with your server and Instance Name with your instance, but leave the quotes, to make this work on your system:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;[reflection.assembly]::LoadWithPartialName(&amp;quot;Microsoft.SqlServer.Smo&amp;quot;)     &lt;br /&gt;$machineName = &amp;quot;UNIVAC&amp;quot;      &lt;br /&gt;$instanceName = &amp;quot;Production&amp;quot;      &lt;br /&gt;$sqlServer = new-object (&amp;quot;Microsoft.SqlServer.Management.Smo.Server&amp;quot;) &amp;quot;$machineName\$instanceName&amp;quot;      &lt;br /&gt;$sqlServer.ReadErrorLog()&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Want to search for something specific, like the word “Error”? Replace the last line with this:&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;$sqlServer.ReadErrorLog() | where {$_.Text -like &amp;quot;Error*&amp;quot;}&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;" class="MsoNormal"&gt;&lt;font face="Calibri"&gt;&lt;b&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;span style="color:maroon;font-size:10pt;mso-bidi-font-size:11.0pt;mso-bidi-font-family:calibri;mso-ansi-language:en;"&gt;Script Disclaimer, for people who need to be told this sort of thing: &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;span style="color:maroon;font-size:10pt;mso-bidi-font-family:calibri;mso-ansi-language:en;"&gt;           &lt;p&gt;&lt;/p&gt;         &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;span style="color:maroon;font-size:10pt;mso-bidi-font-family:calibri;mso-ansi-language:en;"&gt;&lt;font face="Calibri"&gt;Never trust any script, including those that you find here, until you understand exactly what it does and how it will act on your systems. Always check the script on a test system or Virtual Machine, not a production system. Yes, there are always multiple ways to do things, and this script may not work in every situation, for everything. It’s just a script, people. All scripts on this site are performed by a professional stunt driver on a closed course. Your mileage may vary. Void where prohibited. Offer good for a limited time only. Keep out of reach of small children. Do not operate heavy machinery while using this script. If you experience blurry vision, indigestion or diarrhea during the operation of this script, see a physician immediately.&lt;/font&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=23836" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Administration/default.aspx">Administration</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Start a SQL Server Agent Job using the SQL Server PowerShell Provider</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/02/10/start-a-sql-server-agent-job-using-the-sql-server-powershell-provider.aspx</link><pubDate>Wed, 10 Feb 2010 13:13:45 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22096</guid><dc:creator>BuckWoody</dc:creator><slash:comments>5</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/22096.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=22096</wfw:commentRss><description>&lt;p&gt;Whew!&amp;#160; That’s a mouthfull. Anyway, I thought I would share part of a script I wrote today to help automate (more) from PowerShell. This assumes a few things: that you’re doing this from the SQL Server 2008 PowerShell provider (not just good old regular PowerShell) and that you change the HAL9000 and SQL2K8 parts with your server name and your Instance name. Oh, and the Jobs I start are called “Test” and then something else. That’s the Test* part. You can use a specific name and drop the * or use your own naming convention.&lt;/p&gt;  &lt;p&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;font size="2"&gt;&lt;font face="Calibri"&gt;&lt;font color="#800000"&gt;&lt;strong&gt;Script Disclaimer, for people who need to be told this sort of thing: &lt;/strong&gt;            &lt;p&gt;&lt;/p&gt;         &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;font size="2"&gt;&lt;font face="Calibri"&gt;&lt;font color="#800000"&gt;Never trust any script, including those that you find here, until you understand exactly what it does and how it will act on your systems. Always check the script on a test system or Virtual Machine, not a production system. All scripts on this site are performed by a professional stunt driver on a closed course. Your mileage may vary. Void where prohibited. Offer good for a limited time only. Keep out of reach of small children. Do not operate heavy machinery while using this script. If you experience blurry vision, indigestion or diarrhea during the operation of this script, see a physician immediately. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;# Start a Job named Test in the SQL Server 2008 PowrShell Provider&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;DIR SQLSERVER:\SQL\HAL9000\SQL2K8\JobServer\Jobs\Test* | % {$_.Start()}&lt;/font&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=22096" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Agent/default.aspx">Agent</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>Tools and Processes for “Fitting it all in”</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/01/18/tools-and-processes-for-fitting-it-all-in.aspx</link><pubDate>Mon, 18 Jan 2010 14:42:05 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:21147</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/21147.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=21147</wfw:commentRss><description>&lt;p&gt;Most data professionals I’ve met work in two modes: we plan for our day, and we react to the situations around us. I’m staring at my list of things that I need to do today right now, which is my planned work. Of course, I have no idea how much of that will really get done – it’s optimistic to be sure. On the other hand I have several systems I manage, and at any moment one of them or the people that interface with them may “change state” such that I need to give them some attention.&lt;/p&gt;  &lt;p&gt;So how do I meld the two? Sometimes it can be quite difficult. I’m constantly working through my list in my mind, re-arranging what I’m focusing on based on what I perceive as the highest need. There are, however, some tools that I use each day to help me manage the workflow.&lt;/p&gt;  &lt;p&gt;I use Outlook for tracking everything, since it has a task list (my primary tracking), a calendar, mail and so on. Also I can share the information, it’s on-line so I can see it anywhere, and I can even take it offline onto the plane this week when I fly out of town. &lt;/p&gt;  &lt;p&gt;For the “ad-hoc” work, I rely on a script library, which I keep as SQL Server Management Studio projects. I keep those scripts and projects backed using Microsoft Live Mesh, which synchronizes those files (along with a few other critical files and my IE Favorites) across not only my laptop and primary systems, but even with my Virtual Machines. &lt;/p&gt;  &lt;p&gt;Also for my SQL Server systems I use the Standard Reports I’ve blogged about here. I also use Greg Larsen’s Database Dashboard, and a series of PowerShell scripts that work across my systems, alerting me to any problems. Of course I’m using SQL Server Agent Jobs quite a bit, and I also use Alerts and some Perfmon automation for my monthly baselining.&lt;/p&gt;  &lt;p&gt;So – is this your experience as well? Do you get driven by both planned and unplanned work? What tools and processes do you use to keep it all straight with your SQL Server Instances?&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=21147" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Agent/default.aspx">Agent</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Design/default.aspx">Design</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Management/default.aspx">Management</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Planning/default.aspx">Planning</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Process/default.aspx">Process</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server+Management+Studio/default.aspx">SQL Server Management Studio</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SSMS/default.aspx">SSMS</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Web/default.aspx">Web</category></item><item><title>Performance Counters? There’s a script for that.</title><link>http://sqlblog.com/blogs/buck_woody/archive/2010/01/05/performance-counters-there-s-a-script-for-that.aspx</link><pubDate>Tue, 05 Jan 2010 14:02:15 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:20555</guid><dc:creator>BuckWoody</dc:creator><slash:comments>4</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/20555.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=20555</wfw:commentRss><description>&lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font face="Calibri"&gt;&lt;font color="#000000"&gt;&lt;font size="3"&gt;It’s not hard to get Performance Monitor counters in PowerShell 1.0, and it’s REALLY easy in 2.0. This is one I used yesterday to monitor network bytes in and out on 2.0 (keep all of the green lines in this post on the same line) :         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;font face="Calibri"&gt;&lt;font color="#008000"&gt;get-counter -Counter &amp;quot;\Network Interface(*)\Bytes Total/sec&amp;quot; -SampleInterval 1 -MaxSamples 10         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;   &lt;p&gt;&lt;font color="#000000" size="3" face="Calibri"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font face="Calibri"&gt;&lt;font color="#000000"&gt;&lt;font size="3"&gt;The &lt;i style="mso-bidi-font-style:normal;"&gt;–SampleInterval&lt;/i&gt; is in seconds, and the &lt;i style="mso-bidi-font-style:normal;"&gt;–MaxSamples&lt;/i&gt; sets how many you want. The &lt;i style="mso-bidi-font-style:normal;"&gt;–Counter&lt;/i&gt; parameter is the object and counter you want to monitor. Don’t know what they are for your system? No problem:           &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;font face="Calibri"&gt;&lt;font color="#008000"&gt;get-counter -ListSet *         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;   &lt;p&gt;&lt;font color="#000000" size="3" face="Calibri"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font face="Calibri"&gt;&lt;font color="#000000"&gt;&lt;font size="3"&gt;Need to hit another computer? Easy Peasy – doesn’t even require remoting to be turned on (but you do need to have the rights to hit the perf counters):         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;font face="Calibri"&gt;&lt;font color="#008000"&gt;get-counter -ComputerName COLLOSSUS -Counter &amp;quot;\Network Interface(*)\Bytes Total/sec&amp;quot; -SampleInterval 1 -MaxSamples 10         &lt;p&gt;&lt;/p&gt;       &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;   &lt;p&gt;&lt;font color="#000000" size="3" face="Calibri"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;font color="#000000"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;If your machine happens not to be named “COLLOSSUS”, just change that part &lt;/font&gt;&lt;span style="font-family:wingdings;mso-ascii-font-family:calibri;mso-hansi-font-family:calibri;mso-char-type:symbol;mso-symbol-font-family:wingdings;"&gt;&lt;span style="mso-char-type:symbol;mso-symbol-font-family:wingdings;"&gt;J&lt;/span&gt;&lt;/span&gt;&lt;font face="Calibri"&gt;. And yes, you can use whatever counters you like, including SQL Server locks, blocks, etc. The full reference for get-counter is here: &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;a href="http://technet.microsoft.com/en-us/library/dd367892.aspx"&gt;&lt;u&gt;&lt;font color="#0000ff" size="3" face="Times New Roman"&gt;http://technet.microsoft.com/en-us/library/dd367892.aspx&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;    &lt;p&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;font size="2"&gt;&lt;font face="Calibri"&gt;&lt;font color="#800000"&gt;&lt;strong&gt;Script Disclaimer, for people who need to be told this sort of thing:             &lt;p&gt;&lt;/p&gt;           &lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p style="margin:0in 0in 0pt;" class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style:normal;"&gt;&lt;font size="2"&gt;&lt;font face="Calibri"&gt;&lt;font color="#800000"&gt;Never trust any script, including those that you find here, until you understand exactly what it does and how it will act on your systems. Always check the script on a test system or Virtual Machine, not a production system. All scripts on this site are performed by a professional stunt driver on a closed course. Your mileage may vary. Void where prohibited. Offer good for a limited time only. Keep out of reach of small children. Do not operate heavy machinery while using this script. If you experience blurry vision, indigestion or heartburn during the operation of this script, see a physician.            &lt;p&gt;&lt;/p&gt;         &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=20555" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Developer/default.aspx">Developer</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Performance+Tuning/default.aspx">Performance Tuning</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>SQL Server Best Practices: Protect CmdExec</title><link>http://sqlblog.com/blogs/buck_woody/archive/2009/12/03/sql-server-best-practices-protect-cmdexec.aspx</link><pubDate>Thu, 03 Dec 2009 15:49:34 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:19482</guid><dc:creator>BuckWoody</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/buck_woody/comments/19482.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/buck_woody/commentrss.aspx?PostID=19482</wfw:commentRss><description>&lt;p&gt;In SQL Server, there are times that you need to do things in the operating system, and to allow that there is a feature called CmdExec. This is not always a good thing –whenever you leave the confines of SQL Server and go out to the operating system, you can cause issues, not the least of which are security-related.&lt;/p&gt;  &lt;p&gt;This best practice is primarily aimed at SQL Server 2000 – in SQL Server 2005 and higher, you’ll have these as job step types in SQL Server Agent (or ActiveX). What you should to do is ensure that only the sysadmins role can run CmdExec job steps.&lt;/p&gt;  &lt;p&gt;In SQL Server 2005 and higher, you should use other methods to work with the operating system, such as SQL CLR or PowerShell to handle that with better safety and security. &lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=19482" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Administration/default.aspx">Administration</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Best+Practices/default.aspx">Best Practices</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/DBA/default.aspx">DBA</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Development/default.aspx">Development</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/SQL+Server+2000/default.aspx">SQL Server 2000</category><category domain="http://sqlblog.com/blogs/buck_woody/archive/tags/Tips/default.aspx">Tips</category></item></channel></rss>