This blog has moved to http://ThePowerShellGuy.com
Greetings /\/\o\/\/
Dir Replacement for MSH, with Attribute support, like dir in CMD does.
so now you can do things like this :
dir -ar
dir -ard
dir -ah -force
etc.
and if you take a good look.
and even one more as the CMD one does ;-)
you should remove the alias DIR first, like this :
del alias:dir
(you still will have LS or GCI, I would not replace GCI but you could also pick LS to replace)
for more info en tips about getting a directorylist from Monad see this thread :
get-childitem and file attributes...that made me write this script, maybe I will add some more parameters later,
or autoadd -Force if H or S is found, and combine it with the colored Dir replacement elswhere on my blog)
gr /\/\o\/\/
Tags : Monad msh# Dir Function replacement with attributefilter
# /\/\o\/\/ 2006
# http://mow001.blogspot.com
function dir {
if($args.length -ne 0) {
$Script:NewArgs = @()
$Script:filters = @()
foreach ($arg in $args) {
Switch ($arg) {
{$_ -match '-a'} {
if ($_ -match 'r'){$Script:filters += ' | where { $_.attributes -match "ReadOnly"}'}
if ($_ -match 'd'){$Script:filters += ' | where { $_.attributes -match "Directory"}'}
if ($_ -match 'h'){$Script:filters += ' | where { $_.attributes -match "Hidden"}'}
if ($_ -match 's'){$Script:filters += ' | where { $_.attributes -match "System"}'}
if ($_.remove(0,2) -match 'a'){$Script:filters += ' | where { $_.attributes -match "Archive"}'}
if ($_ -match 'n'){$Script:filters += ' | where { $_.attributes -match "NotContentIndexed"}'}
}
{$_ -eq '-d'} {$Script:filters += ' | where { $_.mshiscontainer}'}
default {$Script:NewArgs += $_}
}
}
invoke-command("gci $Script:NewArgs $Script:filters")
} else {
gci
}
}