Udostępnij za pośrednictwem


Windows Powershell - Cooler than Cool!

As you probably know Windows Powershell has RTWed! You can find the download links and more information on the Windows Vista blog or the Windows Powershell blog.

The Windows Vista blog lists 12 Cool Features of Windows PowerShell. I just wanted to add a couple more. So here goes…

[upto #12 here]

13) Native support for navigating the Windows Registry & Windows Certificate store

Browse through the Windows Registry and Windows Certificate store like how you would browse through a folder structure on a Hard drive

Switch to the registry by typing cd hklm:

PS C:\> cd hklm:

Browse hives like Directories/Folders

PS HKLM:\> cd software

PS HKLM:\software> dir

Hive: Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software

SKC VC Name Property
--- -- ---- --------
1 1 C07ft5Y {(default)}
647 0 Classes {}
10 0 Clients {}
3 0 ComputerAssociates {}
1 0 Crystal Decisions {}
1 0 Gemplus {}
1 0 InstallShield {}
1 0 L&H {}
1 0 Macromedia {}
146 0 Microsoft {}
2 0 ODBC {}
1 0 Policies {}
0 1 Program Groups {ConvertedToLinks}
1 0 Schlumberger {}
0 1 Seagate Software {ConfIIS4}
0 0 Secure {}
2 0 VapiVS71 {}
2 0 Windows 3.1 Migration Status {}

Its the same with Certificate store - just use cd cert:  

14) Native support for XML

Windows Powershell has native support for XML, infact XML is a data type. Here’s an example, for simplicity sake I’m not reading the XML from a file but typing it in. Its really easy to ready XML off a file BTW.

PS C:\> $MyXml = [xml]"<Order><OrderNumber>11111</OrderNumber><CustomerName>Bill Gates</CustomerName><Product>Windows Vista Ultimate</Product><Qty>99</Qty></Order>"

So at the Windows Powershell prompt I create a variable $MyXml and pass it a string which contains my Order XML. Notice the [xml] casting that I’m doing, so what I end up with in $MyXml is an XML Object.

I can then access my XML Object simply by typing it out to see the root elements

PS C:\> $MyXml

Order

-----

Order

Or I can see the inner text of the Root elements, Windows Powershell infact formats the output for me in a nice table. It will be much better to view your XML in this way when you have say a lot more nodes within the Order root element.

PS C:\> $MyXml.Order

OrderNumber CustomerName Product Qty

----------- ------------ ------- ---

11111 Bill Gates Windows Vista Ul... 99

If I want to I can even access a particular node in my XML like this

PS C:\> $MyXml.Order.CustomerName

Bill Gates

PS C:\>

Well there is a whole lot more, you can even use XPATH, here is a great article on MSDN if you are looking out to play with XML using Windows Powershell - https://www.microsoft.com/technet/scriptcenter/topics/winpsh/payette3.mspx

The list can just go on… I’d better stop. Windows Powershell – a shell you’ll fall in love with if you are an admin or a developer – just go try it today!

Comments

  • Anonymous
    November 14, 2006
    Except the download links don't work.

  • Anonymous
    November 14, 2006
    Monad PowerShell RTM

  • Anonymous
    November 14, 2006
    Monad PowerShell RTM

  • Anonymous
    November 14, 2006
    None of those links work!

  • Anonymous
    November 14, 2006
    Monad PowerShell RTM

  • Anonymous
    November 14, 2006
    Monad PowerShell RTM

  • Anonymous
    November 24, 2006
    oh maybe there was some down time when you tried - sorry about that. Can you try again if you haven't yet - The links seem to work just fine.