Thursday, December 18, 2014

Setting up a lab

There are so many good reasons to have a lab available. There are very few reasons to not. IT organizations are constantly testing new releases, new configuration, and some widget that needs to be rolled out. We need to evaluate software and solutions that we want to implement in our production environments. With Windows 8+ and the latest versions of Hyper-V there are really no good reasons to not have a lab to use.

With that said, managing the lab in Hyper-V is very easy and to be honest, it is quite fun. If you are a VMWare shop, that is great. Either way there are some simple techniques and best practices that can be super helpful.

This video walks through some thoughts and ideas on how to manage your lab, how to setup the core environment and prepare for testing. We’ll try to follow up with additional content related to evaluating Specops solutions, but first things first…


Enjoy!


Monday, December 1, 2014

Why are my cmdlets not working? Duh!

PS C:> Get-VM
PS C:> 

What? I have multiple VMs running on my system. I use this cmdlet often. What? Why did it suddenly stop working?

So, what to do? Of course my first move is to look at the help system.

PS C:> Get-Help Get-VM -ShowWindow

I really like the 'ShowWindow' parameter. It dumps the complete help file into a separate window where you can filter, zoom, search and more. 


Unfortunately I didn't find anything. I don't get an error in the console. I started using bing. Or Google, whatever you choose. I use bing. Of course there are lots of forum threads and random links. Nothing to do but start reading. 

The 'ah-ha' moment suddenly becomes the 'duh' moment. I saw a thread on the Get-VM cmdlet not working. And a few people were adding very complicated troubleshooting including SC-VMM stuff etc. At the end of the long thread... someone posted "run the console as admin"... DUH! 

I always run my console as admin, but for some reason this time I forgot. And didn't check.

If you have a problem in PS, and it is bizarre/strange... make sure to check how it is running. It is simple, the title bar of the console will tell you if you are running as admin. Make sure to check.


If you are new to PowerShell, simply right-click on the PowerShell Icon in the task bar and choose your option. Simple...





Friday, September 5, 2014

Windows Management Framework 5.0 - September Preview

Like a kid in a candy shop - well a sort of geeky kid

The Windows Management Framework 5.0 came out yesterday twitter-verse was abuzz. Blogging, tweeting, re-tweeting, re-re-tweeting. Lots of interest it appears. It is fun to look at what is new, what improvements have been implemented and begin to see hints of more to come.

Some of the features are fully accessible now, some will take some additional thought. And for each of us those may be different things.

You can find the team announcement on their blog - PowerShell Team Blog.

I'm having a scattered multitasking Friday so I don't know how much time I can spend on this today but I'm excited to dig in. Thanks PowerShell team for delivering a good evaluation guide with these previews, really helpful!

Today I'm;
  1. Setting up Azure Virtual Machine to begin testing some upcoming products!
  2. Digging into some PowerShell/Azure synergy I haven't played with yet
  3. Reviewing the WMF 5.0 September Release
  4. Working on multiple sessions/webinars/conference proposals
    1. DSC and Group Policy - compliance for the desktop
    2. Longer is Stronger - why passphrases are powerful
    3. PowerShell basics - training sessions for our customers
Some of my favorites from the team announcement are;
  • Manage Zip files! - the little things are sometimes great!
    • Compress-Archive
    • Expand-Archive
  • Lots of DSC stuff
  • Register a PSRepository with PowerShell Get sounds interesting - hosted modules - work from anywhere? we will soon see
  • Switch management - more evolution
  • ISE updates to make working with DSC easier
Great job PowerShell team. 

Friday, August 22, 2014

Group Policy 002: The Cmdlets - New-GPO

Simple!

It really is. I want to create a new GPO from PowerShell. Of course there will be work to do later but just get the GPO created. 

I created a brief video walking through the process.


Enjoy!

Monday, August 4, 2014

C'Mon Man! - wasted time - PowerShell Help

PowerShell Help

I love the PowerShell Help System! I honestly do. I have surely drank the kool-aid and stopped trying to memorize everything in there. When I have a need I turn to...
  1. Get-Command
  2. Get-Module
When I have found a command that I believe will work I use
  • Get-Help
  • Get-Help -Full
  • Get-Help -ShowWindow
  • Get-Help -Examples
And...
  • Get-Help -Online
If for some reason I'm still having issues I will go to the Internet and find resources to help. People who have had my problem before, and figure out what they have done.

The Problem

Why is it that people think it is helpful to copy the content of Get-Help -Full and post that as a blog post on their personal blog. No additional value, not scenarios where they used the cmdlet, nothing but the same exact content I can get from Get-Help -Full or Get-Help -Online

This is not helpful! It is distracting and hurts troubleshooting efforts.

