PowerShell Team

Automating the world one-liner at a time…

Latest posts

Jan 11, 2009
Post comments count 0
Post likes count 0

Copy console screen to system clipboard

PowerShell Team

In the previous example we learned how to create a colorized copy of console in HTML and RTF format. However, the output of these scripts cannot be readily used for pasting into web or word processing applications. To insert it into your article in MS Word format, you need several steps: generate RTF string, save it to an RTF file, then open the file in MS Word, copy its contents and, finally, paste it into your document. Can we reduce it to two steps: run the script, which copies console screen to system clipboard, and then paste the results to MS Word? As a matter of fact we can, but to do this we need to learn...

Jan 11, 2009
Post comments count 0
Post likes count 0

Colorized capture of console screen in HTML and RTF.

PowerShell Team

In the previous post we demonstrated how we can use console host API to capture screen buffer contents as text. But what if we want some colors. Would not it be nice to publish colorized copy of console in HTML or insert it as part of Microsoft Word document. For this to work we need to add some modifications to original script. Colors of each character are available as properties of System.Management.Automation.Host.BufferCell object: All we need to do is to iterate through the screen buffer array, keeping track of the cell colors and generate HTML spans or RTF blocks with varying color attributes as soon as t...

Jan 11, 2009
Post comments count 0
Post likes count 0

Finding a URL For File Transfer Cmdlets

PowerShell Team

I just posted a blog about our new File Transfer Cmdlets in which I artfully dodged a difficult question:  How do you get the URL to do the file transfer?  Sometimes you are going to have it but other times you’ll go to a website and it can be bloody impossible to find the URL that you need to download.  That was the case with the example I used.  Let me provide it.  Navigate HERE and tell me if you can find the URLs to download the kits? (If you find out how – let me know – I’d REALLY appreciate it.) My new motto is Experiment, Enjoy, Engage (which means share).  Luckily, we have a...

Jan 11, 2009
Post comments count 0
Post likes count 0

Transferring (Large) Files Using BITs

PowerShell Team

Have you had a file copy fail?  Does that drive you crazy or what?  How about when it is a REALLY big file and it takes a couple of hours and JUUUUUST before it finishes something happens to interrupt the transfer and you have to start all over again.  Does that make you want to shove a sharpened #2 pencil up your nose or what? I got to thinking about these things when I saw that the W7 and WS08/R2 beta bits were available and that the demand was so high that the servers were having a hard time keeping up.  Can you image how you would react if you downloaded a GB and then the transfer failed?&...

Jan 10, 2009
Post comments count 0
Post likes count 0

Test-PSCmdlet

PowerShell Team

Everyone needs to get good with Advanced Functions – this is the easiest path to the best semantics for everyone.  In previous posts we’ve shown how you can add a few simple attributes and get a TON of stuff for free.  There is a LOT more to advanced functions.  You can go VERY VERY far with advanced functions.  I can’t think of anything you can do in C# Cmdlet that you can’t do with a PowerShell cmdlet.  Many of these functions are made available to you via the $PsCmdlet variable. For example, if  you write a Cmdlet which takes multiple ParameterSets, you need to know which Paramete...

Jan 10, 2009
Post comments count 0
Post likes count 0

Capture console screen

PowerShell Team

Seeing nicely formatted console examples in a previous post has inspired me to write a script that captures the console screen buffer directly from the Windows PowerShell console host. With this script you can make console "screen shots" to demonstrate some of your favorite Windows PowerShell concepts, and then post them to your blog, or put them on your Web site. How is it done? The console host has a powerful API that is somewhat neglected by most script writers. This API allows you to capture console screen rectangles or output a colorized text in arbitrary areas of the screen. The console...

Jan 10, 2009
Post comments count 0
Post likes count 0

PowerShell as Inventory Tool

PowerShell Team

Check out Don Jones’ TechNet article Windows Powershell Best Inventory Tool Ever!  He as a streaming video demo at that location as well.  Cool stuff.  I really enjoy the way Don explains things.  It is well worth a view and worth recommending to your friends that are learning PowerShell. Cheers! Jeffrey Snover [MSFT] Windows Management Partner Architect Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Jan 10, 2009
Post comments count 0
Post likes count 0

Get-USB – Using WMI Association Classes in PowerShell

PowerShell Team

Last Thursday, we had our first meeting of PowerShell Script Club on the Microsoft Campus. Script Clubs are really cool. They're kind of like a hands on lab with no set topic or teacher. You bring an idea for a script, and ask your fellow PowerShell users about help getting the script written.  Leave a comment if you’d like to set up a local script club. One of the questions I helped answer involved using a WMI association class, which is a class in WMI that links two other classes together. Association classes are pretty common, and pretty useful, once you get the hang of them. One association class is Wi...

Jan 9, 2009
Post comments count 0
Post likes count 0

Beta of Windows Server 2008 R2 is now Available

PowerShell Team

Want a couple hundred new cmdlets?  Download the beta version of Windows Server 2008 R2 and check out all the cmdlets that we've been dying to talk about but have not been able to.  Also, take a look at what is missing and complain early, often and loudly.  And of course -don't forget to blog about what you find. Download details HERE.   Cheers! Jeffrey Snover [MSFT] Windows Management Partner Architect Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/sc...