Find-Item that used to be DIR /S
Under CMD.EXE, I used DIR /S a lot.
Under PowerShell, this would translate as gci -r –fi .
So I added the following to my profile:
Function Find-ItemWithFilter {
param ([string] $filter = $(throw "You must specify a filter (e.g. *.doc)"))
Get-ChildItem -recurse -filter "$filter"
}
set-alias fi Find-ItemWithFilter
For the record, my current profile is:
Function global:prompt {
$nextId = (get-history -count 1).Id + 1;
$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object 'System.Security.Principal.WindowsPrincipal' $windowsIdentity
$windowTitle = "PowerShell - `"$(get-location)`""
[bool] $isAdministrator = $windowsPrincipal.IsInRole("Administrators") -eq 1
if ($windowTitle -ne $host.ui.rawui.windowtitle) {
if ($isAdministrator) {
$host.UI.RawUI.WindowTitle = "[ADMINISTRATOR] " + $windowTitle
} else {
$host.UI.RawUI.WindowTitle = $windowTitle
}
}
Write-Host "$([DateTime]::Now.ToString('HH:mm:ss'))" -nonewline -backgroundcolor White -foregroundcolor Black
Write-Host ' ' –nonewline
if ($isAdministrator) {
Write-Host ("$(get-location)") -backgroundcolor Red
} else {
Write-Host ("$(get-location)") -backgroundcolor Blue
}
return '[' + $nextId + '] ';
}
Function Display-EnvironmentVariable {
Get-ChildItem ENV: | sort-object -property Name | format-table –autosize
}
Function RAlias {
param([string] $command = $(throw 'Enter the command to search the alias for'))
alias | where {$_.Definition -eq "$command"}
}
Function Find-ItemWithFilter {
param ([string] $filter = $(throw "You must specify a filter (e.g. *.doc)"))
Get-ChildItem -recurse -filter "$filter"
}
set-alias fi Find-ItemWithFilter
set-alias dev Display-EnvironmentVariable
$env:MSSdk = "$env:SystemDrive\Program Files\Microsoft SDKs\Windows\v6.0"
$env:SdkTools = "$env:MSSdk\Bin"
$env:OSLibraries = "$env:MSSdk\Lib"
$env:OSIncludes = "$env:MSSdk\Include;$env:MSSdk\Include\gl"
$env:VCTools = "$env:MSSdk\VC\Bin"
$env:VCLibraries = "$env:MSSdk\VC\Lib"
$env:VCIncludes = "$env:MSSdk\VC\Include;$env:MSSdk\VC\Include\Sys"
$env:ReferenceAssemblies = "$env:ProgramFiles\Reference Assemblies\Microsoft\WinFX\v3.0"
$env:Lib = "$env:VCLibraries;$env:OSLibraries;$env:Lib"
$env:Include = "$env:VCIncludes;$env:OSIncludes;$env:Include"
$env:CPU = "i386"
$env:APPVER = "6.0"
$env:TARGETOS = "WINNT"
$env:FxTools= "$env:windir\Microsoft.NET\Framework\v2.0.50727"
$env:Path = "$env:VCTools;$env:SdkTools;$env:FxTools;$env:SystemDrive\Program Files\Debugging Tools for Windows;$env:Path"
$env:ReferenceAssemblies = "$env:ProgramFiles\Reference Assemblies\Microsoft\WinFX\v3.0"