ps1.soapyfrog.com

doing inappropriate things with powershell

Pages

  • About
  • Downloads
  • Archives

Search

Popular Posts

  • Grrr 1.1 and Big Invaders
  • Space Invaders
  • Convert images to text (ASCII art)
  • Cmdlet clashes
  • Console screen grabs in html

Recent Posts

  • Grrr source code, including Invaders
  • Google going down the pan
  • Cmdlet clashes
  • Grrr 1.1 and Big Invaders
  • Grrr, Cmdlets and PSInvaders revival

Categories

  • Announce (7)
  • Cmdlets (2)
  • Cool (16)
  • Grrr (6)
  • Hint (2)
  • Invaders (5)
  • Odd (2)
  • PowerShell (27)
  • Quiz (3)
  • Rant (7)
  • Uncategorized (1)
  • Utility (5)

Months

  • August 2007 (1)
  • April 2007 (1)
  • March 2007 (1)
  • February 2007 (3)
  • January 2007 (25)
  • December 2006 (1)

Bookmarks

  • Blogroll
    • $script Fanatics
    • blog.soapyfrog.com
    • Brian Long
    • Lee Holmes
    • Nik Crabtree
    • PowerShell-Scripting (French)
    • Richy Rich
    • The PowerShell Guy
    • Windows PowerShell
  • Links
    • Carbon-neutral web hosting!

Meta

  • Log in
  • Posts RSS
  • Comments RSS
  • Valid XHTML
  • Valid CSS
« Pipe or no pipe?
Banners »
 

Alternate Data Streams

18 Jan 2007 11:23 am// PowerShell, Rant    

NTFS has the ability to associate multiple data streams (aka forks) to a file. It’s not very well supported in most Microsoft tools and not very well known, but I use them quite a bit for associating metadata with files.

Unfortunately, PowerShell (or rather .NET) doesn’t support them very well.

If I open up a “Command Prompt” window (CMD.EXE), I can do things like this:

CMD>echo Hello world > file.txt

CMD>echo Hello other world > file.txt:other

CMD>more < file.txt
Hello world

CMD>more < file.txt:other
Hello other world

As you can see, file.txt has two streams, the default one and one named other.

Back in PowerShell:

PS>gc file.txt
Hello world
PS>gc file.txt:other
Get-Content : Cannot find drive. A drive with name 'file.txt' does not exist.
At line:1 char:3
+ gc  < < file.txt:other

PowerShell doesn’t like it. It incorrectly parses the part before the colon as a drive. Even if PowerShell did parse it properly, the underlying .NET bit would fail with System.NotSupportedException: The given path's format is not supported..

Perhaps Microsoft don’t want people using ADS any more… or perhaps they’re just not sure… if you Move-Item or Copy-Item the file, the extra stream is moved/copied intact.

2 comments to “Alternate Data Streams”

  1. On 27 Jan 2007 at 11:06 pm, The PowerShell Guy said:   

    PowerShell : Accessing alternative data-streams of files on an NTFS volume ……

    As Adrian Milliner, mentioned on his blog here : Alternate Data Streams , Alternate Data Streams are…

  2. On 27 Jan 2007 at 11:14 pm, MoW said:   

    Hi Adrian,

    I use a .NET library for this, and made a blogpost about it :

    http://thepowershellguy.com/blogs/posh/archive/2007/01/27/powershell-accessing-alternative-data-streams-of-files-on-an-ntfs-volume.aspx

    Greetings /\/\o\/\/

Copyright © 2006-2008 Adrian Milliner

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.