Re: [PoSh] Collecting oneliners/scripts to wow others
- From: "/\\/\\o\\/\\/" <no@xxxxxxxx>
- Date: Thu, 04 May 2006 19:45:48 +0200
a one-liner I also like :
a GUI directory copy :
(new-object -com Shell.application).NameSpace((new-object -com Shell.application).browseforFolder(0, "Select Target", 0, 0x11)).CopyHere((new-object -com Shell.application).browseforFolder(0,"Select Source", 0, 0x11))
gr /\/\o\/\/
Keith Hill [MVP] wrote:
"dreeschkind" <dreeschkind@xxxxxxxxxxxxxxxxxxxxxxxxx <mailto:dreeschkind@xxxxxxxxxxxxxxxxxxxxxxxxx>> wrote in message news:0D3A3FD9-E891-4425-BA89-1CFC8A75DF44@xxxxxxxxxxxxxxxx.
> Hi all,
>
> Monad/MSH/PowerShell is my default shell for several month now and everytime
> someone looks over my shoulder, he/she asks me what the hell I'm doing with
> that 'stupid old dos prompt'. So I have to explain the whole thing over and
> over again.
>
> For this purpose I'm looking for impressive oneliners and great scripts to
> demonstrate the vastly superior power and manifold possibilities and to
> explain the key concept in very short time. I know there are some examples in
> the documentationpack for comparison with unix shells, but these didn't
> really worked for me. My own functions are mainly experimental and often are
> not that usefull at all because I'm still exploring the full power of
> PowerShell.
>
> So if you have really cool and nifty functions/skripts in your profile etc.
> that you are using for this particular purpose or that you are using
> frequently or that you are really proud of, please post them here!
Here's some from my blog (and from daily use):
If you are thinking about adding more RAM and can't remember how your current memory occupies banks:
PoSH> get-WMIObject Win32_PhysicalMemory |
>> select DeviceLocator, Capacity, Speed | sort DeviceLocator | ft -auto
>>
DeviceLocator Capacity Speed
------------- -------- -----
CHANNEL A DIMM 0 536870912 400
CHANNEL A DIMM 1 536870912 400
CHANNEL B DIMM 0 1073741824 400
For developers:
# Show me all the versions of the MS CRT loaded and what processes
# are using them.
PoSH> get-process | select processname -expand Modules -ea SilentlyContinue |
>> where {$_.ModuleName -like "msvc*.dll"} |
>> group {$_.ModuleName} | format-list
Name : MSVCP71.dll
Count : 12
Group : {CCAPP, CCEVTMGR, CCSETMGR, EDICT, iexplore, msimn, msn, NAVAPSVC,
NPFMNTOR, SPBBCSvc, WeatherDataClient, WINWORD}
Values : {MSVCP71.dll}
<snip>
Stats on your music collection:
PoSH> gci "$home\my documents\my music" -rec |
>> where {!$_.PSIsContainer -and $_.Extension -match "wma|mp3"} |
>> Measure-Object -property length -sum -min -max -ave
>>
Count : 1018
Average : 2991362.43123772
Sum : 3045206955
Max : 102750941
Min : 89025
Property : Length
And two simple ones that I like:
PoSH> gci | group extension | sort count
PoSH> gci | sort extension | ft -groupby extension
And to see when during the day you use the shell the most:
get-history -count $MaximumHistoryCount |
group {$_.StartExecutionTime.Hour} |
sort Count -desc |
format-table Count,@{l="Hour";e={$_.Name}},Group -auto
Here's one I used recently after I recovered files onto a new hard drive. It tells you which files have changed within a certain period of time.
$startDate = (get-date).AddDays(-3) # Get date for 3 days previous to today
gci . -rec | where {$_.LastWriteTime -gt $startDate}
Finally, dumping system event log errors:
get-eventlog system | where {$_.EntryType -eq "Error"} | fl
--
Keith
- Follow-Ups:
- Re: [PoSh] Collecting oneliners/scripts to wow others
- From: /\\/\\o\\/\\/
- Re: [PoSh] Collecting oneliners/scripts to wow others
- Prev by Date: Re: Howto: Remove Computer accounts from AD using a list
- Next by Date: Re: Security and monad - 1 attachment
- Previous by thread: Re: [PoSh] Collecting oneliners/scripts to wow others
- Next by thread: Re: [PoSh] Collecting oneliners/scripts to wow others
- Index(es):
Relevant Pages
|