OK, let me give folks the benefit of the doubt, let's assume they are trying to be helpful. Point to source of the info and post how you used the cmdlet. Learn the help system and know that all of that information is online. The system is absolutely awesome and we as a community need to support it and help it continue to grow. Let people know how great it is and how it helped you. Don't simply copy it and re-post. It is not adding any additional value.

Saturday, June 28, 2014

PowerShell 009 - Get-Help -ShowWindow

Help... huh... what is it good for?

The help system in PowerShell is one of the features that makes the new shell so accessible. Once you get used to the system you ask PowerShell questions and it gives you answers. You ask it to clarify, and it does. You ask for more details, it gives you more details. You ask for examples, it gives you examples. It is really, really great.

I was working through some best practices by some of the PowerShell MVPs and I was finding some sample scripts and advanced functions on TechNet and realized that often times writing good help is skipped.

I'm optimistic that the amount of help content I consume will burn into my brain the value of taking the time to write good help content.

-ShowWindow

You can write the help content to the screen and read it from the console. You could even send it right out to a printer, but don't! ("I speak for the trees, for the trees have no tongues" - The Lorax) Sending the help content to the console window is great. When working quickly I often will simply look at examples to get me started;

PS> Get-Help Get-CimInstance -Examples

If I want to see all of the content in the console window;

PS> Get-Help Get-CimInstance -Full

Great. Quick, moves the ball forward nicely. But when learning the subtleties of cmdlets there is often an extensive amount of content to go through. PowerShell's ISE provides a way to throw the content into a single window. It also provides some very interesting features to assist. To get the full content in a separate window type;

PS> Get-Help Get-CimInstance -ShowWindow

Your help content is now in a separate windows. Makes research and troubleshooting much easier in my opinion.

My poor eyes! The text is small, my reading glasses are in the other room, my backup reading glasses are in the couch cushions and my backup, backup reading glasses are who knows! But look... in the bottom right hand of the screen there is a slider bar that allows you to magnify the text... nice! Thanks Microsoft! (you can also <CTRL> & + to increase the font size)


Narrow It Down

OK, now there is a lot of content. How do I find what I am looking for. Get-CimInstance (the cmdlet I chose for the example) seems pretty confusing. The first thing I see is syntax. Lots of syntax. There are almost 10 parameter sets to deal with. Seems to be lots of parameters. I'm betting there are lots of examples.

Right at the top left side of the screen you will see a 'Find:' feature. Simply type in the word or phrase you are looking for and let PowerShell (well the ISE) help you.



In the upper right you will find a button called 'Settings'. Click this button and select only the 'type' of content you want displayed in the window.

It is all pretty self-explanatory. Make sure you spend time here. I have surely heard this message from the PowerShell gurus out there and taken it to heart. Another lesson I'm learning the more I develop scripts and tools with PowerShell is the importance of formatting... but that is a discussion for a different day.

Friday, June 20, 2014

PowerShell 008 - $Profile

$Profile - what is it good for?

There are many things you can use the profile for in PowerShell. The variable $profile stores the path to the profile loaded when you launch the console or the ISE.
 


 
If you notice the path above you will see the script is called 'Microsoft.PowerShellISE_Profile.ps1'. It is a profile script that will load when you launch the ISE. I almost exclusively use the ISE these days, I have found very few reasons to use the console. That is a different discussion.
 

What is put in the profile script?

Well, that is really the question I've been asking myself. I find that just about every time I launch the ISE I think of something that I need to have available to me. For example I use the Specops PowerShell cmdlets every day. The cmdlets and functions that come through our Deploy products are PowerShell modules. Our Specops Password products expose their commands through PSSnapIns. PSSnapIns and some modules need to be loaded explicitly.
  • Add-PSSnapIn -Module specopssoft.specopspasswordpolicy
  • Import-Module -Module specopsdeploy
Another thing I do on a regular basis is update the help content. Now this is a bit much for a profile in my experience but it can catch updated content when available. If there are specific modules that you utilize all the time you can update those individually. This command updates the help content.
  • Update-Help
  • Update-Help -Module Hyper-V
Many of my friends and colleagues use PowerShell and some are true power users. Their profile scripts include quite a bit of automation. These are just simple examples share yours.
 
Starting the console with the focus on a directory that is used for most tasks is also very helpful.
  • Set-Location c:\psstuff

How to Update the profile script

The path to the profile script is stored in the $Profile variable. Above you can see the data stored in this variable for the ISE. When you want to edit your profile script simply type
 
 
 
 
This will launch notepad with the profile script.
 
 
 
 
 
 
 
 
 
 
 
 
 
 

And that is that

Save the script, close the ISE and re-launch it. the configuration your have in the script will run. If you haven't updated help content in a while this one can take a while. So use that with the understanding of what it is doing.