Translate

Translate to EnglishÜbersetzen Sie zum Deutsch/GermanΜεταφράστε στα ελληνικά/GreekПереведите к русскому/RussianOversetter til Norsk/NorwegianÖversätta till Svensk/Swedishहिन्दी अनुवाद करने के लिए/Hindi
Tradueix al català/CatalanTulkot uz latviešu/LatvianPreložiť do slovenčiny/SlovakVertaal aan het Nederlands/Dutchترجمة الى العربية/ArabicTraduzca al Español/SpanishTraduisez au Français/French
Traduca ad Italiano/ItalianTraduza ao Português/Portuguese日本語に翻訳しなさい /Japanese한국어에게 번역하십시오/Korean中文翻译/Chinese Simplified中文翻译/Chinese TraditionalПереклад на українську/Ukrainian
Image of Modern Operating Systems (3rd Edition)
Image of Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series)
Image of Android Wireless Application Development
Image of XSLT 2.0 and XPath 2.0 Programmer's Reference (Programmer to Programmer)

More on PowerShell

Microsoft’s PowerShell is radically different than shells on UNIX or GNU Linux systems in that Powershell can deal in objects rather than just plain text.

A concrete example may help you more quickly understand the difference.  Suppose you want to get and save information about all the files in a certain subdirectory.   We want to get not only the names of the files but as much metadata as possible relating to each file such as date of creation, date of modification, etc.  This information also needs to be stored in a single XML document.  To keep the size of this post manageable, our subdirectory contains only two files, i.e. file.xml and file.xsl, as shown below.

On a UNIX or GNU Linux system, this would be a somewhat difficult task to quickly accomplish.  Using Powershell, however, it becomes a simple one or two line task.

Because Powershell is fundamentally object-orientated, it regards a filesystem as being an object representated as a location exposed by provider.  More generally, a location can be a file directory, a registry hive, a certificate store or some other “thing” exposed by a provider.  The Powershell get-childItem cmdLet is used to retrieve information, including metadata, about items in a specified location.  Thus get-childItem can be used for a lot of different types of operations including enumerating directory contents, listing registry values or showing the current values of variables.  For our purposes, get-childItem exposes information about files in a specified subdirectory or the current directory if no directory is specified.

Here is a single line Powershell script which does what we want to do.   It retrieves metadata about the two files in the current directory using the get-childItem cmdLet, pipes that data to a cmdLet called ConvertTo-XML which in turn converts the metadata into a valid XML document.  The save method is then used to write this stream out to a file called file.out in the current directory. (get-childItem | ConvertTo-XML -NoTypeInformation).save(“$(convert-path “X:”)\file.out”)

Alternatively, we could store the retrieved metadata in a variable and then write it out to a file as shown below.  Similar to bash and ksh93, Powershell supports the concept of aliases and defines ls as one of the aliases for the get-childItem cmdLet,dir and gci being the other two. $a=(ls | ConvertTo-XML) $a.save(“$(convert-path “X:”)\file.out”)

Here is the contents of file.out.  As you can see, quite a bit of information about each of the two files is exposed. <?xml version="1.0"?> <Objects> <Object Type="System.IO.FileInfo">

Vista Snipping Tool Rant

My version of Microsoft Windows Vista comes with a screen capture tool called the Snipping Tool.  It is a very useful tool which I often use.  With this tool you can capture a screen shot (snip) of any part of your screen and save it to the clipboard or to a file in a number of formats (HTML, PNG, GIF, or JPEG).  Available snip types include free-form, rectangular, window or full-screen.

One day last week the Snipping Tool suddenly stopped allowing me to save a snip to a file.  No error messages or message of any kind.  Pressing the Save option simply did not nothing.  The warning message about saving a unsaved snip still appeared when exiting the Snipping Tool but did not allow me to save the snip.

After some research I stumbled across the answer.  It turns out that I had deleted the Pictures folder in my user folder as part of a cleanup of my folders.  I never use that folder so I naively assumed that I could delete it.&nbsp However if you delete that folder, the Snipping Tool does not display a Save File dialog box.  Note that the Snipping Tool does not force you to save a snip in your Pictures folder but does require you to have the folder!  You can save the snip anywhere you like provided you have the right permissions.

What a poor user interface design! As part of Vista QA did nobody test this scenario?  If it was a deliberate design decision to require the Pictures folder, why not display a dialog box warning the user that the folder is missing and is required?