Friday, June 18, 2010

PowerShell Script Provider

Just when you think we’ve seen all that the (awesome) PowerShell community can do, along comes another cool development. The latest coolness comes from Oisin Grehan in the form of a PowerShell Script provider. This is a tool, which you can download from Codeplex, that enables you to write a provider purely in script without the need to do stuff in C#. This is pretty cool!.

The project is at version 0.1, with at least 4 more versions planned. As it says on Codeplex, this code is alpha – but knowing Oisin those versions will come quickly. 

Thursday, June 17, 2010

Signing PowerShell Scripts – A Gotcha with ISE!

In some enterprise environments, signing PowerShell scripts and setting an execution policy to only run signed scripts is a useful control mechanism. It can avoid less skilled admins ‘fixing’ a script almost correctly and can avoid untested scripts from running. Of course, the malign admin can still cut/paste the scripts into the command line and do damage – but that same admin can nuke the registry, reformat a volume, etc. Script signing is just another layer of defence.

The Scripting Guys Team (well actually superstar MVP Ragnar Harper) has written a two part blog post on the subject of how to do script signing. Part 1 is a useful tutorial on how to setup your own PKI using Windows Server’s built in Certificate Service feature (AD CS as MSFT call it). With Part 1, you learn how to get your code signing digital certificate.  Part 2 then talks you through how to use that certificate to generate a signed script.

The demo is good and the instructions work well, however there is one small gotcha. If you use PowerShell ISE to edit and save your scripts, the technique shown in Part 2 will fail. Here’s what you will see (from the ISE).

image

As you can see, this results in a rather less than helpful “UnknownError”. Turns out the reason is simple: By default, ISE saves scripts in Unicode BigEndian format – which Set-Authenticode does not cater for. And worse, the ISE Save-As dialog does not give you any option to save in a more friendly encoding (ie ASCII!).

There are three solutions to this:

1. Use Notepad to re-save the file as ASCII, then sign it. This is suboptimal but it works.

2.  You can get ISE to save as Unicode (not BigEndian) using a small script, unfortunately not from the menus. Just run the following bit of code:

$psise.CurrentFile.Save([system.Text.Encoding]::Unicode)

3: You can get ISE to save as always as ANSI. As t add the following bit of code to your PowerShell ISE:

register-objectevent $psise.CurrentPowerShellTab.Files collectionchanged -action {
    # iterate ISEFile objects
    $event.sender | % {
        # set private field which holds default encoding to ASCII
        $_.gettype().getfield("encoding","nonpublic,instance").setvalue($_, [text.encoding]::ascii)
     }
}

Once this fragment is executed, probably by adding it to your Profile, scripts get saved as ANSI and can be signed just fine.

Note in the above, you can both save the current file as ASCII or auto-save as Unicode. Set-AuthenticodeSignature works with both encodings, just not the ISE normal default of Unicode BigEndian (just change ::ASCII to ::UNICODE or vice versa!). Personally, I now save as ASCII. But if you have non-ANSI characters in your scripts, set the default as Unicode!

And a tip of the hat to Oisin Grehan who posted about this on the MVP list and who has posted some of the above code on his blog here.

 

Thursday, June 10, 2010

Communications Server ‘14’ Powershell Blog Up And Running

The Communications Server ‘14’ team have put up a CS and Powershell blog. You can read it at http://blogs.technet.com/b/csps/. It’s early days, as CS14 was finally revealed to the world (with no NDA!) here in New Orelans TechEd North America. Speaking to the PowerShell PM, the intention is for the blog to be a one-stop shop for all CS14 and PowerShell. I look forward to seeing how this evolves!

Friday, June 04, 2010

Training and the Cloud

I’ve been having some discussions with a client about the impact of cloud computing on the IT training business, particularly IT Professional training. If you believe the hype, cloud computing will take all the problems of running your IT suite and make it a thing of the past. Thus, you don’t need any more IT Pros and therefore no training. Of course it’s nowhere as simple as that! I’ve been reading an interesting blog piece by Alan Le Marquand titled From Servers to Services: the Role for the IT Pro in the Cloud. It’s provided some good input into the training question.

Alan first makes the point that 'the cloud’ is actually many things. Cloud computing has evolved in to distinct layers, each with their own approaches and IT Pro needs. Le Marquand breaks “the cloud” down into three main layers:

  • Software as a Service (SaaS)– here you buy the software hosted by a supplier. For example, an organisation can use one of many hosted Exchange solutions for email. For this layer, the hardware, OS layers and application peices are for the most part gone. so IT Pros no longer need to worry about them. Of course, at the application layer, there is still a need to perform management and provisioning functions such as adding or removing email accounts as employees come and go. And since you are paying for the application, you need to monitor your SLA, possibly differently than today as well as manage your supplier.
  • Platform as a Service (PaaS)– here the hardware and OS are provided by a supplier but you provide the application – Microsoft’s Azure is an example of this cloud layer. With PaaS, the OS and hardware are primarily managed by the supplier , but you manage the application that sits on top.This layer still requires IT Pros to handle all the application management functions plus the ability to manage the platform in the cloud. 
  • Infrastructure as a Service (IaaS) – here you just get the hardware provided by the supplier and you deal with the OS, application and everything above. To some degree, this is really not much different than from today in terms of the skills that IT Pros need – the key difference being where you put the hardware and how you scale it out (or not!). IT pros still need to know how to deploy the OS and the applications and manage them. Only the scale is different – you still need to patch, troubleshoot etc.

The role that the IT Professional plays in each of these layers differs, in some cases significantly, from today.  And of course, this means training needs differ too. All three layers require you to consider end-user/administration training in how to use and get the most out of the applications. PaaS and IaaS also require you to know how to develop and deploy your application solution. And finally, IaaS requires you to have broadly the same deployment skills as today since most IT Pros start their tasks once the hardware is in place.

The key first step all organisations considering the cloud need  to take is to get a good understanding of how to buy as well as deploy and manage cloud services. Organisations are being led to believe by the suppliers that the Cloud is the answer. That may be the case ultimately, but not all suppliers are equal and not all offerings are the same. So companies need to understand how to go about buying the services and then how to deploy them. For IT Pros, that deployment may be a challenge as there are new issues to consider. Deploying application to hundreds or thousands servers require you to have new automation skills than you might have needed if you just use the GUI to manage one server.

