Skip to main content

Posts

Showing posts from February, 2014

Get the PowerShell V3–ShowWindow in PowerShell V2

This week I’m delivering a PowerShell class in Virginia to an audience who will be using PowerShell V2 for a while longer.  I noticed that one of the features of V3 that they like is the – ShowWindow parameter of Get-Help .  Since this class is a 10 day tool making course, I decided to just create the tool for them.  What I decided to do was to have Notepad display the help file information for me.  This provides the critical “Search” capability that they are looking for.  I also decided to address one of the short comings of Get-Help – ShowWindow and that is it’s inability to open multiple help windows at the same time.  Below is the code. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 8

Adding Some Code Templates to the PowerShell ISE

Today I’m sitting at the car dealership waiting on my wife’s car to get a recall fixed.  Luckily I can carry my entire office on my laptop (I’ve been here for 3 hours).  I’m working on finalizing my code for the 2014 PowerShell Summit in April so of course I keep finding better and better ways of writing my own code.  (BTW, my session at the summit is on Tuesday)  What I am focused on is to take my HelpDesk module code to the next level, but also to be able to do it quickly and easily.  This has finally given me a reason to use the Snippets functionality in the PowerShell ISE. I wrote up some code that will help me a lot and saved it as a PowerShell script called HDSnippet.ps1 .  This code will be my template. Now, before we begin, you need to be on PowerShell V3.  I know that a lot of you who are going to be taking my PowerShell classes over then next few months are still in a V2 environment.  That is OK.  Copy and Paste still work.  For those of you on PowerShell V3, open the ISE a

Testing if a Resource is online

I was sitting in the USO at the San Jose airport a few months ago after teaching a class when I got a call from a friend who had an issue.  Apparently, his company’s email server went down.  It had been down for about 24 hours.  Of course the first person to take note of this was the big boss her self.  He asked me if PowerShell could tell him when a serve is down. This reminded me of a script that I ran years ago that would test connectivity to all of my resources (servers, printers, routers, etc.) and then dropped me an email to let me know if I had work to do.  This email would say something like “Have a nice day” if nothing was wrong in the subject line.  It would say something else if there was a problem and then I would have to open it. I spent about an hour building a test environment and rebuilt that script in PowerShell for my friend.  He was very happy to receive it. For this years SMB Nation Emerging Technology Tour, I decided build a simplified version of it.  I also set