Tag: PowerShell
This category contains posts pertaining to PowerShell. On this blog, this will be the vast majority of the posts.
PowerShell presence at TechEd 2008 IT Pro
I’m absolutely thrilled at the presence that PowerShell has had at the IT Pro week of TechEd 2008. There have been a huge number of breakout sessions and interactive theatres talking about PowerShell and showing how to use it to manage your environment, many of which have been full or close too it (especially the interactive theatres — they were jam packed, standing room only in the back). There’s also a PowerShell demo pod in the Management (blue) area and many vendors who have products in the PowerShell space ready to answer questions, show off demos, and in some cases give away free products too! I’m sure Jeffrey Snover must be really happy (probably an understatement) with the well deserved interest and attention that PowerShell is getting. This is such a fun space to work in, and PowerShell is absolutely the best technology I have ever worked with!
Kirk out.
| Share this post: |
Interview with Dmitry Sotnikov about PowerShell and PowerGUI on IT TV
Windows IT Pro magazine recently launched their new IT TV website, a community site that hosts videos relevant to today’s IT professional. One video that caught my interest today is an interview with Dmitry Sotnikov discussing PowerShell and PowerGUI. Curious about what PowerGUI is and how it might help you? Check out the interview to learn more about it!
Kirk out.
| Share this post: |
Enter the PowerPack Challenge!
Ok, I’m really excited about this one. Quest Software (my employer and sponsor of all PowerGUI development) has created a PowerGUI contest! Whether you are a newcomer to PowerShell, a seasoned PowerShell scripter or somewhere in between, why not experiment with all of the creative things you can do with PowerGUI and PowerShell and enter the PowerPack Challenge! All you need to do to enter is create and/or update one or more PowerPacks during the contest period (between July 1, 2008 and September 30, 2008). There are some great prizes to be won, as described on the PowerPack Challenge contest page!
So now that you know about the contest, what should you do next? Since the contest period doesn’t start until July 1, 2008, you have some time to prepare yourself for the contest. if you aren’t totally familiar with PowerPacks or how to create them, you can learn how to do that by watching the flash demo I created here. If you want to browse existing PowerPacks to get an idea what is already available, you can look in the PowerPack library here. Or if you are attending the IT Pro week of TechEd 2008, there are a lot of sessions, hands on labs, instructor led labs, and more with PowerShell content and you can learn more about PowerShell and PowerGUI by visiting the demo station in booth 1101.
And please, just like anything else I post on this blog, if you have questions don’t hesitate to ask.
Thanks and good luck with your contest entries!
Kirk out.
| Share this post: |
Learn about PowerShell and PowerGUI at TechEd 2008
Are you interested in PowerShell? Would you like to see a demo of some cool free tools that can help you use PowerShell more easily today? Visit the PowerShell demo station in booth 1101 at TechEd 2008 and learn how PowerShell and PowerGUI can help you manage your IT environment more easily!
Kirk out.
| Share this post: |
EnergizeIT Certification Bootcamp slide decks now available
Whether you attended the EnergizeIT Certification Bootcamp 2008 National User Group Tour or not, you might want to check out the slide decks that were presented. Kai Axford and I presented a ton of content over a 2½ to 3 hour period. There were three sessions presented, as follows:
Session 1: Security in a Virtual World
Session 2: Windows Server 2008 & Virtualization
Session 3: Making Security a Career
I should note that the session order changed slightly and the content was tweaked after the first few stops on the tour. Also as Kai and I mentioned during the tour there are additional slides included in these slide decks that were hidden during the tour, so now you can get access to those slides in addition to those we presented as well.
There is a lot of great material in these slide decks, so you should take a look. I’ve linked the session names to the slide decks, but you can also find them on the official bootcamp website in the sidebar on the right-hand side near the bottom.
Do you use virtualization in your environment? Are you sure you’re thinking about everything you need to with respect to virtualization security? Check out the slide deck for session 1. There may be some things you haven’t considered that you should definitely look at. Or maybe you just want to learn more about Hyper-V and System Center Virtual Machine Manager — that’s in there too.
Windows Server 2008 brings a lot of new features and usage scenarios to the table. Server Manager, Server Core and my personal favorite, PowerShell were demoed, and many other features were discussed. Check out the session 2 slide deck for more information (including the PowerShell resources I talked about during the demos).
Are you doing the job today that you want to be doing 10 years from now? Do you want to be telling your manager in 2018 that you just finished the automated rollout of Windows Server 2018 using PowerShell? That might sound pretty cool today (it sounds pretty cool to me today), but you might want to be the manager being told that the rollout is complete instead of the one doing the rollout by then, or maybe you have something completely different in mind for your future career. The session 3 slide deck has some great content about career management. The emphasis is on making a security career, but the content is very generic and can be applied to making many changes in your career. Personally, I love the slides that talk about the three rules for recession proofing and have been following those for a while now. I used these rules last year to redirected my career towards PowerShell and that lead to me joining the PowerGUI team where I continue to work happily today. The rules are great for recession proofing, general career management and redirection as well. If you are considering a career change in the future, internal to your current company or external, you should seriously check the session 3 slide deck out.
If you have problems accessing any of these slide decks, let me know and I’ll try to help work it out for you.
Kirk out.
| Share this post: |
Provisioning users in Active Directory with PowerShell and the QAD cmdlets
As part of the EnergizeIT tour that I was on for the past three weeks, I did a quick introduction to PowerShell and then showed how the ability to automate tasks using PowerShell can make the job of an IT administrator much, much easier. The scenario for the automation example I used was this: your HR department contacts you on Friday afternoon and tells you there are a bunch of new users coming in next week and you need to make the accounts right away. The actual number is arbitrary because PowerShell scripts are the same for 1 user as they are for 1000000 users (exaggerated as that might be), but for my example I used a dozen users.
The point with this example was to show you how you can accomplish a task like this quickly regardless of the number of users being created and go home on time for date night, your son’s baseball game, etc. This demonstration was very well received, and at the end of the demonstration I promised that I would post the script I wrote during the demo here in my blog. The script that I post here may look slightly different from the script you saw me run at your tour event because I wanted to make sure shared the answer to a question someone asked me during the tour: How do I set the password for the new users when I create them?
For those of you who didn’t see the live demonstration, note that the csv file I used (C:\Users\Poshoholic\Documents\NewHires.csv) contained the following text:
FirstName,LastName,Title
Dmitry,Prosser,Software Developer 4
Oisin,Hill,Quality Analyst 1
Jeffrey,Shell,Senior Support Representative
Don,Munro,Software Developer 1
Charlie,Shaw,Project Manager
Marco,van Oursow,HR Assistant
Brandon,Russel,Product Manager
Keith,Hicks,Software Developer 3
Marc,Grehan,Product Marketing Manager
Karl,Jones,Quality Analyst 3
Kirk,Lee,Quality Analyst 1
Thomas,Sotnikov,IT Analyst 2
(FYI: if you think those names look familiar, I took the first names and last names of 12 PowerShell MVPs and mixed them up)
During the demonstration, the script below was built up iteratively within the PowerShell console so that you could see the thought process involved in creating a script that way. In this blog post however, I’m simply going to post the finished script. If you have questions about the demonstration or want to refresh your memory on how you could build a script like this iteratively, let me know. The finished script to create the users from the csv file simply looks like this:
Import-Csv ‘C:\Users\Poshoholic\Documents\NewHires.csv‘ `
| Add-Member -Name Name -MemberType ScriptProperty -Value {$this.FirstName + ‘ ‘ + $this.LastName} -PassThru `
| Add-Member -Name SamAccountName -MemberType ScriptProperty -Value {($this.FirstName[0] + $this.LastName.Replace(‘ ‘,”)).SubString(0,20)} -PassThru `
| New-QADUser -City Ottawa -UserPassword ‘P4$$w0rd‘ -ParentContainer poshoholicstudios.com/users
Please note the following if you want to use this as a basis for your own script:
- You can copy this script from my blog and paste it directly into the PowerGUI Script Editor where you can customize it to meet your needs (be careful of the word wrap – there should be four lines of script once you paste it in PowerGUI). Alternatively if you want the script already in a ps1 file, you can download it here.
- This example requires the Quest AD cmdlets to create the new users. Once you have those installed, don’t forget to load them in PowerShell using Add-PSSnapin or in PowerGUI using Libraries in the File menu.
- This shows the finished script I built during the demonstration, with the addition of the assignment of the default user password value as P4$$w0rd. Whatever you use for the default password value, it must meet your password requirements in your lab.
- If you want to run this without making changes, don’t forget to append -WhatIf at the end of the last line in the script.
Don’t be afraid to ask me questions about any of this, whether you need help customizing this script to make it work in your environment or just want an explanation of how the script works. I’m always happy to help!
Kirk out.
| Share this: |
Use PowerShell instead of cmd.exe
If you’re reading this blog then the point is probably moot, but I’ll put it out there anyway. One strong recommendation I was giving to IT admins who came to see me on the tour I was on for the past three weeks was this: if you need to go into cmd.exe to run some command, do it in PowerShell instead. This is really, really important. Jeffrey Snover talks about it here. Even if you don’t have time to dive in and start learning a lot about it today, just using PowerShell instead of cmd.exe is a step in the right direction. It will start exposing you to how things work slightly differently in PowerShell and allow you to start scratching the surface so that learning more is just that much easier when you do have the time to do so. The next time you find yourself in cmd.exe, flip over to PowerShell and run your commands there instead! You’ll be doing yourself a big favour!
Kirk out.
| Share this: |
EnergizeIT Certification Bootcamp – National User Group Tour 2008
Last night marked the last stop for the EnergizeIT Certification Bootcamp National User Group Tour 2008 here in Canada. A little while back Microsoft invited me to present Windows Server 2008 features (including PowerShell) during this tour with Kai Axford, and I am absolutely thrilled that I was able to take them up on their offer. Kai is a phenomenal speaker and it was a great privilege for me to be able to present at these events with him.
The tour spanned across the last three weeks and included 10 major cities in Canada, in the following order: Halifax, Toronto, Ottawa, Montréal, Winnipeg, Regina, Victoria, Vancouver, Calgary and Edmonton. Previously I had only been to the first four of these cities, so this was a great opportunity for me to get out and visit the rest of Canada. There was a ton of interest in this tour and most stops sold out within 24 hours after they were announced. Fortunately there were not many technical difficulties along the way at all, and for those technical difficulties that did occur, I sincerely apologize for the impact they had on the demonstrations.
One thing in common among each of these events that really made it fun for me as a presenter was the people. The people that took the time to come out and try and learn something from these events were just great. I can’t tell you how much I enjoyed being able to meet so many IT professionals face to face, hear about their problems or concerns, and hopefully show them something useful that will make their job easier.
Many thanks to Kai, Sim, Bruce, Nik, the user group leads, all of the attendees for coming out, and anyone else involved in making this event happen! It has been a very rewarding experience for me!
Kirk out.
| Share this: |
Essential PowerShell: Use non-portable console customizations sparingly
Isn’t it odd how issues with software are often raised in groups? I’ve been helping people use software for a long time and I find it uncanny how when I come across an issue once, there are bound to be two or three other occurrences of the same issue just about to be brought to my attention. Maybe it just seems that way because once I’m on track to discovering the issue I notice other occurrences of the same issue more easily. All I know is that this happens all the time.
Recently one such issue came to my attention quite a few times and it needs to be talked about. Any of the following questions were used by those facing the issue:
- Why doesn’t this command work in that PowerShell console?
- Why did my PowerShell script work when I ran it here but it doesn’t work when I run it there?
- Why can’t I find command commandName? It worked fine when I used it in the other console.
- I used to be able to use drive driveName, but I can’t anymore. Why?
The answer to these questions lies in the recognition of one area where PowerShell is not very consistent: through the use of customized PowerShell consoles.
Since PowerShell has been out now for over a year, many product teams now provide PowerShell snapins for their products. This includes Microsoft products like Exchange, System Center Operations Manager, System Center Virtual Machine Manager, SQL Server and IIS (among others) as well as ISV products like VMware ESX and Server (the VI toolkit) and Quest ActiveRoles Server (the QAD cmdlets). And there are others who provide PowerShell snapins for a particular business need, like SDM Software’s Group Policy Management Console (GPMC) Cmdlets, /n software’s NetCmdlets, and SoftwareFx’s PowerGadgets. Many (the majority, in fact) of these snapins come with their own customized PowerShell console. These customized console are designed to do one or more of the following:
- Display welcome text with help.
- Show a tip of the day.
- Run in elevated mode on Windows Vista and Windows Server 2008.
- Load the PowerShell snapin(s) relevant to the product that the shell customization came with.
- Change the current location to a provider that was included with the snapin(s) or a drive that was created within the customized shell.
- Create custom commands (functions and aliases) to make it easier to use the snapin(s).
- Prompt the user for connection-related information to establish a connection required for the cmdlets to work.
There are definitely other possibilities of how these customized consoles might be used, but this list gives you the general idea. Most of these customizations are helpful because it gives the PowerShell newcomer a starting point; however, more than half of them can give users the wrong impression and cause them to ask the questions listed above when they use other PowerShell consoles. Let’s look at some examples.
One thing in common among each of the customized consoles is that they load the PowerShell snapin(s) relevant to the product that the shell customization came with. The Exchange Management Shell loads the two snapins that come with Exchange, so that users don’t have to do this to use Exchange cmdlets:
Add-PSSnapin -Name `
Microsoft.Exchange.Management.PowerShell.Admin
Add-PSSnapin -Name `
Microsoft.Exchange.Management.PowerShell.Support
This might not seem like a big issue, however in practice it seems to give users the false impression that they can simply call the cmdlets they need from any PowerShell script or console, which ultimately results in head-scratching when commands or a script don’t work somewhere else. And as indicated, this is common among each of the customized consoles, so the IIS PowerShell Management Console, System Center Operations Manager Command Shell, Windows PowerShell with PowerGadgets, and others all do the same thing, loading their respective snapin automatically.
Another customization that seems to be common is for consoles to provide custom commands (aliases and functions) that are only available in that particular console. VMware does this in their VMware VI Toolkit (for Windows). When you open that console, you are presented with a message that shows you four commands as useful starting points, three of which only work in the VMware VI Toolkit (for Windows) shell (FYI, the commands I’m referring to are Get-VICommand, Get-VC and Get-ESX). You can imagine that causes confusion when someone is trying to use one of these commands in another console. Of course VMware isn’t the only one that does this. The Exchange Management Shell creates three commands that are only available by default in that console (Get-ExCommand, quickref and Get-ExBlog) and the System Center Operations Manager Command Shell creates 10 commands that are only available by default in that console. I won’t bother listing all of those here because I’m sure you get the picture by now. Trying to use these commands in other consoles without adding them to the profile or explicitly creating them results in an error indicating that the command was not found and invariably some head scratching for the individual who is trying to run then.
A third type of customization is to check for the presence of a connection and then to prompt users for connection information if a local connection was not detected. The System Center Operations Manager 2007 Command Shell provides connection management like this in its console. The connection that is established is not usable outside of that console, nor is it documented accordingly, so users need to be aware that their scripts will have to include commands to make the required connections in order to work in any PowerShell environment.
There are surely going to be other examples of this as different teams customize their console environment to meet their needs. As a PowerShell end user, when these customized consoles are very convenient, what can we do to make sure we’re aware of what customizations are being made?
Fortunately the console customizations are easy to discover. Every customized console uses PowerShell’s command line parameters to perform the customizations. This means viewing the properties of any of the shortcuts used to launch a customized console allows you to see what customizations are being performed by examining the command line parameters for powershell.exe. The customizations that you need to look at are the PowerShell console file that is used (as identified by the -psconsolefile argument) and the script that is executed (as identified by the -command argument). The PowerShell console file (psc1 file) is an xml document that defines which snapins should be automatically loaded by PowerShell when it starts. The snapins identified in this file are silently added to the PowerShell session when it is opened. The command argument identifies the PowerShell script or PS1 file that will be run after the snapins are loaded. This script is used to customize the look of the console, create custom commands, manage connections, etc.
Now that you have this information, all you need to do is make sure you are aware of the customizations in the console you are using, particularly those that are not portable to other consoles, so that you don’t make incorrect assumptions when you write your scripts.
Before I close this off, I have a request that I’d like to put out there for snapin developers. If you’re creating a customized PowerShell console when your snapin is installed, please make an effort to make those customizations self documenting. I don’t want you to hurt the end user experience your after, but I think a bit of carefully worded output that identifies your console customizations as customizations that are specific to that console would go a long way to educate beginner PowerShell users about how consoles can be customized and what they need to be aware of when switching from one console to the next. Without that information, users simply aren’t getting the information that they need to use your commands in other console that they might use. And of course, if you are making custom function that are only available in your customized console, ask yourself, should those function only be available in one console, or should they be available all the time. Often times I bet the answer is the latter, so please consider making cmdlets for those function you feel are necessary for the right experience when using your snapin. Otherwise you’re just making it more difficult for your users to have the experience that you want them to have.
Thanks for reading!
Kirk out.
| Share this post: |