The suppliers of particularly PaaS and IaaS also need to deliver or facilitate training in their offerings. While SQL on Azure may be almost like SQL on your own server, there are differences. Also, deploying and managing larger numbers of servers will require new approaches to the tasks.

For organisations that are considering cloud computing, I’d recommend spending some time to think through just which cloud layers you are considering and the impact those have on your IT staffing. Then you should start to do some training needs analysis. The cloud offers organisations of all sizes some advantages and as Alan poitns out, IT Pros, and hence the training, will certainly adapt to fit the cloud model. But there is still some thinking and planning to be done before leaping off in to cloud-land!

Technorati Tags: ,

SQLIse – A PowerShell SQL Server Query Tool

I am doing some work at the moment building SQL PowerShell training for an upcoming PowerShell MasterClass. In my searching, I came across a small project being done by Chad Miller, called SQLIse. As Chad describes in his blog, SQLISE is an ISE add-on that provides  “a basic IDE for T-SQL that includes the ability to exit, execute, parse and format SQL code from within PowerShell ISE”.

SQLISE is a part of a larger SQL PowerShell project called SQL Extensions for PowerShell or SQLPSX. Having played a bit with both extensions, they are pretty cool and can certainly help IT Pros who have to deal with SQL. Chad has even created a short video to demostrate SQLISE – get this at YouTube: http://www.youtube.com/v/1KcNSHn7oTA&hl=en.

SQLISE has two pre-requisites. First, you need to have the PowerShell Pack installed and you need the SQLPX extensions loaded. You can get PowerShellPack from the MSDN Code Gallery.

One issue I faced was that the SQLIse installation process was not seamless or easy.  In order to get this running, I needed two uber-modules (SQLPSX and PowerShellPack) and these come from different places. Second, the installation process requires you to run programs, SQLPSX_Install and PowerShellPack.MSI.

I find this somewhat contrary to the spirit of Modules in PowerShell V2 in that modules should be deployable using only Xcopy. In my case, I did not want either uber-module to be loaded in the personal modules folder, but in the system modules folder. But the installer(s) gave me no option. More importantly, while the SQLPSX installation program seemed to run, but left the module folder empty. A bit of hacking (and running streams.exe across the expanded file set!)  enabled me to get the module installed. But sadly the hacking did not work well – and some of the features do  not work. More hacking I suspect is needed.

In summary, a great feature let down by the complex installation process.

Wednesday, June 02, 2010

PowerShell Admin Module – A Follow Up

in a recent blog article I wrote about a new Codeplex project called PowerShell Admin Modules, being developed by super-star MVP Richard Siddaway. I noted two small things I’d noticed about the module. Well today, Richard wrote to say he’d fixed Get-Share to accept wildcards and had changed around the parameters of New-Share to match that of the venerable Net Share.

He also mentions the latest version, 0.2, has a bunch of functions for dealing with binary and hex numbers, which include:

  • ConvertTo-Binary
  • ConvertTo-Decimal
  • ConvertTo-Hex
  • Get-BinaryAND
  • Get-BinaryDifference
  • Get-BinaryOR
  • Get-BinarySum
  • Get-BinaryXOR
  • Get-HexDifference
  • Get-HexSum
  • Test-Binary
  • Test-Hex

This is nice work – although one thought would be to merge the functions of PSAM into the PowerShell Community Extensions.

Tuesday, June 01, 2010

The PowerShell Guy Has Returned

Marc, aka The PowerShell Guy is back. In his blog (now back on air), Marc recounts a tale that is all too familiar to many of us: IT problems combined with the demands of a real life. But thanks to those very nice folks over at OrcsWeb, Marc’s site and his many outstanding contributions are back online.

Welcome back to the online world Marc!

Monday, May 31, 2010

Another Reason Why PowerShell Matters

I’ve just been reading an interesting blog article in Peeters Online about fixing a DCOM issue that affects some machines. The issue results in Error Log entries with DCOM Event 10005 – Service can not be started. At least one common cause of this is disabling the Remote Storage Manager. The solution involved some manual registry editing and that is something I really do NOT like doing on production servers. 

In PeetersOnline, the author presents a nice PowerShell script to fix the issue. The script opens the remote registry, and does the necessary fixes. The script is parameterised therefore suited to larger organisations but more importantly, seems to handle the key error situations (keys not being found, not able to connect to the remote registry). You could go further, and create a trouble-shooter using the Windows SDK to enable remote admins to do the job even more simply (and perhaps both avoiding doing it where not needed and ensuring it’s done properly where it is).

This script shows how PowerShell can be used both to automate a solution and at the same time ensuring good documentation on what the fix is. The script , but also provides a measure of security from the admin that can’t type well! The reliable repetition of accurate instructions is a key to improving availability. It is things like this that make PowerShell so important.

Technorati Tags:

Sunday, May 30, 2010

Awesome script

I just saw a neat post over on twitter regarding Beyond Export-Csv: Export-Xls 

This is an awesome script, and one I've put into my profile already!! It might be a good addition to PowerShell Community Extensions.

Sunday, May 23, 2010

PowerShell Admin Module

I’ve been playing a bit with a Codeplex project called PowerShell Admin Modules (PSAM). Developed by Richard Siddaway, PSAM is intended to supply a number of PowerShell modules for use by IT Pros. The first of these modules contains 6 functions that work with shares, as follows:

  • Get-Share
  • Get-ShareAccessMask
  • Get-ShareSecurity
  • New-Share
  • Remove-Share

Using this module is easy. First download the zip file from Codeplex and expand the contents into your modules folder. Then import the module using Import-Module. It looks like this:

PSH [C:\foo]: import-module PAMSHARES
PSH [C:\foo]: get-command * -module pamshares

CommandType     Name                                                Definition
-----------     ----                                                ----------
Function        Get-Share                                           ...
Function        Get-ShareAccessMask                                 ...
Function        Get-ShareSecurity                                   ...
Function        New-Share                                           ...
Function        Remove-Share                                        ...
Function        Set-Share                                           ...

PSH [C:\foo]: new-share c:\foo foo2
Share foo2 was created
PSH [C:\foo]: get-share foo2

