String Theory

Mastering the laws of physics with Windows PowerShell

As you may know last week AppSense released the 8.3 version of there AppSense Environment Manager product. It has several impressive features added, like user self-service. The feature that I found the most thrilling is the inclusion of the AppSense Personalization API. Now I am not sure if this is a new API or just the documentation of the existing functionality. Nevertheless it is a huge step in automation of AppSense Personalization.  I have on multiple occasions stated that if AppSense were to at least document their API then I would be more than happy to create a PowerShell module. Its time to keep up on my end of the promise so I will be working on creating a PowerShell module for the AppSense API.

You don’t need a special module to interact with the AppSense Personalization API as it is a Windows Communication Foundation (WCF)service. However a module will encapsulate the functions and make it easier to operate against.  In the documentation for the AppSense Personalization API they even have a Windows PowerShell example for calling the API. A small snippet is included below.

  1. # Load service model
  2. [Reflection.Assembly]::LoadWithPartialName("System.ServiceModel") > $null
  3. # Load proxy dll
  4. [Reflection.Assembly]::LoadFrom("$home\ProfileManagement.dll") > $null
  5. # Create binding
  6. $wsHttpBinding = new-object System.ServiceModel.WSHttpBinding
  7. $wshttpBinding.MaxReceivedMessageSize = 67108864
  8. # Create endpoint
  9. $endpoint = new-object System.ServiceModel.EndpointAddress(“http://localhost/PersonalizationServer/ProfileManagementService.svc”)
  10. 
  11. # And return client
  12. new-object ProfileManagementClient($wsHttpBinding,$endpoint)

In the snippet, Lines 2 and 4 load the WCF framework and the proxy dll for the Personalization service respectively.  These lines use the static methods from the System.Reflection.Assembly .Net class.

If you are using PowerShell version 2, and you should be using version 2 by now, there is a better way. Use the Add-Type cmdlet.  In the snippet below the respective lines have been replaced with the Add-Type cmdlet. This is a much cleaner implementation.

  1. # Load service model
  2. Add-Type -Assembly "System.ServiceModel"
  3. # Load proxy dll
  4. Add-Type -Path "$home\ProfileManagement.dll"
  5. # Create binding
  6. $wsHttpBinding = new-object System.ServiceModel.WSHttpBinding
  7. $wshttpBinding.MaxReceivedMessageSize = 67108864
  8. # Create endpoint
  9. $endpoint = new-object System.ServiceModel.EndpointAddress(“http://localhost/PersonalizationServer/ProfileManagementService.svc”)
  10. 
  11. # And return client
  12. new-object ProfileManagementClient($wsHttpBinding,$endpoint)

 Related articles

I have been working hard with the leaders of some of the other Atlanta user groups as well as some very helpful Microsoft employees to organize this years Atlanta TechStravaganza. I am happy to announce this year’s event on Friday June 1st, 2012. Last year’s event was such a great hit that we decided to keep the same format. There will be three tracks with four sessions in each track. And of course there is a track dedicated to Windows PowerShell.

Back again this year with two sessions is the fan favorite Ed Wilson, Mr. Scripting Guy himself. This year we introduce Glen Gordon, Developer Evangelist for Microsoft to talk about what’s new in Windows 8 and Server 2012. And finally we have Hal Rottenberg and Jonathan Walz with PowerScripting Live, a live PowerShell roundtable that will be featured on an upcoming PowerScripting Podcast.

Don’t delay. Attendance is limited so make sure to reserve your seat now and I look forward to seeing you on June 1st. For more information visit http://techstravaganza2012.eventbrite.com/.

TechStravaganza 2012

Room

Centennial Park

Grant Park

Piedmont Park

Track

Track 1 System Center

Track 2 Windows Server

Track 3 PowerShell

8:00 – 8:50

Registration, Breakfast, Announcements , (sponsor) Presentation

9:00-9:45

Keynote – Jeremy Moskowitz:

Managing Desktops from the Cloud: Inside Microsoft’s Windows Intune Service

10:00-10:45

Get “AMP”ed with SCOM
Greg Cameron

VDI Implementation, Scalability and Performance metrics
Jeff Stokes

Use PowerShell to manage the remote Windows 7 workstation Ed Wilson

11:00-11:45

System Center 2012 Licensing
Melissa Seeker

Group Policy: Where it rocks (and where it needs a boost).

Jeremy Moskowitz

What’s New in Windows 8

Glen Gordon

12:00-1:00

Lunch, Prize Giveaway, 1E Presentation

1:15-2:00

Configuration Manager Servicing and Tools
Brian Huneycutt

Active Directory Forest Disasters: How they occur and how to recover

Gary Olsen

PowerShell Best Practices

Ed Wilson

2:15-3:00

Common Migration blockers for Configuration Manager 2012
Rodney Jackson

Overview of VMware vSphere Editions and vSphere Active Directory Integration

Cindy Manderson

PowerScripting Live!

Jon Walz
Hal Rottenberg

3:00-4:20

Closing Comments and Grand Prize Giveaway

The 3rd annual TechStravaganza 2012  will be held Friday June 1, 8am – 3pm at the Microsoft office in Alpharetta.  The past 3 TechStravaganzas have been huge successes, requiring us to limit attendance within about 2 weeks of opening registration.

More details will come in the announcement to be sent Friday April 27, but we can tell you:

·          Well known keynote speaker

·         12 technical sessions in 3 tracks: Cloud/Deployment, Windows Infrastructure, PowerShell

·         Breakfast/Lunch served

·         Prize give away

·         Best of all, it’s FREE!

 

Mark it on your calendar and watch for the announcement on Friday

Enhanced by Zemanta

Its that time again. We are busy planning for this years Atlanta TechStravaganza. It is happening June 1st at the Microsoft offices in Alpharetta. It is my responsibility to schedule the speakers and topics for the PowerShell track.

If you are interested in speaking send me an email at Mark.Schill [at] cmschill.net with a bio and brief synopsis of your topic.

If you aren’t interested in speaking but would like to see a particular topic covered email it to me as well and we will see if we can get it covered.

 

A few days ago I posted the question online of how I could change the Windows 7 theme using any automated method such as .Net or even C++ which I could call from Windows PowerShell. Although I was unable to locate a solution to the problem, PowerShell version 3 did offer a compromise.

 

Figure 1: Get-ControlPanelItem (Click image for full-size.)

 

In version 3 (CTP2) two new cmdlets were added that allow interaction with the Windows Control Panel. The first cmdlet, Get-ControlPanelItem allows you to list all of the control panel applets in your system. It accepts three different parameters that allow you to retrieve the items that you want: Name, CanonicalName, and Category. The categories are the same as when you view the Control Panel in category view.

Demonstrating Get-ControlPanelItem

Figure 2: Show-ControlPanelItem (Click image for full-size.)

The second cmdlet added was Show-ControlPanelItem. As you can guess from the name it shows the specified Control Panel applet. As shown in Figure 2, you can specify either the Name or CanonicalName directly or you can pass the output from Get-ControlPanelItem. When executed the control panel applet is shown.

In my case I could not find a way to automatically set the Windows 7 theme, but I was able to use Show-ControlPanelItem Personalization to present the user with the dialog box to allow them to change the theme manually. It wasn’t the solution I was looking for but it still made the task easier to accomplish.

 

 

 

 

 

Enhanced by Zemanta

One of the nice things that has changed with PowerShell Version 3 as of CTP 2 is the way that the registry is displayed. In PowerShell Version 3, the PowerShell team updated the format files for the registry provider. To see this difference first do a directory listing for HKCU: in version 2. You will get a similar output to Figure 1.

Listing of HKCU: in PowerShell Version 2

Figure 1: Listing of HKCU: in PowerShell Version 2 (Click image for full-size)

As you can see the listing is compact and actually somewhat hard to read, especially if you are interested in the properties. Now, perform the same action in version 3. You will be presented with the output similar to Figure 2.

Listing of HKCU: in PowerShell Version 3

Figure 2: Listing of HKCU: in PowerShell Version 3 (Click image for full-size)

As you can see the display is longer and isn’t completely captured in the screenshot. You will notice though, that it is much easier to read and you can view the values for each property very cleanly. This makes using PowerShell to navigate the registry so much easier and is a definite plus to the language.

Disclaimer: This post covered PowerShell Version 3 CTP 2. Since this is a pre-release version, there is a possibility that the features described herein will be changed or completely removed from the final product.

Imagine the scenario: You are working on a script or command in your PowerShell session and you need to get help on a cmdlet. Sure, you have tab completion, but you can’t remember whether the parameter takes a string or an object, or you can’t remember how the value should be formatted. So you break out the ever helpful (haha) get-help cmdlet.

Get-help provides you the information, but now you have to get back to your command. You start typing the command and realize you need more information. You either have to scroll up or rerun get-help. Wouldn’t it be nice if you could just have the help in a separate window that you can reference for as long as you need it?

Well it should be no surprise that you can display help in a separate window. Otherwise I wouldn’t have anything to write about, right? In version 3, Get-Help has a new parameter, -ShowWindow. As you can imagine -ShowWindow presents the help contents in a new, separate window as shown in Figure 1.

Get-Help -ShowWindow

Figure 1: Get-Help -ShowWindow (Click image for full-size)

Now you can continue editing your command AND have the help right there where you need it. Furthermore, you can search the help and customize the output to include/exclude the section you want by clicking on the Settings button as shown in Figure 2.

ShowWindowOptions

Figure 2: Get-Help -ShowWindow Options. (Click image for full-size)

Disclaimer: This post covered PowerShell Version 3 CTP 2. Since this a pre-release version, there is a possibility that the the features described herein will be changed or completely removed from the final product.

Not too long ago I was filling out an “achievement” form for an award that I want to obtain. This award was based on your community presence and how well you engaged the community to spread the value of the award’s intended purpose. One of the questions asked was your twitter username and how many followers you had.

Every day I receive at least one user following me that is either a local business, some “hot chick” looking for a lonely guy, or someone selling some device at ridiculously low prices. Each and every time I reach for the spam link to report them, I think about that form. Do I  block them because they probably have no interest in what I have to say, or do I let them follow so they can pad my follower count? We are talking about the possibility of hundreds of additional followers.

Most of the time I just report them for spam but I always have to think about it first. To me this is just the social version of “What certifications do you have?” Most certification exams are no more than just a test of how well you can memorize something, not how well you know a subject. Saying you have a lot of followers just means you know a lot of people. Maybe the better question is: Who are your followers? Quality over quantity.

The AppSense Environment Manager can provide you with valuable information related to the processes involved in login and logoff . Using Windows PowerShell you can easily retrieve this information to assist you in identifying problem spots.

continue reading…

Just a Little Update

4 comments

Starting with an innocent conversation a little over 15 months ago, I agreed to co-author a book on Windows PowerShell. I had no idea what I was getting into nor the amount of work it was going to entail. It was a very long and detailed process, but I can finally say it was all absolutely worth it.

The book is in its final stages and we are looking at a September or October release date. As you can see from the image to the left we have our book cover. This is the part I was most looking forward to.

I am especially proud to have been able to use my experience and knowledge to dedicate individual chapters to Citrix XenApp 6 and  to Citrix XenDesktop 5. My goal from the beginning of this project was to include these topics because I felt they hadn’t been addressed in any other resource appropriately. These chapters are only a beginning and I look forward to expanding on the information contained.

If you haven’t yet seen the new PowerShellGroup.org site I would recommend that you take a look.  Joel Bennett and I have been working very hard to migrate the system from the old site to the new one. It wasn’t an easy process, but I can honestly say that I am proud of the new site. With the new host I haven’t seen a single “Page Not Found”.

The new User Group map is the feature that I am most proud of. When I was preparing my proposal for taking over the site it was the feature that I wanted the most. The were two questions that were prevalent at the Scripting Guys booth during MSTechEd here in Atlanta:

  1. Is there a PowerShell user group where I live?
  2. How can I start my own PowerShell user group.

The User Group map answers that first question. As to the second question: stay tuned. I will be starting work on a ‘New User Group’ welcome packet that provides all of the resources you need to start your very own user group.

With the book completed and more free time, I am working hard to complete everything I have postponed and become an active member of the PowerShell community once again.