Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alias for PsIsContainer?

Tags:

powershell

Instead of typing PsIsContainer, I would like to be able to use either "dir" or "folder" strings. Is there a way in PowerShell that allows me to substitute one string for another, as in this case?

like image 297
Sabuncu Avatar asked Oct 28 '25 04:10

Sabuncu


1 Answers

I think you could get close to what you're afer by predefining a couple of scriptblocks e.g.:

$IsDir = {$_.PsIsContainer}
$IsFile = {!$_.PsIsContainer}
dir | Where $IsDir
dir | Where $IsFile

Good news in PowerShell V3. This is supported natively e.g.:

dir -directory
dir -ad
dir -file
dir -af
like image 125
Keith Hill Avatar answered Oct 30 '25 05:10

Keith Hill