Name                                    Path                                    Description
----                                    ----                                    -----------
foo2                                    c:\foo

PSH [C:\foo]: remove-share foo2


The module works well enough although get-share does not seem to support wildcards and the order of the parameters in New-Share is different from that of Net Share (for those of us who even remember Net Share!). I’ve posted a fix to the wildcard issue on CodePlex. For the other issue, one could just change the order of the parameters in New Share. This is the joy of open source proejcts like this – you can fix ‘bugs’ and make your own changes as you see fit.

Friday, May 14, 2010

PowerShell Community Extensions (PSCX) 2.0 Released

A new version of the PowerShell Community Extensions (PSCX), version 2.0, has been released and is available from Codeplex (http://pscx.codeplex.com/releases/45101/download/121340). This free set of PowerShell extensions provides a number of very useful enhancements, particularly new/added cmdlets.

The main purpose behind the 2.0 release was to migrate the code from being a snap-in to being a module. As it’s a module, deployment is really simple – just Xcopy the files into your module folder and use Import-Module to load the module (typically you just put the Import-Module into my $profile). You can of course, put the module somewhere else and specify the full path using the Import-Module cmdlet.

PSCX also includes some NEW cmdlets, including:

  • ConvertTo-Metric
  • Get-AlternateDataStream
  • Test-AlternateDataStream
  • Remove-AlternateDataStream
  • Unblock-File
  • Get-LoremIpsum (lorem)
  • Get-TypeName (gtn)
  • Get-Uptime
  • Get-FileTail (tail)

This package is a great set of very useful extensions. Being module based, deployment is much simplified. I commend this release to all PowerShell users!

Wednesday, May 05, 2010

MSDN Webcast: Powershell for Data Professionals Tomorrow (May 5th)

I just got news of an interesting SQL PowerShell web cast coming up tomorrow. In the webcase, Microsoft SQL Server guru Aaron Nelson is going to look at how you perform everyday database administrator tasks using POwerShell. He’ll cover backing up user databases, scripting table objects, and evaluating disk space usage. The idea is to demonstrate how PowerShell scripts can be used to automating SQL Server activities.

Sign up for the web cast here: MSDN Webcast: geekSpeak: Powershell for Data Professionals (Level 200). I’ll try to post details of the recordings after the event for those that can’t make it.

Technorati Tags: ,,

Thursday, April 22, 2010

Digicert - Utility for Managing SSL Certs

Most of the readers of this blog will have used and possibly setup SSL on a web site. If you really, really know what you are doing and do it all the time, managing digital certs is relatively straigtforward. But for over-worked admins who DON'T do this daily, dealing with things like intermediate CAs, keys, etc, etc is just a mind-bending experience. It's also easy to make mistakes (for example, adding a root CA cert to your personal vs computer store).

Digicert, who sell digital certificates, have created a new and free certificate management utility. This utility provides a number of useful features including:

  • See all the SSL certificates installed on a server.
  • View details for all certificates.
  • Import and Export certificates either as a backupo or to copy/move certs between servers.
  • Test a certificate

You can download this utility from Digicert’s site for free – and you run it on the server you wish to test. Here’s what the UI looks like:

image

If you are using services that require digital certs, such as Communications Server (aka OCS), then this tool may well be very useful in helping to resolve certificate issues on your OCS/CS systems.

Wednesday, April 21, 2010

PowerShell Cmdlets Search via Bing

Microsoft this week released a new feature in the Bing search engine – a visual search of PowerShell Cmdlets. This is part of the Visual Search feature of Bing which allows you to search using visual images, versus just text. When you fire up the Visual Search , you will now see a “Visual Search” link.  You can then click through to see the PowerShell Cmdlets. Sadly, this is available currently only in the “en-us’ version of Bing, but it looks like this:

image

 

Along the left, you can see a number of categories (Top 12 Cmdlets, WMI Cmdlets, etc) as well as some ways to narrow down your search. I especially like the ‘Introduced in Version’ and ‘Remoting Uses’  As you can see in the above graphic, when you click on a cmdlet, you get more help information along the right, including basic cmdlet information and several links to more detailed help documentation. Although you can’t see it from the graphic above, this page seems to be generated by using WPF, so you get some pretty neat effects when you click on the left hand pane of this page!

Th PowerShell Cmdlets search feature is available on the US version of Bing only. Unlike Google, there seems no way to invoke country specific versions of Bing. You get what Bing works out to be your local variant. But with a little hacking, you can indeed get to the above page. The rather unfriendly URL is: http://www.bing.com/visualsearch?mkt=en-us&g=powershell_cmdlets&FORM=SGEWEB&qpvt=powershell#remoting=1&r=1. Alternatively, you can start at the Bing US home page and drill down from there (http://www.bing.com/visualsearch?mkt=en-us).

There will also be more cmdlets documented this way. I have no idea what the time table is, either for wider disbribution of this pretty cool feature, or when we’ll see more cmdlets being documented.

Technorati Tags: ,

Saturday, April 17, 2010

PowerShell Profile Files

PowerShell defines some special script files, called Profiles, that you can use to customise and configure a PowerShell Session, whether you are using Powershell.exe, PoweShellISE.exe or a customised version (e.g. Exchange Management Console). The neat thing about the profile is that it runs, at start-up of every PowerShell host, in dot sourced mode. Thus functions and variables defined in the profile persist in your shell.

For each PowerShell Host, you have up to four potential profiles:

  • AllUsersAllHosts
    • C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
  • AllUsersCurrentHost
    • C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1 (PowerShellISE.exe), or
    • C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 (PowerShell.exe)
  • CurrentUserAllHosts
    • C:\Users\<username>\Documents\WindowsPowerShell\profile.ps1
  • CurrentUserCurrentHost
    • C:\Users\tfl\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1 (PowerShellISE.,exe), or
    • C:\Users\tfl\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 (PowerShell.exe).

For both the CurrentHost files – these will vary depending on which host the script is run. Above shows the profile files for both PowerShell and PowerShell ISE. The profile files (obviously one each of the four!) run in the order noted above. This means the admin could, for example define some functions in the AllUsersAllHosts that you can override in your CurrentUser profiles.

As it turns out, there’s a very PowerShell one-liner you can run to return your host’s profile files (and can even tell you if the file exists!) This one-liner looks like this:

$profile | gm *Host* | % { $_.Name } | % { $p = @{}; $p.Name = $_ ;$p.Path = $profile.$_; $p.Exists= (Test-Path $profile.$_); New-Object PSObject -Property $p } | Format-Table –AutoSize

I’ve posted a similar script over on my PowerShell Scripts blog. The script I’ve posted on the PowerShell Scripts blog contains a Format-List (to look a bit better on the blog. You might prefer the Format-Table in the one-liner above.

 

Technorati Tags: ,

Wednesday, March 24, 2010

PowerShell Master Class – More Sessions

I’ve had a gratifying response to my first PowerShell Master Class event. Like all first time runs, you learn some things by running the event.  One of which is that three days is not long enough. So future events are not four days. Not that I neede dto learn it, but the last run shows that, given how vast V2 is,  there is stuff that even with four days, we still can’t cover. So I am planning an advanced seminar for later in the year – watch this space.

In the mean time, we have two more sessions currently planned:

I’m also discussing a further session in Stockholm in September along with a more advanced workshop also in September in Stockholm.

Master Class outline

The class outline is as follows:

Day 1 – The Basics of PowerShell

  • PowerShell Fundaments – the key elements of PowerShell including installation, setup, profiles
  • Discovery – finding your way and learning how to discover more
  • Formatting – how to format output nicely

Day 2 – From the command line to the script

  • Remoting – working with remote systems and PowerShell’s remoting feature.
  • Providers – getting into OS data stores
  • Scripting Concepts – automating everyday tasks including language constructs, error handling and debugging

Day 3 – Practical PowerShell

  • Modules – managing PowerShell in the enterprise
  • .NET/WMI/COM Objects – working with objects of all kinds, including WMI, COM, .NET and your own custom objectw
  • PowerShell and Windows Client/Server – how you can use built in PowerShell cmdlets and providers included with Windows 7 and Windows Server 2008 R2

Day 4 – Applying PowerShell 

  • PowerShell in Key Microsoft Servers - a look at PowerShell today in SQL, Exchange, SharePoint 2010, SCVMM/HyperV and CS 2010.
  • Taking it to the Next Level – stuff to do later!

Monday, March 22, 2010

And now for something quite different

I have a good friend that lives on the Big Island of Hawaii (Kona side). She runs a coffee plantation and a small Mac consultancy in her spare time. I’ve enjoyed her coffee for a long while (if only post was somewhat less expensive!).

She also rents out a room on the coffee estate for you to rent. The rate is US$50/night plus 12%tax). This is a real bargain near some great snorkelling and diving locations. The house is high enough up in the hills for good sleeping (and of course good coffee). And the place is pretty quiet which is good if you just want to get away from it all and chill.

Although the pictures are not the most artistic, Mahi House itself itself is fairly new – with parking!

 YourHouse

The room is also nice:

YourRoom

So if you are heading over to Hawaii and looking for a bargain place to stay, please let her know (MahiHouse@Yahoo.com).

Technorati Tags: ,

Official Microsoft Team Blogs

Over the past few years, Microsoft has gotten big on blogging. A number of employees blog their activities to a personal blog. Additionally, a number of product teams blog, as a team. Some of these, such as You Had Me At EHLO (The Exchange Team Blog) are fantastic, with re rest mostly very good.

Naturally, there's a page to see an Official list of Microsoft Team Blogs / Microsoft Blogs!

There is some great information here -if you have the time to read it all!
Technorati Tags: ,

Saturday, March 20, 2010

Windows PowerShell Cookbook

I see Lee Holmes is updating his Windows PowerShell Cookbook - a nice book that is one of the three I carry around when I train PowerShell. If you head on over to the O'Reiley Labs site, you can view the emerging next edition.

If you sign-up/register (see link at the top of the page), then you can make coments etc.

Wednesday, March 17, 2010

PowerShell Master Class in Stockholm – A Great Success (and now a repeat!)

The PowerShell Master Class in Stockholm last week was three long days of PowerShell Fun. The course went very well and the delegates great.

The training centre, LabCenter.SE is an amazing place to teach. The rooms are well kitted out (killer sound systems), good lighting, great chairs, and very good computers. It’s a very happy environment – lots of nice refreshments, and the people are all wonderful. I think it’s one of the nicest centres I’ve taught at in a long while.

The delegates enjoyed the course they asked more more! So sometime late summer, early Autumn, I’ll go back for 4 more days of PowerShell Applied – lots more in depth labs etc. And given the market, the centre want me to come back to Stockholm to teach another run of the PowerShell Master Class in May (May 25-28) – although the web site is currently showing the wrong dates and length! We are making this a four day class – so even more fun and all the more PowerShell! 

To register for this course, you shoudl go to http://www.labcenter.se/shoppingcart.aspx?t=1 (although I note the price and duration is not yet correct so you might hold off booking for a wee while till I get the site updated).

Tuesday, March 16, 2010

Updating Reskit.Net

In last week’s PowerShell Master Class in Stockholm, I noticed that reskit.net was a tad out of date. I also agreed to put up a references page for the delegates to share all my many book marks. I found an old copy of FrontPage (ancient but it does the business) and have made a start.

Thus far, I’ve tidied up the front page a bit, and have I’ve removed some of the really old contents. I also created and began populating a /PSMC sub folder and made a link to an already existing /PowerShell Folder. There were a bunch of very old Monad and PowerShell scripts that I’ve removed (these will migrate over to http://pshscripts.blogspot.com).

Please take a look and add come comments!

Technorati Tags: ,

Monday, March 15, 2010

SCCM PowerShell Module

The relentless community development on all things PowerShell continues unabated. Today, I found a module for use with System Center Configuration Manager (SCCM). This module contains the following functions:
  • Get-SCCMCommands
  • Connect-SCCMServer
  • Get-SCCMObject
  • Get-SCCMPackage
  • Get-SCCMCollection
  • Get-SCCMAdvertisement
  • Get-SCCMDriver
  • Get-SCCMDriverPackage
  • Get-SCCMTaskSequence
  • Get-SCCMSite
  • Get-SCCMImagePackage
  • Get-SCCMOperatingSystemInstallPackage
  • Get-SCCMBootImagePackage
  • Get-SCCMComputer
  • Get-SCCMUser
  • Get-SCCMCollectionMembers
  • Get-SCCMSubCollections
  • Get-SCCMParentCollection
  • Get-SCCMSiteDefinition
  • Get-SCCMSiteDefinitionProps
  • Get-SCCMIsR2
  • Get-SCCMCollectionRules
  • Get-SCCMInboxes
  • New-SCCMCollection
  • Add-SCCMCollectionRule
  • Add-SCCMDirUserCollectionRule

It looks a great start. And while I like how all the nouns are all prefixed, there is the danger that when the SCCM team eventually deliver native SCCM cmdlets, there is a danger of cmdletname collision down the line.

Monday, March 01, 2010

PowerShell Documentation Community Review

The Microsoft PowerShell doc team is looking for volunteers for the third documentation review cycle. This cycle is focusing on the needs of new and intermediate PowerShell users. And if you speak a language other than American or English, then they’re doubly interested. Shay Levy has some more details over on his site.
If you care about the documentation, particularly non English language material, then contact superstar and writer extraordinaire June Blender (JuneB@Microsoft.Com) or PowerShell community superstar Marco Shaw (Marco.Shaw@Gmail.Com). Please help make the documentation better.

Sunday, February 28, 2010

Discovery In PowerShell – Get-Help vs. Get-Command

Discovery is process by which a user will learn to use any product. The more discoverable any product is, the easier it is for new users to get started. A disoverable product enables any user both to leverage what they already know and to find more. PowerShell was designed to be, and I believe is, a discoverable product.

One example of this came up this week – looking at how you can find cmdlets (and other stuff) that you can run. By using Get-Help, Get-Command and some where clause foo, you can quickly locate and learn about cmdlets in your environment. And, this help information provides examples to illustrate the use of a particular cmdlet and some products (eg SCVMM) add additional About_* files.

Get-Command and Get-Help are similar but different. They both can be used to find cmdlets and other help information. So while sharing a similar usage, they return different information. Get-Help returns information on 4 categories: Alias, Cmdlet, Provider and HelpFile. Get-Command, on the other hand, returns information of 6 different command types: Alias, Application, Function, Cmdlet, ExternalScript and Filter.

Where this helps is knowing which cmdlet to use to search for what. If you are using pure PowerShell Cmdlets, modules and scripts, Get-Help will be your main discovery tool. But if you are also using console applications from, say earlier versions of SharePoint, then Get-Command will help to find the commands you might need.

The trick to getting the most out of these cmdlets is knowing how to search and the key to that is using wildcards. If you want to find out what cmdlets, etc, are available for a PSSession object,

 

PSH [C:\]: Get-Help *PSSEssion*

Name                              Category  Synopsis
----                              --------  --------
Register-PSSessionConfiguration   Cmdlet    Creates and registers a new session configuration.
Unregister-PSSessionConfiguration Cmdlet    Deletes registered session configurations from the computer.
Get-PSSessionConfiguration        Cmdlet    Gets the registered session configurations on the computer.
Set-PSSessionConfiguration        Cmdlet    Changes the properties of a registered session configuration.
Enable-PSSessionConfiguration     Cmdlet    Enables the session configurations on the local computer.
Disable-PSSessionConfiguration    Cmdlet    Denies access to the session configurations on the local computer.
New-PSSession                     Cmdlet    Creates a persistent connection to a local or remote computer.
Get-PSSession                     Cmdlet    Gets the Windows PowerShell sessions (PSSessions) in the current session.
Remove-PSSession                  Cmdlet    Closes one or more Windows PowerShell sessions (PSSessions).
Enter-PSSession                   Cmdlet    Starts an interactive session with a remote computer.
Exit-PSSession                    Cmdlet    Ends an interactive session with a remote computer.
New-PSSessionOption               Cmdlet    Creates an object that contains advanced options for a PSSession.
Export-PSSession                  Cmdlet    Imports commands from another session and saves them in a Windows PowerS...
Import-PSSession                  Cmdlet    Imports commands from another session into the current session.
about_pssessions                  HelpFile  Describes Windows PowerShell sessions (PSSessions) and explains how to
about_pssession_details           HelpFile  Provides detailed information about Windows PowerShell sessions and the

Or try the following:

PSH [C:\]: get-command *PSSession*

CommandType     Name                                                Definition
-----------     ----                                                ----------
Cmdlet          Disable-PSSessionConfiguration                      Disable-PSSessionConfiguration [[-Name] <String[...
Cmdlet          Enable-PSSessionConfiguration                       Enable-PSSessionConfiguration [[-Name] <String[]...
Cmdlet          Enter-PSSession                                     Enter-PSSession [-ComputerName] <String> [-Crede...
Cmdlet          Exit-PSSession                                      Exit-PSSession [-Verbose] [-Debug] [-ErrorAction...
Cmdlet          Export-PSSession                                    Export-PSSession [-Session] <PSSession> [-Output...
Cmdlet          Get-PSSession                                       Get-PSSession [[-ComputerName] <String[]>] [-Ver...
Cmdlet          Get-PSSessionConfiguration                          Get-PSSessionConfiguration [[-Name] <String[]>] ...
Cmdlet          Import-PSSession                                    Import-PSSession [-Session] <PSSession> [[-Comma...
Cmdlet          New-PSSession                                       New-PSSession [[-ComputerName] <String[]>] [-Cre...
Cmdlet          New-PSSessionOption                                 New-PSSessionOption [-MaximumRedirection <Int32>...
Cmdlet          Register-PSSessionConfiguration                     Register-PSSessionConfiguration [-Name] <String>...
Cmdlet          Remove-PSSession                                    Remove-PSSession [-Id] <Int32[]> [-Verbose] [-De...
Cmdlet          Set-PSSessionConfiguration                          Set-PSSessionConfiguration [-Name] <String> [-Ap...
Cmdlet          Unregister-PSSessionConfiguration                   Unregister-PSSessionConfiguration [-Name] <Strin...

If you are looking for more conceptual information about some feature (typically the noun in the cmdlet name – as here “PSSession”) Get-Help will return the ‘About_’ topics, These help you to learn more about the underlying objects, as well as the help information about specific cmdlets. I personally use Get-Help to remind myself of the cmdlets names and spellings.

And finally – if you are using Get-Help on your local machine, you can usually specify the –online parameter. This opens up a browser window into Technet, pointing to the current documentation. If you look at the online help for Enter-PSSession (http://technet.microsoft.com/en-us/library/dd315384.aspx), you can see this page was updated mid December. The PowerShell writers do a fantastic job of fixing the online versions of the help. And they are working on a way to get these updates to you as fast as possible.

Saturday, February 27, 2010

PowerShell Master Class in Stockholm – Filling Up Quickly!

In a recent blog post, I mentioned the PowerShell Master Class I am running in Stockholm on March 9-11 2010 (see Http://Www.PowerShellMasterClass.Com for more details). I’m pleased to say the class is nearly full! I am looking forward to three great days with PowerShell!

NITkon – Day Of PowerShell in Norway

For those in or around Norway next month (well Wednesday March 17th to be precise), NITKon, a Norwegian education conference for IT Pros in Norway, is holding Deep Dive PowerShell – a full day Of PowerShell content. I think this is the first conference to hold a full day just on PowerShell!

The contents of the day look pretty good too:

  • PowerShell Modules – Bruce Payette (superstar member of the development team and outstanding author)
  • Proxy Functions – Dmitry Sotnikov (fellow MVP and the brains behind PowerGui)
  • PowerShell and Wmi – ME!
  • PowerShell and .NET/COM objects – ME again
  • Advanced Features in PowerGui – Dmitry Sotnikov
  • PowerShell Advanced Techniques – Bruce Payette

I can’t wait for this event. I’m always keen to see Bruce and Dmitry – they are awesome speakers. I hope we will be able to post the slides once the event is complete.

Hope to see you there.

Technorati Tags: ,

Tuesday, February 09, 2010

Formatting with PowerShell

PowerShell is an increasingly important tool for the IT Admin. In it’s early version, it didn’t do much, but with products like Exchange, SharePoint 2010, and System Centre being so PowerShell focused, it’s a tool every IT Admin needs to learn and learn how to leverage.

A key aspect of PowerShell is output – getting the output you need. In some cases, that output can be quick and dirty: how many mail boxes are currently on Mailbox-Server-1? Or how many handles has the DNS server used (and has that changed since last week).

But often, output needs to look good as well as being accurate. PowerShell has a wealth of formatting capabilities (and with 3rd party tools like PowerGadgets, you have a bunch more).

I’ve written a two part article for The Scripting Guys to explain some of these options. You can find Part 1 at: http://tinyurl.com/yhmvvul, and Part 2 at: http://tinyurl.com/ykt7wq6.

These articles are the basis for one of the modules in my upcoming PowerShell Master Class that I blogged about last week.  I’ve taken Module 3 of the class and turned it into these articles, although I’ll be adding some more stuff into the Master Class!

I’d be grateful for comments!

Sunday, February 07, 2010

Solarwinds – Free WMI Monitor

I am slowly pulling together my upcoming PowerShell Master Class. One of the modules looks at WMI objects and I’ve been searching for as many cool tools etc as I can find. Thanks to a couple of tweets (Shay and Doug!), I found a pretty cool free tool from Solarwinds, called WMI Monitor. This is a free download that does a number of things, including:

  • monitors the performance on a Windows server
  • leverages pre-built and community generated application templates for monitoring virtually any application
  • enables you to modify or design your own application templates with the built-in WMI browser

This tool is free, but you do have to register. Also – it’s a 60mb download! But if you are doing WMI scripting with PowerShell, it might well be worth the download.

Technorati Tags: ,,

Friday, January 29, 2010

PowerShell Master Class – 9-11 March 2010 in Stockholm

Do you want to learn more about PowerShell V2? Do you want to take your skills to that next level? Do you want you head to explode as you learn more, more and more about PowerShell? If so, I have just the ticket for you1

March sees the first PowerShell master class. It’ll be three days of intense  PowerShell – hands on and practical. No marketing stuff – just hard core useful information and plenty of hands on. I’ll be turning up with more material than we can cover in the normal day, so we’ll  be having evening sessions in the hotel – and who knows the odd drink too!

Afraid it’ll all be too technical – well that’s always a risk, but we start off slowly and go deeper and further than any of the official courseware is allowed to. So  bring your helmet and seatbelts!

Here’s the class outline:

Day 1 – The Basics

  • PowerShell Fundaments – the key elements of PowerShell plus installation, setup, profiles
  • Discovery – finding your way and learning how to discover more
  • Formatting – how to format output nicely
  • Remoting – working with remote systems
  • Providers – getting into OS data stores
  • Homework – you’ll get a short assignment to complete by the start of Day 2

Day 2 – Diving Deeper

  • Scripting Concepts – automating everyday tasks including language constructs, error handling and debugging
  • Modules – managing PowerShell in the enterprise
  • .NET/WMI/COM Objects – working with objects
  • Homework – you’ll get another assignment to complete by the start of Day 3

Day 3 – Practical PowerShell

  • PowerShell and Windows Client/Server – how you can use built in PowerShell cmdlets
  • PowerShell in Key Microsoft Servers - a look at PowerShell today in SQL, SCVMM plus a look forward to the future with SharePoint 2010
  • Taking it to the Next Level – the stuff we can’t cover in these three days.

I am really looking forward to working with LabCenter – they have a great facility in Stockholm, and will provide great hands on systems for you to use (and there may even be a pretty cool take away that I can’t talk about today – so watch this space). They’re really nice people too!

Places are limited and I know there’s already a number of bookings – so book now!  See you in Stockholm in March. And please pass on the word!

Saturday, January 09, 2010

Number of Microsoft Certified Professionals Worldwide

As I pointed out in a blog post a while back, Microsoft Learning publishes a web page displaying the number of MCPs in the world. Well they used to – it looks like the page (https://www.microsoft.com/learning/mcp/certified.mspx) now just re-directs to a different page (https://www.microsoft.com/learning/en/us/certification/cert-overview.aspx) that just lists the details of certification itself, and not the number of folks certified. Shame really.

Technorati Tags: ,

Tuesday, January 05, 2010

Elevation Power Toy for PowerShell

Now this is pretty cool - a power toy to handle elevation of PowerShell scripts. The idea is simple: you run PowerShell as normal, then use this powertoy to run a script (or cmdlet) as elevated. Yeah! Still not quote SUDO but getting better.

You can get more information and the tools by visiting TechNet Magazine at: http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx.

Turns out this tool has been around for a while - wonder why I hadn't seen it before.

Technorati Tags: ,

Saturday, January 02, 2010

PowerShell Cmdlet Naming Conventions Inside Modules

PowerShell cmdlets use a verb-noun naming pattern. To the extent possible, you should follow the same pattern when writing your own functions and scripts. This verb-noun naming is partly enforced by PowerShell, at least as far as the verbs to. MS has published an approved verbs list on MSDN.
With PowerShell V2, if you try to import cmdlets or modules that violates the verb naming convention, you’ll get a warning. Here’s an example module to demonstrate this. First, I create the file testmodule.psm1. I store this as testmodule.psm1, inside my modules folder:

  1. # Demo of badly named function 
  2. # and how PowerShell V2 deals with it 
  3.  
  4. function badly-named { 
  5.   "Inside the badly named function" 
  6.   } 
  7. } 
Look what happens when I try to import it:
PSH [C:\foo]: ls $Modules\testmodule
    Directory: Microsoft.PowerShell.Core\FileSystem::C:\Users\tfl\Documents\WindowsPowerShell\Modules\testmodule
Mode           LastWriteTime       Length Name
----           -------------       ------ ----
-a---      1/2/2010 12:36 PM          340 testmodule.psm1

PSH [C:\foo]: import-module testmodule -verbose

VERBOSE: The command name 'badly-named' includes an unapproved verb which might make it less discoverable
VERBOSE: Importing function 'badly-named'.
PSH [C:\foo]: badly-named
Inside the badly named function

Ss you can see, you can create a module with a badly named function just as you can create your own badly named cmdlets – and they work. But when you try to import such a module, PowerShelL v2 emits a warning error.
So for those of you getting into PowerShell, make sure that the functions you are putting into modules are named correctly!
Technorati Tags: ,,

Tuesday, December 29, 2009

Is PowerShell only for the Nerds?

An interesting question, to say the least. This blog carries a lot of PowerShell content – and much of that content is aimed at IT Pro types. I think it’s clear that IT Pro nerds working in the Microsoft need to know PowerShell. PowerShell is central to Microsoft’s current and future management roadmap – so, yes, PowerShell is for nerds.

That begs the question though - should home users have to learn it? Well – yes and no. There are certainly a number of PC enthusiasts out there that want to learn more about how to manage their home computer – and PowerShell can help much like they once used Cmd.exe (and may still do). Learning PowerShell does involve a learning curve. And much of the documentation and a fair share of blog posts do tend to be on the dense side until you become more familiar with PowerShell. So persevere.

But should your grandmother have to learn PowerShell? No. No more than she’d need or even want to learn C, the .NET Framework, DNS, TCP/IP! Those technologies, and PowerShell too, is built into the “system” so she doesn’t have to use them directly. Of course, developers may well begin to use PowerShell as part of building their GUI – and I hope they do so.

So if you’re a nerd, take a moment to download PowerShell V2 (assuming you haven’t already done so) and get cracking!

 

Technorati Tags:

Saturday, December 26, 2009

Exchange 2007 Updated Help File

For some products, suggesting someone read a help file is like suggesting they take a long walk on a short pier (albeit less wet). But for Exchange 2007, this seems good advice. Microsoft published an updated version of the help file for Exchange, available for download from the MS Downloads site.

I hope they continue this approach with the advent of Exchange 2010.

 

Technorati tags: ,

Unified Communications Developer Portal

Microsoft's push into the world of Unified Communications continues with the launch of the Unified Communications Developer Portal.  This MSDN portal is part of the Office Development Center, and is designed to feature links and resources for developers wanting to get into UC.

As I write this updated post, there some interesting feature articles, including Detecting the State of the Office Communications Server and Building UCMA Installers.

This is a great site for developers (and admins that secretly want to be developers!) to learn more about developing in the UC space.

Friday, December 25, 2009

Merry Christmas – One and All

It’s time to rest and hang out with my family. For those of you on line today: Merry Christmas – now get back to the folks that matter. For the rest of you, I hope you had a great day.

Thursday, December 24, 2009

PowerShell V2 Download

If you are running Windows 7 or Windows Server 2008 R2, then you will have PowerShell installed by default. On Windows 7, both the PowerShell console and PowerShell ISE are installed by default. On Server 2008 R2, PowerShell console is installed by default, whilst the PowerShell ISE is a feature you can add using Server Manager. And of course, for any Server 2008 R2 core installations, you would need to add both the .NET Framework and PowerShell – virtually nothing extra gets added to Server Core!

For downlevel (aka older) versions of Windows, Microsoft has released a KB article which directs you to versions you can download. Go to the page http://support.microsoft.com/kb/968929 where you can find PowerShell V2 for Windows XP, Vista, Server 2003 and Server 2008 (RTM) – in both 32-bit and 64-bit versions. Note that in Server 2008 RTM, PowerShell is not supported in Server Core.

In addition to PowerShell V2, the downloads also include the RTM version of Windows Remote Management (WinRM). WinRM is Microsoft’s  implementation of the standards based WS-Management Protocol. WinRM is based on Simple Object Access Protocol (SOAP), and provides a firewall-friendly protocol enabling hardware and operating systems from different vendors to interoperate.

If you are are using an older OS, i.e. Windows 2000 or earlier, then there is no supported version of PowerShell for you. You can probably hack some or even most of PowerShell V2 into those older OSs. But things may not work – and it’s not ever going to be supported.

Want to REALLY Understand What PowerShell Remoting Does On The Wire?

Well, maybe not everything, but the document entitled PowerShell Remoting Protocol Specification contains 179 pages of details of what Powershell Remoting does! It’s not for the faint of heart, to say the least as it very detailed – just the sort of hard core techie details that the true PowerShell addict will lap up!

This document is one of the many Communications Protocols that Microsoft has been publishing. You can download the specific PDF for the PowerShell Remoting Specification, or download a zip file with all the PDF files for all the published specifications. The latter might be overkill even for the most hardened network geek.

Wednesday, December 23, 2009

Microsoft Releases the PowerShell v2.0 SDK

The Systems Development Kit, or SDK, is a download of stuff you need to be able to develop applications around a particular technical area. The Windows SDK is huge and there are SDKs for almost every technology MS produces. Other vendors produce SDKs too.

Initially, Microsoft shipped a PowerShell SDK. Then some time ago this changed and the PowerShell SDK was subsumed into the Windows SDK – which meant finding  just the PowerShell stuff was challenging. I saw any number of complaints around this in the newsgroups etc.

Well –the PowerShell team have just released the Version 2.0 SDK – as an independent (and small at 2.4mb!) SDK. The SDK contains the reference assemblies and 45 samples that help you to better understand how to use PowerShell. There appears to be no documentation (and the installation process doesn’t seem to add in any shortcuts or start menu items.

More holiday reading!

OCS R2 Training Materials

Earlier this year, Microsoft released an OCS R2 learning Portal – you can find this at:  http://www.microsoft.com/learning/ocs2007/r2/default.mspx. It contains some training resources for OCS R2. However, the page is both out of date, and is short on links. I have some more details to add to this page:

  • As noted, the OCS R2 Resource Kit is available. This is a must have book!  The book is excellent, but it appears rushed and needed a better technical editing. Hopefully that will happen in the next release of the book!
  • The Portal discusses the OCS 2007 R2 exam. The exam number is the same exam number as for the RTM exam, although the contents have been updated to reflect the new features in R2. If you have already passed the earlier RTM exam there’s no need to re-sit it. There is also a voice exam,but it’s not listed in the OCS Learning Portal (yet).
  • The portal describes the training available for OCS (on a linked page). This page  lists 5177/8/9 (and clinic 6447A) which was RTM courseware (and fairly poor) and should probably be avoided. An updated version of the official courseware, released as CWL course 50214, was released, but the quality was so poor it has been withdrawn until remediation can be completed and properly tested. When this updated course is available, I’ll post here! I am anxious to see the updated courseware. The updated labs look good.
  • The portal also lists the OCS Ignite course (50024A), but this material is both RTM only and not being run very often (although I can certainly offer it if clients really want it). A much better course is the OCS 2007 R2 Ignite content – course 50232A. This focuses on the R2 release, although it can be used to teach new to product folks. I teach this a lot and love it – but beware trying to do it in 3 days. With the right instructor, this course can easily fill 4 days and 5 (if the delegates are new to OCS). The labs are great too.
  • Finally, the page does not mention the updated Voice Ignite workshop. Voice Ignite for OCS 2007 R2 has bee been created and is available.
  • Note that all the courseware discussed here is Courseware Library content, content authored by a 3rd party with MS just acting as a reseller. Quality of CWL material has been variable, but MSL and the UC team are ensuring that all the courseware is good and fit for purpose. So you can book this training with confidence that the material is good.

OCS 2007 R2 is now in the field and customers should start to evaluate it for your organisation. If you have not yet deployed OCS at all, R2 is a natural next step. A new version of OCS, OCS “wave 14’ will be going into beta some time in the new year and is scheduled for release later in 2010 – dates are not yet firm on either the beta or RTM. Once I get more information, I’ll post it here.

OCS is a rich and complex application – if you are planning on deploying it, you could usefully do with some training. But before booking on the course, make sure you get a good trainer – someone who has been working with the product for a while and can explain the product and it’s values and can dive deep into deployment, configuration and support. Investing in some training would be a good thing!

Technorati Tags:

Tuesday, December 22, 2009

Office Communications Server 2007 Virtualisation Support

Earlier this year, Microsoft confirmed that it would now support OCS 2007 in a virtualised environment. This has been a big ask by clients pretty much ever since OCS was launched. Just about every time I’ve taught OCS in the past couple of years, as well as in the OCS newsgroups, the question of why it’s not supported comes up over and over again. Along with anecdotal evidence that it worked in at least a VMware ESX environment. And in the classroom, we see OCS working (well as least the server components) just fine.
The support Microsoft is providing caters for OCS server roles running in VMs hosted on both a single server (a typical classroom scenario) or hosted on a number of servers (a scenario more likely in corporate deployment). Support is limited to a subset of OCS Server roles, i.e. Front-End Servers, Back-End SQL Server 2008 (64-bit), Group Chat Channel Servers, Group Chat Channel and Compliance Servers, and Access Edge Servers. This means no support of other server roles - Microsoft say these roles are not supported due to “possible quality issues” with real time media.
It took MS a while after R2 was released to support this - I understand that part of the delay in announcing full support was testing. MS always wants (needs!) to test anything it offers to support, and OCS is no different. In announcing VM support, MS has tested a fully distributed topology with 40,000 users and 10,000 group chat users. This means, says Microsoft that: “audio/video/web conferencing servers, audio/video/web edge conferencing servers, dial-in conferencing, Communicator Web Access, enterprise voice, or Remote Call Control may not be deployed as part of the virtualized pool.” The impact of this means that you can not (at least in a supported fashion) virtualise a Standard Edition pool (or for that matter an EE consolidated pool), a consolidated edge server or a CWA server.
Microsoft also published an interesting whitepaper detailing the tested architecture. The white paper also looks at OCS performance and how you can use the Capacity Planning Tool.
This is a great move forward but it comes with some strings. Namely, the roles that are supported only work in an administratively complex environment. Or to put it another way, all the easy installations of OCS (SE, consolidated EE pool, consolidated edge) can not be virtualised in a supported way. And since, with R2, Microsoft has de-emphasised the distributed architecture, to deploy OCS in a virtualised environment, you would need to use the command line tools which makes the deployment potentially more work. I am hoping we’ll see a better story with the next wave of product.

Monday, December 21, 2009

Office Communications Server 2007 R2 Ignite

I’ve been running a lot of OCS training over the years – and Office Communications Server 2007 R2 Ignite is one cool course! I’ve taught this several times around EMEA and find it to be well received.I will be teaching it again this week coming. The technical level as advertised is also pretty correct – although one can go deeper as needed!

The content is OCS 2007 R2 focused, with fairly limited marketing fluff! The labs are rich and complex – and the troubleshooting opportunities abound. In my view, this is a 4  day class – especially given the richness of the labs. AND – if you are new to product, it can be a great 5 day class with the right instructor.

 

Technorati Tags: