Question

I was thinking to use ADS to tag my ps1 files in order to find them more easily. someting like

#add tags
PS>Add-Content -Path style.ps1 -Stream tags -Value "colour;help;test" 

#search file containing help tag
PS>gc *.ps1 -Stream tags -ea silentlycontinue | ? { $_ -match "help"} |select pspath         

PSPath                                                                                       
------                                                                                       
C:\temp\style.ps1                                                                            

after googling a bit this does not seem to be a common practice, do you think that is not a so good idea and why ? Thanks

Was it helpful?

Solution

I think the big question is what editor you use and whether it preserves alternate streams? For example:

PS C:\scripts> Add-Content -Path style.ps1 -Stream tags -Value "colour;help;test" 

PS C:\scripts> get-content -path style.ps1 -Stream tags
colour;help;test

PS C:\scripts> ise style.ps1

PS C:\scripts> get-content -path style.ps1 -Stream tags
get-content : Could not open alternate data stream 'tags' of file 'C:\scripts\style.ps1'.
At line:1 char:1
+ get-content -path style.ps1 -Stream tags
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\scripts\style.ps1:String) [Get-Content], FileNotFoundException
    + FullyQualifiedErrorId : GetContentReaderFileNotFoundError,Microsoft.PowerShell.Commands.GetContentCommand

Powershell ISE doesn't preserve the tags stream, so you would have to reapply the tags every time you edit something. I think most other editors would have the same problem.

Also, you should be using some form of source control on any scripts you write, so again the source control system will probably strip tags.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top