DCSIMG
December 2008 - Posts - Shay Levy

Shay Levy

If you repeat it, PowerShell it!

December 2008 - Posts

Windows PowerShell Integrated Scripting Environment (ISE)

 

ise

The Windows PowerShell Integrated Scripting Environment (ISE) is a host application that enables you to run commands, write, test and debug scripts in a friendly, syntax-colored, Unicode-compliant environment.

 

 

 

 

What does it have to offer?

1. A command pane for running interactive commands, just as you would in the Windows PowerShell console. Just type a command and press Enter. The output appears in a separate output pane.

2. A script pane to compose, edit, debug, and run functions, and scripts.

3. Multiple tabs, each with its own command and script pane to allow you to work on one or several tasks independently.

4. The ability to edit text in complex scripts and right-to-left languages.

5. You can extend every aspect of ISE through its underlying scripting object model with your own code.

6. Separate profile.

Note: ISE is a WPF application and it requires .NET 3.5.


Check the Windows PowerShell Team recent posts for more information:

My PowerShell_ISE Profile
My Powershell_ISE Profile Part 2
PowerShell ISE Can Do a Lot More Than You Think

 

One thing to keep in mind, ISE is not perfect and is in constant developing by the PowerShell Team. Don't hesitate to tell what you think if you encounter any problem/bug when you use it or have any suggestion/feature you would like to have, just submit your feedback on Microsoft Connect. Remember, this is a CTP version and the team is hoping to hear from you and improve the product based on your feedback.

 

Here is a simple utility function I have in my profile to load ISE:

function Invoke-ISE{     
    param (     
        [string[]]$file,    
        [string]$path="$pshome\powershell_ise.exe"   
    )     
   
     if($file){    
        foreach($f in $file){    
            & $path (resolve-path $f)    
        }    
     } else {    
        & $path        
     }    
}     
   
Set-Alias ISE Invoke-ISE  

 

# this will launch a fresh blank instance of ISE (using the function alias)
PS > ise


# load ISE with a bunch of scripts ready to be edited
PS > ise (dir *.ps1)

 

iseeditor

Regular Expression Webcast Series


source: http://blogs.msdn.com/zainnab

This is a great resource for learning what regular expressions are and how you can use them in .NET applications, including PowerShell (featured briefly), I watched the first 4 chapters and I love every part of it.

 

Presenter: Zain Naboulsi, MSDN Developer Evangelist, Microsoft Corporation

In this webcast series, we explore an unsung hero: the regular expression. It slices, it dices, and it can turn twenty lines of code into one line if you know how to use it. Join us as we explore pattern matching and substitution using regular expressions. Also, see how you can use regular expressions in the Microsoft .NET Framework applications with some examples in Microsoft SQL Server 2005 and JScript.

Regular Expressions 1 of 10

In part one, we explain what regular expressions are, describe how they can be useful to you, and address common misconceptions about how they should be used. Finally, we provide some simple examples of using regular expressions.

Regular Expressions 2 of 10

In part one of this webcast series, we introduced what regular expressions are, described how they can be useful to you, and addressed some common misconceptions about how they should be used. Join the second half of our series as we dive deeper into using regular expressions. In this session, we explore the different levels of regular expressions and illustrate how to use metacharacters to improve your expressions. We also examine when and where you can, or should, employ metacharacters.

Regular Expressions 3 of 10

In Part III we will explore real-world examples of using regular expressions in different products. We begin with .NET web and windows applications and move on to SQL Server 2005 and Jscript. Additionally we will create a class scenario and work on the solution together as a group.

Regular Expressions 4 of 10

In Part IV we will turn our attention to the other side of Regular Expressions: substitution. While many people know that Regular Expressions can be used for pattern matching, few realize that it is also an extremely powerful substitution tool.

Regular Expressions 5 of 10

In Part V we will focus on grouping and backreferencing. Now that you have created expressions we will learn how to turn a simple match into an even more powerful capture. Not only will we find the data, we will capture it and use it in meaningful ways. We will also learn how to do sequential matches for the same pattern for finding duplicates.

Regular Expressions 6 of 10

In Part VI we will take time to go back over what we have learned so far. This is the perfect time to reinforce what we have learned already with examples and group suggestions. We will use this time to go back over basic expressions, metacharacters, grouping, substitution, etc...

Regular Expressions 7 of 10

In Episode VII Luke re-opens the Jedi Academy. Just kidding. We will take a look at regular expressions used specifically in .NET development. A comparison of C# and Visual Basic usage will take place. Also we will examine some of the regular expression options that are available and what impact they have.

