<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-37819735</id><updated>2012-01-28T13:16:21.152+01:00</updated><category term='Menu'/><category term='Vista'/><category term='CLI'/><category term='Windows Product Key'/><category term='Performance'/><category term='transactionlog'/><category term='SQL'/><category term='bug'/><category term='random'/><category term='SQL Server Product Key'/><category term='formatting'/><category term='WWN HBA PowerShell'/><category term='Trap'/><category term='Test'/><category term='2005'/><category term='array'/><category term='Web'/><category term='Virtual Windows'/><category term='PowerShell'/><category term='filesystem'/><category term='CPU'/><category term='WMI'/><category term='PowerShell v2'/><category term='configuration'/><category term='get-member'/><category term='License'/><category term='Socket'/><category term='logreader'/><category term='script'/><category term='GPS'/><category term='email'/><category term='Dilbert'/><category term='SMO'/><category term='Error'/><category term='WinRAR'/><category term='Quest'/><category term='T-SQL'/><category term='Query'/><category term='Secunia'/><category term='BOFH'/><category term='PSI'/><category term='sort'/><category term='Audit'/><category term='Core'/><title type='text'>JBs Powershell</title><subtitle type='html'>This is the place where I put various small PowerShell bits'n pieces. I hope they can be of use to others.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>63</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-37819735.post-6448785272053190600</id><published>2011-08-11T09:03:00.003+02:00</published><updated>2011-08-11T09:20:01.878+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WWN HBA PowerShell'/><title type='text'>Collect WWN</title><summary type='text'>Due to recent works on migrating a large number of servers and SAN LUNs, I threw together this small script to collect WWN numbers (see WWN on Wikipedia) from servers. Maybe it can be useful for someone else?Save the lines below as wwn.ps1 :## WWN version 1.1## Script to determine HBA WWNs on remote servers (Win 2003+)## Usage: .\wwn.ps1 servername.domain.comParam ($servername)$data = </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/6448785272053190600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=6448785272053190600' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/6448785272053190600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/6448785272053190600'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2011/08/collect-wwn.html' title='Collect WWN'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-6036232371424497197</id><published>2011-04-17T19:26:00.002+02:00</published><updated>2011-04-17T19:36:47.197+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Secunia'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><category scheme='http://www.blogger.com/atom/ns#' term='PSI'/><title type='text'>Secunia PSI &amp; Powershell</title><summary type='text'>I been using Secunia's Personal Software Inspector since it was in beta. This is a free product that I highly recommend. It is currently in version 2.0.For those of you who don't know PSI:The Secunia PSI is a FREE security tool designed to detect vulnerable and out-dated programs and plug-ins which expose your PC to attacks. Attacks exploiting vulnerable programs and plug-ins are rarely blocked </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/6036232371424497197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=6036232371424497197' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/6036232371424497197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/6036232371424497197'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2011/04/secunia-psi-powershell.html' title='Secunia PSI &amp; Powershell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7558790462272974668</id><published>2010-11-15T20:48:00.001+01:00</published><updated>2010-11-15T20:50:28.105+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='2005'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Product Key'/><title type='text'>SQL Server Product Key - SS 2005</title><summary type='text'>In order to extract the Product key from SQL Server 2005, change the following two lines in the previous post:    $regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\Setup"    $regValue1 = "DigitalProductId"To:    $regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\90\ProductID"    $regValue1 = "DigitalProductID77591"</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7558790462272974668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7558790462272974668' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7558790462272974668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7558790462272974668'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2010/11/sql-server-product-key-ss-2005.html' title='SQL Server Product Key - SS 2005'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-3851987856294895192</id><published>2010-11-11T16:57:00.004+01:00</published><updated>2010-11-11T17:03:42.820+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='License'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server Product Key'/><title type='text'>SQL Server Product Key</title><summary type='text'>A while back I wrote a small script to retrieve the Windows license key. Since then I've been asked several times how to retrieve the product key of an SQL Server.So today I threw together this small script to do just thatfunction Get-SQLserverKey {    ## function to retrieve the license key of a SQL 2008 Server.    ## by Jakob Bindslet (jakob@bindslet.dk)    param ($targets = ".")    $hklm = </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/3851987856294895192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=3851987856294895192' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3851987856294895192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3851987856294895192'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2010/11/sql-server-product-key.html' title='SQL Server Product Key'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7269036373086871253</id><published>2009-12-13T21:28:00.004+01:00</published><updated>2009-12-13T21:35:43.635+01:00</updated><title type='text'>SQLmonkeys</title><summary type='text'>A friend and colleague of mine has just launched a new site - go to www.sqlmonkeys.com to have a look.I'm not sure what contest will be added to the site, but I guess it will mainly be about SQL ... and monkeys ...</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7269036373086871253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7269036373086871253' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7269036373086871253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7269036373086871253'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/12/sqlmonkeys.html' title='SQLmonkeys'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_NsDgkRavKXw/SyVPSxPUWNI/AAAAAAAAARA/OhWVm_gD6I0/s72-c/smallsqlmonkey.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-5647227792168427944</id><published>2009-12-13T21:20:00.003+01:00</published><updated>2009-12-13T21:28:20.206+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SMO'/><category scheme='http://www.blogger.com/atom/ns#' term='Audit'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQL: Poor man's audit</title><summary type='text'>Most DBAs have had to examine unknown database/instances in order to evaluate their configuration.I recently had to examine a few SQL servers for a client in order to offer advice on improvement - mainly in the area of "best practice configuration". This is a (simplified) version of a script I wrote in order to do a quick survey of misconfigurations. Please excuse the simple script - it is more </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/5647227792168427944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=5647227792168427944' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5647227792168427944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5647227792168427944'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/12/most-dbas-have-had-to-examine-unknown.html' title='SQL: Poor man&apos;s audit'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7430725291972331451</id><published>2009-10-19T10:35:00.000+02:00</published><updated>2009-10-19T10:36:51.803+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell v2'/><title type='text'>PowerShell v2 Launch Party</title><summary type='text'>PowerShell v2 finally launches October 22nd: http://powerscripting.wordpress.com/2009/10/16/powershell-v2-virtual-launch-party/</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7430725291972331451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7430725291972331451' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7430725291972331451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7430725291972331451'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/10/powershell-v2-launch-party.html' title='PowerShell v2 Launch Party'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7131924678772066565</id><published>2009-06-05T14:50:00.004+02:00</published><updated>2009-06-05T14:54:52.239+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Virtual Windows'/><title type='text'>Virtual Windows &amp; PowerShell</title><summary type='text'>I'm playing around whit Windows 7 and the Virtual Windows feature at the momemt.Naturally I've tried to manipulate Virtual Windows PC through PowerShell. At the moment the possibilities are apparently limited to using COM - with a namespace similar to Virtual PC/Virtual Server:### Virtual Windows (Virtual PC) com object ###$vpc = new-object -com VirtualPC.Application$vms = $</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7131924678772066565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7131924678772066565' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7131924678772066565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7131924678772066565'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/06/virtual-windows-powershell.html' title='Virtual Windows &amp; PowerShell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-588711463096112062</id><published>2009-05-20T19:41:00.008+02:00</published><updated>2009-05-20T20:36:20.828+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Socket'/><category scheme='http://www.blogger.com/atom/ns#' term='WMI'/><category scheme='http://www.blogger.com/atom/ns#' term='CPU'/><category scheme='http://www.blogger.com/atom/ns#' term='Core'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><title type='text'>Getting informationon installed CPUs, Cores and Sockets</title><summary type='text'>A friend and former colleague asked me about a way to obtain rather detailed information on the type and number of CPUs installed in a server, as well as the number of cores present.This is the function I came up with.Please note that this function is incapable of coping nicely with limitations implemented using /NUMPROC in boot.iniThe function should work on Windows 2000 Server and </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/588711463096112062/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=588711463096112062' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/588711463096112062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/588711463096112062'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/05/getting-informationon-installed-cpus.html' title='Getting informationon installed CPUs, Cores and Sockets'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-716152780154375812</id><published>2009-05-08T15:09:00.007+02:00</published><updated>2009-06-06T19:21:33.526+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Test'/><category scheme='http://www.blogger.com/atom/ns#' term='WinRAR'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Testing WinRAR 3.90 beta</title><summary type='text'>I recently had to evaluate the preformance of the Rarsofts new beta of WinRAR.WinRAR is a powerful GUI and CLI archiever that handles many archieve formats.In order to test the preformance I installed WinRAR 3.80 as well as WinRAR 3.90beta1 (in both 32 and 64-bit versions).Here is a light version of the PowerShell script I came up with (please adjust file paths and $source according to your own </summary><link rel='related' href='http://www.rarsoft.com' title='Testing WinRAR 3.90 beta'/><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/716152780154375812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=716152780154375812' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/716152780154375812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/716152780154375812'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/05/testing-winrar-390-beta.html' title='Testing WinRAR 3.90 beta'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-666123701890698121</id><published>2009-02-23T19:09:00.005+01:00</published><updated>2009-02-23T19:15:20.261+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><title type='text'>WebServer investigated</title><summary type='text'>I recently spend some time playing around with creating a bunch of scripts to monitor changes in a web page. While doing this I needed to determine what kind of webserver a given site was hosted on. This is a somewhat simplified version of my solution:function Get-WebServer {    param ($target)    if (-not ($target -like "http://*")) {        $target = "http://" + $target    }    $wr = [</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/666123701890698121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=666123701890698121' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/666123701890698121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/666123701890698121'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/02/webserver-investigated.html' title='WebServer investigated'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-6929497066473014318</id><published>2009-02-09T20:40:00.003+01:00</published><updated>2009-02-09T20:48:16.844+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='BOFH'/><category scheme='http://www.blogger.com/atom/ns#' term='Dilbert'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><category scheme='http://www.blogger.com/atom/ns#' term='Menu'/><title type='text'>CLI Menu in PowerShell</title><summary type='text'>There are a lot of WPF-based PowerShell menu functions and demos available in various places, but for some reason I feel that PowerShell really needs a good, ol' fashion CLI menu.So, here is a quick, sort of hack'ish CLI menu for PowerShell (dont worry, I just made up the individual menu options - can you tell I just reread BOFH recently?).Use the up and down arrows to navigate the menu, and </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/6929497066473014318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=6929497066473014318' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/6929497066473014318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/6929497066473014318'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/02/cli-menu-in-powershell.html' title='CLI Menu in PowerShell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_NsDgkRavKXw/SZCHUeiSuiI/AAAAAAAAAOY/3LxDSeQv52Q/s72-c/ps_menu.PNG' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7333014970178934058</id><published>2009-02-09T00:02:00.001+01:00</published><updated>2009-02-09T00:03:57.068+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Error'/><category scheme='http://www.blogger.com/atom/ns#' term='Trap'/><title type='text'>Trapping errors in Powershell</title><summary type='text'>I just stumbled across this sweet little introduction to trapping errors in PowerShell:http://powershell.com/cs/blogs/tobias/archive/2008/09/29/trapping-errors.aspx</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7333014970178934058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7333014970178934058' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7333014970178934058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7333014970178934058'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/02/trapping-errors-in-powershell.html' title='Trapping errors in Powershell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-5941784814472456906</id><published>2009-02-07T21:48:00.008+01:00</published><updated>2009-02-07T22:13:39.686+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Vista'/><category scheme='http://www.blogger.com/atom/ns#' term='PowerShell'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows Product Key'/><title type='text'>Retrieveing the Windows Product Key</title><summary type='text'>I was recently asked if I knew of a tool capable of retrieving the Product Key from an installed instance of Windows Vista. While there are several such tools available (use google), my solution - naturally - was to write a PowerShell script that can do just that.The script below is based on information from "The Custodian" on Everything2: http://everything2.com/node/1058074I've tested the </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/5941784814472456906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=5941784814472456906' title='25 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5941784814472456906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5941784814472456906'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/02/retrieveing-windows-product-key.html' title='Retrieveing the Windows Product Key'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>25</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-4968881863441102952</id><published>2009-02-05T20:04:00.002+01:00</published><updated>2009-02-05T20:13:55.064+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='T-SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Query'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>T-SQL query with object-based result</title><summary type='text'>Two small functions that can be used to make an T-SQL query, and have the result returned as a standard PowerShell object. This can be useful if - for some reason - you would like to use Sort-Object or similar on the result afterwards.function ConnectSQL {    Param ($server, $query, $database)    $conn = new-object ('System.Data.SqlClient.SqlConnection')    $connString = "Server=$server;</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/4968881863441102952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=4968881863441102952' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/4968881863441102952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/4968881863441102952'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2009/02/t-sql-query-with-object-based-result.html' title='T-SQL query with object-based result'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-310210180899572234</id><published>2008-09-16T21:19:00.001+02:00</published><updated>2008-09-16T22:06:59.749+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='transactionlog'/><category scheme='http://www.blogger.com/atom/ns#' term='logreader'/><category scheme='http://www.blogger.com/atom/ns#' term='Quest'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Read The Transactionlog of SQL Server from PowerShell</title><summary type='text'>Yes, the header is correct. Thanks to Quest Software, the ability to read individual transactions from the transaction log of SQL Server has arrived!If you want to try it out, I've written this very brief quick start guide:Start by downloading the trial version of Quest's LiteSpeed product: www.quest.com (products -&gt; all products -&gt; LiteSpeed)Install the LiteSpeed trial you've just </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/310210180899572234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=310210180899572234' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/310210180899572234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/310210180899572234'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/09/read-transactionlog-of-sql-server-from.html' title='Read The Transactionlog of SQL Server from PowerShell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7199484836546819725</id><published>2008-08-22T19:51:00.001+02:00</published><updated>2008-08-22T19:59:45.388+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Call for inspiration: PowerShell + SQL</title><summary type='text'>I was wondering if anyone out there has any good suggestions for SQL related PowerShell automation that just needs doing?Any suggestions are welcome - if I can find the time, I might even try to create a solution.PSThis blog is now listed at PowerShellComunity.org</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7199484836546819725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7199484836546819725' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7199484836546819725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7199484836546819725'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/08/call-for-inspiration-powershell-sql.html' title='Call for inspiration: PowerShell + SQL'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-56165703082116534</id><published>2008-08-17T11:46:00.000+02:00</published><updated>2008-08-17T12:13:34.456+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SMO'/><category scheme='http://www.blogger.com/atom/ns#' term='configuration'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQL configuration through SMO</title><summary type='text'>If you administer a large number of SQL servers, you might for some reason, have a server that doesn't quite align to your standards.In order to avoid this I find it very nice to be able to extract various configuration settings from my servers.Building on my post from yesterday, I'll post at small script I've been expanding on for some time (the script below is a rather basic version). The </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/56165703082116534/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=56165703082116534' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/56165703082116534'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/56165703082116534'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/08/sql-configuration-through-smo.html' title='SQL configuration through SMO'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7561548856991484417</id><published>2008-08-16T22:21:00.002+02:00</published><updated>2008-08-17T12:13:34.457+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='get-member'/><category scheme='http://www.blogger.com/atom/ns#' term='SMO'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>SMO example</title><summary type='text'>As mentioned before, I spend quite some time creating scripts in PowerShell for managing SQL server. Here is an example of a couple of SMO functions I have found very useful.In the future, I'll try to post some examples that uses the functions belowWe'll start by loading the correct assembly:[void][reflection.assembly]::Load("Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral, </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7561548856991484417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7561548856991484417' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7561548856991484417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7561548856991484417'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/08/smo-example.html' title='SMO example'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-2600759782365994232</id><published>2008-08-15T11:58:00.000+02:00</published><updated>2008-08-17T12:13:34.458+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='random'/><category scheme='http://www.blogger.com/atom/ns#' term='sort'/><title type='text'>Sort-Random</title><summary type='text'>The current Sort-Object cmdlet in PowerShell lacks "random" functionality.Here is a small function that allows youto sort randomly:function sort-random {    process {        [array]$x = $x + $_    }    end {        $x | sort-object {(new-object Random).next()}    }}Usage:1..100 | Sort-Random- or -Get-Process | Sort-Random</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/2600759782365994232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=2600759782365994232' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/2600759782365994232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/2600759782365994232'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/08/sort-random.html' title='Sort-Random'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-4347682873274912320</id><published>2008-07-24T15:13:00.002+02:00</published><updated>2008-08-17T12:13:34.459+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQL queries</title><summary type='text'>There aren't that much written about using PowerShell as a channel for T-SQL, available on the web, so I thought I might give it a shot.The scripts below allows you to query a SQL Server (SELECT statements) and use the returned data, as well as perform queries that doesn't return data (INSERT, UPDATE, DBCC *, etc.).The way these functions are written are in no way ideal, but rather the minimum </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/4347682873274912320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=4347682873274912320' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/4347682873274912320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/4347682873274912320'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/07/sql-through-adonet.html' title='SQL queries'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-5762728650521858586</id><published>2008-07-23T14:37:00.001+02:00</published><updated>2008-08-17T12:13:34.459+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SMO'/><category scheme='http://www.blogger.com/atom/ns#' term='bug'/><title type='text'>A small bug in SMO</title><summary type='text'>I recently encountered what appears to be a small bug in SMO:When accessing the SqlServer.Management.Smo.Wmi.ManagedComputer namespace using a 32bit application (ie. Powershell.exe) from a 64-bit platform (HW &amp; OS), SMO won't return anything for the "ServerInstances" property. If a 64bit application is used everything works just fine.Try the following script from the 32, and 64 bit versions of </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/5762728650521858586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=5762728650521858586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5762728650521858586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5762728650521858586'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/07/small-bug-in-smo.html' title='A small bug in SMO'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7813201880204801732</id><published>2008-07-20T12:46:00.001+02:00</published><updated>2008-08-17T12:13:34.459+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GPS'/><title type='text'>NMEA GPS &amp; 22 lines of PowerShell</title><summary type='text'>Inspired by the python article "GPS + Google Maps Mash-up in 42 lines of code", I decided to create something similar in PowerShell:function Nmea2dec {    Param ([double]$degrees, $o)    $deg = [math]::floor($degrees/100.0)    $frac = (($degrees/100.0) - $deg)/0.6    $ret = $deg + $frac    if ($o -eq "S" -or $o -eq "W") {$ret = $ret * (-1)}    return $ret}$port = new-Object </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7813201880204801732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7813201880204801732' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7813201880204801732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7813201880204801732'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/07/nmea-gps-22-lines-of-powershell.html' title='NMEA GPS &amp; 22 lines of PowerShell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-8591239214443007165</id><published>2008-07-16T18:58:00.000+02:00</published><updated>2008-08-17T12:13:34.460+02:00</updated><title type='text'>Locked file detection</title><summary type='text'>As previously stated here the Blog, I spend quite some time doing automation of SQL Server maintenance.One challenge has been to detect if a given SQL Server was currently locking a specific device file (backup file). To solve this problem I came up with this small function:function TestFileLock {    ## Attempts to open a file and trap the resulting error if the file is already open/locked    </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/8591239214443007165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=8591239214443007165' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/8591239214443007165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/8591239214443007165'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/07/locked-file-detection.html' title='Locked file detection'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-4649042790731539236</id><published>2008-07-12T23:53:00.002+02:00</published><updated>2008-08-17T12:13:34.461+02:00</updated><title type='text'>Obtain external IP</title><summary type='text'>Recently I had to obtain the external IP of a number of PC - ie. the address the PCs appear to use on the internet (in my case, the external IP address of their internet gateway/router).Here is the small function I ended up using:## Function to retrieve external IP address.## the external address is retrieved from the## title header of the webpage "www.myip.dk"function Get-ExternalIP {    $source</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/4649042790731539236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=4649042790731539236' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/4649042790731539236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/4649042790731539236'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/07/obtain-external-ip.html' title='Obtain external IP'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-8808903787941105923</id><published>2008-07-12T13:46:00.000+02:00</published><updated>2008-08-17T12:13:34.461+02:00</updated><title type='text'>Make PowerShell start much faster</title><summary type='text'>Jeffrey Snover recently wrote the following on the PowerShell Blog:Speeding Up PowerShell StartupI talked about this before but a number of people have missed it so here it is under a better title.In V1, we had a problem which caused our assemblies to not get ngen'ed during installation.  If you don't know what "ngen" is, don't worry - you don't need to.  All you need to know is that we didn't do</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/8808903787941105923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=8808903787941105923' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/8808903787941105923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/8808903787941105923'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/07/make-powershell-start-much-faster.html' title='Make PowerShell start much faster'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-3317595996420829826</id><published>2008-05-07T18:22:00.000+02:00</published><updated>2008-08-17T12:13:34.462+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>List failed SQL agent Jobs</title><summary type='text'>This function is used to extract a list of jobs that didn't complete successfully on last execution.The function takes a single parameter - the SQL server (instance) to query.This script can be useful in getting a daily overview - especially if wrapped in a loop and run against all servers.[void][reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo");[void][</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/3317595996420829826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=3317595996420829826' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3317595996420829826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3317595996420829826'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/05/list-failed-sql-agent-jobs.html' title='List failed SQL agent Jobs'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-1806904889225655323</id><published>2008-04-14T15:06:00.001+02:00</published><updated>2008-08-17T12:13:34.462+02:00</updated><title type='text'>Read groupmembers from AD</title><summary type='text'>A friend of mine asked how he could read from his local AD, in order to create a script for verifying group membership against a saved list. Here is a small piece of code that helped him:$users = [adsi]"LDAP://cn=groupName,ou=ouName,dc=MyDomain,dc=MyDomain2"foreach ($user in $users.Member) {    Write-Host (([adsi]"LDAP://$user").displayname)}</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/1806904889225655323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=1806904889225655323' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/1806904889225655323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/1806904889225655323'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/04/read-groupmembers-from-ad.html' title='Read groupmembers from AD'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-5427083151288486073</id><published>2008-04-14T13:16:00.000+02:00</published><updated>2008-08-17T12:13:34.462+02:00</updated><title type='text'>New-RemoteProcess</title><summary type='text'>It is possible to initiate a process on a remote machine through PowerShell, but only through WMI.Unfortunately there are certain limitations to this functionality in WMI:1.) The process will never be visible to a user logged on to the remote server.2.) The process will only be initialized - no return values are passed back through WMI.Limitation #2 can be circumvented by directing the output to </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/5427083151288486073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=5427083151288486073' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5427083151288486073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5427083151288486073'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/04/new-remoteprocess.html' title='New-RemoteProcess'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-8833850557080277120</id><published>2008-04-14T11:35:00.002+02:00</published><updated>2008-08-17T12:13:34.463+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='array'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Creating arrays</title><summary type='text'>In PowerShell an array can be contructed in a number of ways:$a = 1, 2, 3, 4, 5$a = 1..5The "1..5" notation builds a range of numbers starting with 1 and ending with 5. It is also possible to create a decrementing list:$a = 5..1$a54321As a server/network/database administrator one will often have to deal with servers/databases/tables/etc. that share the same name, except for some sort of </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/8833850557080277120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=8833850557080277120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/8833850557080277120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/8833850557080277120'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/04/creating-arrays.html' title='Creating arrays'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-2156899342813896996</id><published>2008-01-31T10:45:00.000+01:00</published><updated>2008-08-17T12:13:34.463+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>PowerShell, WMI and SQL Server</title><summary type='text'>I was recently asked "how can we determine the specific SKU of an installed SQL Server - without being able to execute T-SQL?". My answer:The following one-liner lists various advanced properties of a SQL installation:Get-WmiObject sqlserviceadvancedproperty -namespace "root\Microsoft\SqlServer\ComputerManagement" -computername  | Select-Object -Property PropertyName, PropertyNumValue, </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/2156899342813896996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=2156899342813896996' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/2156899342813896996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/2156899342813896996'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/01/powershell-wmi-and-sql-server.html' title='PowerShell, WMI and SQL Server'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7024245067243905415</id><published>2008-01-25T00:23:00.000+01:00</published><updated>2008-12-11T00:19:05.520+01:00</updated><title type='text'>Google Chart API &amp; PowerShell</title><summary type='text'>Have you heard of Google's "Chart API"?No?Well, the Google Chart API lets you dynamically generate charts. Using only a browser. But why use a browser when you can use PowerShell instead? :-)Click here to learn more about Google Chart API.I had been playing around with Google Chart API  for some time, when I decided to create a small PowerShell script to obtain a pie chart - sort of a poor mans </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7024245067243905415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7024245067243905415' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7024245067243905415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7024245067243905415'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/01/google-chart-api-powershell.html' title='Google Chart API &amp; PowerShell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_NsDgkRavKXw/R5kemc6besI/AAAAAAAAAJU/e_2ZLySrzCA/s72-c/chart.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-344928612331504076</id><published>2008-01-24T11:06:00.000+01:00</published><updated>2008-08-17T12:13:34.464+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>DBCC check through ADO.NET/PS</title><summary type='text'>Here is a small script I use to run DBCC against various databases in my environment:$ScriptName = $myInvocation.MyCommand.Name[void][reflection.assembly]::LoadWithPartialName("System.Data.SqlClient")$ConnString = "Server=Servername\Instance;Integrated Security=SSPI;Database=DatabaseName;Application Name=$ScriptName"$MasterConn = new-object ('System.Data.SqlClient.SqlConnection') $ConnString$</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/344928612331504076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=344928612331504076' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/344928612331504076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/344928612331504076'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2008/01/dbcc-check-through-adonetps.html' title='DBCC check through ADO.NET/PS'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-2230301170941531492</id><published>2007-12-21T08:50:00.000+01:00</published><updated>2008-08-17T12:13:34.465+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='email'/><title type='text'>Send-SMTPmail update</title><summary type='text'>Version 1.2 of my Send-SMTPmail cmdlet:# PowerShell 1.0 script to send email through SMTP# by Jakob Bindslet (jakob@bindslet.dk), 21. december 2007# Current Script version 1.1##NAME#    Send-SMTPmail##SYNOPSIS#    Sends an email by use of an SMTP server##SYNTAX#    Send-SMTPmail -to  -from  -subject  -body #    [-smtpserver ] [-port ] [-attachment ] [-html]#    [-cc ] [-bcc ] [-alert] [-timeout ]</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/2230301170941531492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=2230301170941531492' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/2230301170941531492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/2230301170941531492'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/12/send-smtpmail-update.html' title='Send-SMTPmail update'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-2171010894405034743</id><published>2007-12-20T20:46:00.000+01:00</published><updated>2008-08-17T12:13:34.465+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='email'/><title type='text'>A cmdlet-like email script</title><summary type='text'>I'm currently working on a database monitoring, datacollection and automation project using PowerShell. In this project I often find m self in need of sending a status or warning email when some event occurs - For a while I've just used code much like what I posted here on my blog back in december 2006, but last night I spend a bit of time writing up a cmdlet like "Send-SMTPmail" function once </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/2171010894405034743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=2171010894405034743' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/2171010894405034743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/2171010894405034743'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/12/cmdlet-like-email-script.html' title='A cmdlet-like email script'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-4247547381884276886</id><published>2007-12-13T11:56:00.000+01:00</published><updated>2008-08-17T12:13:34.466+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WMI'/><title type='text'>Script to extract disk space usage through WMI</title><summary type='text'>This script can be used to extract information regarding sapce usage (actually free disk space in percent) from one or more servers or cluster. Since the script uses Win32_Volume, it can also recognize mountpoints.$outData = @("")$server = $args[0]$dataFromServer = Get-WmiObject Win32_Volume -ComputerName $server | Select-Object SystemName,Label,Name,DriveLetter,DriveType,Capacity,</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/4247547381884276886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=4247547381884276886' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/4247547381884276886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/4247547381884276886'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/12/script-to-extract-disk-space-usage.html' title='Script to extract disk space usage through WMI'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-409040557682612250</id><published>2007-11-16T14:08:00.000+01:00</published><updated>2008-08-17T12:13:34.466+02:00</updated><title type='text'>PowerShell support in SQL Server 2008</title><summary type='text'>Latest news from IT-Forum/TechEd 2007 Barcelona, is that the upcomming CTP 5 release of MS SQL Server 2008 won't come with integrated PowerShell - this feature won't be available until CTP 6 of SQL Server 2008 :-(</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/409040557682612250/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=409040557682612250' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/409040557682612250'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/409040557682612250'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/11/powershell-support-i-sql-server-2008.html' title='PowerShell support in SQL Server 2008'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-3711593106155109366</id><published>2007-11-06T09:14:00.000+01:00</published><updated>2008-08-17T12:13:34.466+02:00</updated><title type='text'>Powershell V2 Approaching</title><summary type='text'>If you haven't noticed already, Jeffrey Snover has announced the immediate release of PowerShell V2 CTP.The PowerShell V2 CTP is not for everyone. You should read this PowerShell Team blog entry ( http://blogs.msdn.com/powershell/archive/2007/11/02/ctp-watch-this-space.aspx ) to find out what it is and what it isn't and then make an informed decision before installing the CTP.</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/3711593106155109366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=3711593106155109366' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3711593106155109366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3711593106155109366'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/11/powershell-v2-approaching.html' title='Powershell V2 Approaching'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-7380122416506428269</id><published>2007-10-10T14:42:00.000+02:00</published><updated>2008-08-17T12:13:34.467+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='filesystem'/><title type='text'>ClusterSize</title><summary type='text'>I recently had to complete a survey of the actual clustersizes used on a bunch of SQL Servers. In order to obtain this information, I came up with the small script below.The script will list all drives (including drives without driveletters assigned, only mountpoints):As noted by a reader the WMI class "Win32_Volume", is only available on Windows 2003 Server &amp; Windows 2008 Server.$servers = "</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/7380122416506428269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=7380122416506428269' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7380122416506428269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/7380122416506428269'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/10/clustersize.html' title='ClusterSize'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-5521610652588713639</id><published>2007-08-30T04:17:00.000+02:00</published><updated>2008-08-17T12:13:34.467+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='formatting'/><category scheme='http://www.blogger.com/atom/ns#' term='SMO'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Formatting through the -f parameter</title><summary type='text'>Formatting in PowerShell is typically achieved through the use of .NET's format strings. You might have seen cryptic statements like:"{0,-8:P1}" -f 1.75The above format can be explained as:"{argument index[,alignment][:formatString zeros]}"Note that both the alignment and the formatString are optional.argument index is used when formatting more than one argument.##### Argument Index"{0,8}{1,10}" </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/5521610652588713639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=5521610652588713639' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5521610652588713639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/5521610652588713639'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/08/formatting-through-f-parameter.html' title='Formatting through the -f parameter'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-3611851359632101056</id><published>2007-08-29T20:45:00.000+02:00</published><updated>2008-08-17T12:13:34.468+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WMI'/><title type='text'>Is my drive fragmented?</title><summary type='text'>Marco Shaw commented on my post ragarding fragmentation of files. Unfortunately WMI doesn't expose the fragmentation of specific files (at least I can't find it). But Marco's approach is useful in many situations.Here is a small example on how to retrieve and display the fragmentation staus from a series of servers:$allservers = "server1.", "server2"Write-Host -foregroundcolor Yellow "Server</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/3611851359632101056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=3611851359632101056' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3611851359632101056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3611851359632101056'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/08/marco-shaw-commented-on-my-post.html' title='Is my drive fragmented?'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-118297337612639768</id><published>2007-08-22T11:27:00.000+02:00</published><updated>2008-08-17T12:13:34.468+02:00</updated><title type='text'>A few nice variables</title><summary type='text'>Obtaining the name of the current script: $myInvocation.MyCommand.NamePath to Powershell executable: $PSHomeGet environment variables: $env:username or $env:logonserverList all available environment variables: dir env: (note that no $ is included)Show last commandline entered: $lineCurrent Path: $pwd</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/118297337612639768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=118297337612639768' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/118297337612639768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/118297337612639768'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/08/few-nice-variables.html' title='A few nice variables'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-3114258214166124745</id><published>2007-08-09T13:51:00.000+02:00</published><updated>2008-08-17T12:13:34.469+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Reading directly from SQL Server</title><summary type='text'>A small example of reading a value from an SQL Server. In this case the maximum memory allowed for the SQL Server Instance.$adOpenStatic = 3$adLockOptimistic = 3$timeout = 3function GetMaxMemory {    ## returns single string    ## returns -1 if memory is unlimited    ## returns -2 if no connection to the desired DB can be obtained    ## arg0 = datasource (eg. server1\instance01)    $objConnection</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/3114258214166124745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=3114258214166124745' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3114258214166124745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/3114258214166124745'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/08/reading-directly-from-sql-server.html' title='Reading directly from SQL Server'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116972497835147152</id><published>2007-01-25T12:32:00.000+01:00</published><updated>2008-08-17T12:13:34.469+02:00</updated><title type='text'>Is my file fragmented?</title><summary type='text'>Small function to determine if a file is fragmented - for instance to analyzed an .ldf/.mdf file.The function below also demonstrates one way to invoke an external command/tool (in this case "contig.exe" from www.sysinternals.com).The function requires contig.exe to be in the local path.function getFileFragments {    $filename = $args[0]    $contigOutput = contig -a $filename    foreach ($line in</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116972497835147152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116972497835147152' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116972497835147152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116972497835147152'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/01/is-my-file-fragmented.html' title='Is my file fragmented?'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116774455193765144</id><published>2007-01-02T14:26:00.000+01:00</published><updated>2008-08-17T12:13:34.469+02:00</updated><title type='text'>Test connection to server</title><summary type='text'>Small function to test connectivity to a server.function test-connection {    $pingtest = ping $args[0] -n 1        if ($pingtest -match 'TTL=') {        Write-Output $true    } else {        Write-host $false    }}Usage:test-connection MyServer01.domain.com</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116774455193765144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116774455193765144' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116774455193765144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116774455193765144'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2007/01/test-connection-to-server.html' title='Test connection to server'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116722379591591911</id><published>2006-12-27T13:48:00.000+01:00</published><updated>2008-08-17T12:13:34.470+02:00</updated><title type='text'>List current functions in powershell</title><summary type='text'>You can use the following command to display what functions that are part of your current shell.Get-ChildItem function:*To view the code contained in a function - in this example the function "mkdir":$function:mkdirIf you would like to change a function, simply create a new function of the same name:function C: {    Write-Host "You are not allowed on drive C: !"    Set-Location M:}The function </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116722379591591911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116722379591591911' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116722379591591911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116722379591591911'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/list-current-functions-in-powershell.html' title='List current functions in powershell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116672997943600801</id><published>2006-12-21T20:38:00.000+01:00</published><updated>2008-08-17T12:13:34.470+02:00</updated><title type='text'>Configuring PowerShell</title><summary type='text'>Enable scripts - in order to execute script in PowerShell, the default Executionpolicy of "Restricted", has to be changed to "Unrestricted":Set-Executionpolicy UnrestrictedInstead of "Unrestricted" you could also selec RemoteSigned, AllSigned, Restricted, Default (to reset to the PowerShell default)Configure my profileDetermine where my profile is stored through the following default variable:$</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116672997943600801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116672997943600801' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116672997943600801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116672997943600801'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/configuring-powershell.html' title='Configuring PowerShell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116662181862198953</id><published>2006-12-20T14:36:00.000+01:00</published><updated>2008-08-17T12:13:34.471+02:00</updated><title type='text'>How much RAM have I got?</title><summary type='text'>A small function to retrieve the number and size of RAM modules in a PCfunction GetMem{    $a = Get-WmiObject win32_physicalmemory -computername $args[0]    Write-Host ("-" * 60)`n "Memory Configuration of" $args[0] `n("-" * 60)    foreach ($b in $a) {        Write-Host $b.tag `t $b.capacity "bytes" `t ($b.capacity/1mb) "mb"    }}Usage:GetMem </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116662181862198953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116662181862198953' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116662181862198953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116662181862198953'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/how-much-ram-have-i-got.html' title='How much RAM have I got?'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116660370021869141</id><published>2006-12-20T09:34:00.000+01:00</published><updated>2008-08-17T12:13:34.471+02:00</updated><title type='text'>Useful .NET stuff</title><summary type='text'>One of the big advantages of PowerShell is the easy access to .NETFor instance, in order to gain access to the .NET functionality contained in datatime wecan use Get-Member to look at the available methods:$a = [datetime]Get-Member -InputObject $a -sOr written in a shorter notation:[datetime] | gm -sWe might find the IsLeapYear or Parse methods interisting, and decide to try them out:[datetime]::</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116660370021869141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116660370021869141' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116660370021869141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116660370021869141'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/useful-net-stuff.html' title='Useful .NET stuff'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116655295026411603</id><published>2006-12-19T19:27:00.000+01:00</published><updated>2008-08-17T12:13:34.471+02:00</updated><title type='text'>Memory consumption</title><summary type='text'>Here are two small script used for displaying the name of currently running processes, as well as the amount of memory currently allocated (through VMM) to Virtual Machines (either Microsoft Virtual PC or Virtual Server):function GetMem {    $processes = Get-WmiObject win32_process | Sort-Object -property WorkingSetSize -descending    $processes | format-table `         ProcessName, `         </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116655295026411603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116655295026411603' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116655295026411603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116655295026411603'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/memory-consumption.html' title='Memory consumption'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116601831724326254</id><published>2006-12-13T14:51:00.000+01:00</published><updated>2008-08-17T12:13:34.472+02:00</updated><title type='text'>Environment variables</title><summary type='text'>To use the standard windows environment variables (temp, computername, windir, etc.) in PowerShell, you can use the following notation:${env:temp}Or, if the full names (not 8.3 DOS notation) are required:[io.path]::GetFullPath($env:temp)Note that if $env:path is needed, you have to use the first notation (which in this case returns the full path/file names).${env:path} [io.path]::GetFullPath($env</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116601831724326254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116601831724326254' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116601831724326254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116601831724326254'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/environment-variables.html' title='Environment variables'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116596632540931798</id><published>2006-12-13T00:31:00.000+01:00</published><updated>2008-08-17T12:13:34.472+02:00</updated><title type='text'>Sending emails from powershell</title><summary type='text'>Here is a small script to send emails from PowerShell. Remember to use a valid SMTP server.$SMTPserver = "mysmtp.nowhere.now"$fileattachment = "c:\\boot.ini"$from = "hans@nowhere.now"$to = "somebody@somewhere.org"$subject = "PowerShell Test"$emailbody = "this is my very first email send through PowerShell 1.0"$mailer = new-object Net.Mail.SMTPclient($SMTPserver)$msg = new-object </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116596632540931798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116596632540931798' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116596632540931798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116596632540931798'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/sending-emails-from-powershell.html' title='Sending emails from powershell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116593494597686898</id><published>2006-12-12T15:48:00.000+01:00</published><updated>2008-08-17T12:13:34.473+02:00</updated><title type='text'>PowerShell can be strict</title><summary type='text'>Normally PowerShell silently ignores the use of uninitialized variables.For instance, the script below will simply assume that $b has no value, and return the value "5"$a = 5$a + $bIt is often useful to force PowerShell to return an error if an unitialized variable is used.This can be accomplished by enabling "strict" mode:Set-PSDebug -strictIf the earlier scritp is run again an error is returned</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116593494597686898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116593494597686898' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116593494597686898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116593494597686898'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/powershell-can-be-strict.html' title='PowerShell can be strict'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116547827836470153</id><published>2006-12-07T08:51:00.000+01:00</published><updated>2008-08-17T12:13:34.473+02:00</updated><title type='text'></title><summary type='text'>Jeffrey Snover of MSFT suggested the following (shorter) way of implementing yesterdays script:[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")$myTitle = "Important Question"$myText1 = "Is PowerShell useful to you ?"$a = [Windows.Forms.MessageBox]::Show($myText1, $myTitle, "YesNoCancel", "Question")$myText2 = "You answered: $a"$a = [Windows.Forms.MessageBox]::Show($myText2</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116547827836470153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116547827836470153' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116547827836470153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116547827836470153'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/jeffrey-snover-of-msft-suggested.html' title=''/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116541363180152559</id><published>2006-12-06T15:00:00.000+01:00</published><updated>2008-08-17T12:13:34.473+02:00</updated><title type='text'>Quick'n'dirty user interface</title><summary type='text'>The example below shows a quick way to use a standard windows messagebox as a user interface, through Windows Forms.[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")$myTitle = "Important Question"$myText1 = "Is PowerShell useful to you ?"$a = [Windows.Forms.MessageBox]::Show($myText1, $myTitle,`        [Windows.Forms.MessageBoxButtons]::YesNoCancel, `        [</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116541363180152559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116541363180152559' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116541363180152559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116541363180152559'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/quickndirty-user-interface_06.html' title='Quick&apos;n&apos;dirty user interface'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116533078643301563</id><published>2006-12-05T15:57:00.000+01:00</published><updated>2008-08-17T12:13:34.474+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SMO'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>PowerShell, SQL &amp; SMO</title><summary type='text'>On november 30th I showed how to access a SQL Server using ADO. Todays script does excatly the same, but uses SMO instead of ADO:function ShowAllDB_SMO {    [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.ConnectionInfo" );    [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.SmoEnum" );    [void][reflection.assembly]::LoadWithPartialName( "</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116533078643301563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116533078643301563' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116533078643301563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116533078643301563'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/powershell-sql-smo.html' title='PowerShell, SQL &amp; SMO'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116523375537656798</id><published>2006-12-04T13:00:00.000+01:00</published><updated>2008-08-17T12:13:34.474+02:00</updated><title type='text'>Oneliner</title><summary type='text'>Todays script is a oneliner that sums up the memory consumption of alle running processes (or rather all visible running processes). It also demonstrates the use of ";" as a line separator   $a = get-process; foreach ($i in $a) {$sum = $sum + $i.workingset}; $sum / 1mb</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116523375537656798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116523375537656798' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116523375537656798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116523375537656798'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/12/oneliner.html' title='Oneliner'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116488722762586440</id><published>2006-11-30T12:45:00.000+01:00</published><updated>2008-08-17T12:13:34.475+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>PowerShell, SQL &amp; ADO</title><summary type='text'>The following function connects to a SQL server through ADO, and queries the master database for a list of the database id (dbid) and name of all databases on the server:function ShowAllDBs { $adOpenStatic = 3  $adLockOptimistic = 3     $objConnection = New-Object -comobject ADODB.Connection     $objRecordset = New-Object -comobject ADODB.Recordset     $query = "SELECT dbid, name FROM </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116488722762586440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116488722762586440' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116488722762586440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116488722762586440'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/11/powershell-sql-ado.html' title='PowerShell, SQL &amp; ADO'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116479175541865686</id><published>2006-11-29T09:56:00.000+01:00</published><updated>2008-08-17T12:13:34.475+02:00</updated><title type='text'>Functions in PowerShell</title><summary type='text'>Here is how to create a simple function in PowerShell. The function takes a single argument, and returns the twice the given amount. Note that the function works on both integers and strings (PowerShell handles multiplication of strings by repeating the string the given number of times).:function MultiplyByTwo {    $temp = $args[0] * 2    Write-Output $temp}MultiplyByTwo 42MultiplyByTwo "</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116479175541865686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116479175541865686' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116479175541865686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116479175541865686'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/11/functions-in-powershell.html' title='Functions in PowerShell'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116478621316203996</id><published>2006-11-29T08:19:00.000+01:00</published><updated>2008-08-17T12:13:34.476+02:00</updated><title type='text'>Variables and types</title><summary type='text'>A variable in PowerShell must begin with the dollarsign ($). The name of the variable stops at the first word breaking character (such as space, comma or period). If special characters are needed in a variable, name curly braces can be used to surround the variable name:$myvar = "normal variable name"$myvar${ugh!b££!!¤&amp;(} = "special variable name"${ugh!b££!!¤&amp;(}In order to determine the type of a</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116478621316203996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116478621316203996' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116478621316203996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116478621316203996'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/11/variables-and-types.html' title='Variables and types'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116474772854601618</id><published>2006-11-28T22:00:00.000+01:00</published><updated>2008-08-17T12:13:34.477+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>SQLDMO</title><summary type='text'>Here is a small script using SQLDMO against a MS SQL Server 2000 or 2005 to obtain the TCP port number currently used. I know the Books Online for SS05 indicates that DMO is no longer supported - well I guess that they're wrong:$s = New-Object -comobject "SQLDMO.SQLServer"$s.loginsecure = $true$s.connect("SERVERNAME01")$s.registry.tcpport$s.close() </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116474772854601618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116474772854601618' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116474772854601618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116474772854601618'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/11/sqldmo.html' title='SQLDMO'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116474747874057467</id><published>2006-11-28T21:56:00.000+01:00</published><updated>2008-08-17T12:13:34.477+02:00</updated><title type='text'>Two ways of writing foreach</title><summary type='text'>There are two ways of creating foreach statements in PowerShell    $b = 'hans','soren','ib','poul','hanne','william','ann-marie'    $b | Foreach-Object {Write-Host $_} Or    $b = 'hans','soren','ib','poul','hanne','william','ann-marie'    Foreach ($a in $b) {Write-Host $a} </summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116474747874057467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116474747874057467' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116474747874057467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116474747874057467'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/11/two-ways-of-writing-foreach.html' title='Two ways of writing foreach'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-37819735.post-116474723989743881</id><published>2006-11-28T21:51:00.000+01:00</published><updated>2008-08-17T12:13:34.478+02:00</updated><title type='text'>Basic Stuff</title><summary type='text'>Literal Strings'text' indicate a literal string in PowerShell, while "text" is used when variables and escape chars are needed.   $c = "Julemanden"    Write-Host 'Santa Claus is called $c in Denmark'    Write-Host "Santa Claus is called $c in Denmark"Multidimensional Arrays$a = @( (1,2,3,4,5) , (6,7,8,9,0) )$a[0][0]$a[1][1]</summary><link rel='replies' type='application/atom+xml' href='http://mspowershell.blogspot.com/feeds/116474723989743881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=37819735&amp;postID=116474723989743881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116474723989743881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/37819735/posts/default/116474723989743881'/><link rel='alternate' type='text/html' href='http://mspowershell.blogspot.com/2006/11/basic-stuff.html' title='Basic Stuff'/><author><name>Jakob Bindslet</name><uri>http://www.blogger.com/profile/15991115017499294057</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.bindslet.net/billeder/jbi_me.png'/></author><thr:total>0</thr:total></entry></feed>
