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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With