Regular Expressions 8 of 10

Part VIII begins the deep dive section of our series. In this lesson we will step back from the coding and examine the advanced concepts of regular expression engine types and the ways processing occurs.

Regular Expressions 9 of 10

Here we look at several real-world examples of using regular expressions in your .NET Framework applications. The focus is on Windows - Web applications, and usage in the real world.  Also, we will discover that security definitely can be a great reason to use regular expressions.

Regular Expressions 10 of 10

We are going to take ideas / comments / suggestions that you have submitted from prior sessions and use them to discuss all types of topics from "where to go from here" to "what are you doing with regular expressions in your world" and beyond! 

Free eBook: Understanding Microsoft Virtualization

 

vsThis is the book for IT professionals who want to learn more about the lat-
est Microsoft virtualization technologies, including Windows Server 2008 Hyper-V, System Center Virtual Machine Manager 2008, Microsoft Application Virtualization 4.5, Microsoft Enterprise Desktop Virtualization, and Microsoft Virtual Desktop Infrastructure.

The book also examines other virtualization-enabling technologies from Microsoft including Windows Server 2008 Terminal Services, Roaming User Profiles, Folder Redirection, and Offline Files.
 

Download (14.4MB PDF)

PowerShell V2 (CTP3) is public

 

ps

PowerShell V2 Community Technology Preview 3 is public with lots of goodies. Read the announcement at the Windows PowerShell Team blog, now go get it :-)

Where did that PowerShell come from?

 

Today, while working on my laptop (Vista), I accidentally pressed a key combination (Windows logo key+1) that caused PowerShell to fire!

What gives? I don't recall configuring keyboard shortcuts for any of my applications. I checked all of PowerShell's shortcuts and found that none is configured to use keyboard shortcuts. I checked for that keystroke on my desktop computer (XP) and it didn't work.

OK, there must be an application to list all registered keyboard shortcuts, so I googled for one. At first glance, I didn't find any. Then I made a second search for a complete list of Windows shortcut keys (I should have done it first). I came across number of articles and couldn't find a clue in any one of them.

Finally I found the answer on Windows Help under the section: Microsoft keyboard shortcuts. It appears to be a Vista thing:

"Windows logo key with any number key - Open the Quick Launch shortcut that is in the position that corresponds to the number. For example, Windows logo key +1 to launch the first shortcut in the Quick Launch menu."

That makes sense... the Quick Launch toolbar shows that PowerShell IS the first shortcut...damn slick!

ql

 

 

 

How to trick SCVMM prerequisites checking


The other day I was trying to install SCVMM Administrator Console on my machine. One of the software requirements for VMM is Windows PowerShell v1. I got this error in the prerequisites dialog:

vmm

Doe's this mean we can't have SCVMM installed side by side with newer versions of PowerShell? Apparently not.

I had the same issue before when I tried to install Exchange 2007 admin tools while having PowerShell CTP 2 installed. Checking under the hood, using regmon, revealed that the installation is looking for a registry key named PID. I checked that key on a PowerShell v1 machine and found that its value was "89383-100-0001260-04309". I created it manually, ran the Exchange installation again and the problem has disappeared.

So I decided to check if this is the case with SCVMM, and it was. SCVMM is looking for the same key/value. I launched PowerShell , executed the following and clicked the "Check Again" button:

PS  > Set-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\PowerShell\1" -name PID -value "89383-100-0001260-04309"

That did the trick:

vmm1

 

Now that the prerequisite phase is complete you can safely remove the key:

PS > Remove-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\PowerShell\1" -name PID

 
This solution should work with upcoming CTPs as well.

Expert to Expert: Erik Meijer and Jeffrey Snover - Inside PowerShell

source

Welcome to another edition of Expert to Expert. Once again the venerable language master Erik Meijer leads the conversation. This time, we're lucky enough to have PowerShell creator and Partner Architect Jeffrey Snover. Jeffrey is really passionate about PowerShell and has worked hard to see that his .NET shell scripting technology ships in Windows 7 (it is on by default in Windows 7 and is used by administration components of the new OS).

Erik is a big fan of PowerShell (especially since the code name of PowerShell was "Monad"Smiley) so we figured it would be useful to have Erik dig into the nitty gritty of PowerShell with Jeffrey and determine exactly what PowerShell is, how it's designed (and why), how it's used primarily (and secondarily) and finally how it will evolve. PowerShell is much more than a Windows-based shell scripting language and engine. But what, exactly, does this statement mean? Tune in. This is yet another great conversation between two stalwarts of the programming industry. Enjoy!

Click the image to view the video.