Always A-HEAD, By being ahead you are always master of time

Hits

BOOKS

Wednesday, December 20, 2006

PowerShell Lab Experience

Set-ExecutionPolicy

Get-ExecutionPolicy

PS E:\> Get-ChildItem E:\PowerShell | measure-object length -Average -Sum -Maximum -Minimum

Count : 4
Average : 19491
Sum : 77964
Maximum : 37856
Minimum : 768
Property : length

-------------------------------------- 

PS E:\> Get-ChildItem E:\PowerShell | Group extension

Count Name Group
----- ---- -----
2 {MakesSense, NeedtoTry}
4 .log {Ldisk.log, process.log, properties.log, service.log}

------------------------------------

PS E:\> ((Get-ChildItem C:\WINDOWS\system32 | Measure-Object length -sum).sum)/1MB
354.373404502869

------------------------------------

PS E:\> Get-ChildItem c:\ -Recurse -Include *.tmp | select-object pspath

PSPath
Microsoft.PowerShell.Core\FileSystem::C:\WINDOWS\system32\CONFIG.TMP
Microsoft.PowerShell.Core\FileSystem::C:\WINDOWS\system32\setb6.tmp
Microsoft.PowerShell.Core\FileSystem::C:\WINDOWS\SET3.tmp
Microsoft.PowerShell.Core\FileSystem::C:\WINDOWS\SET4.tmp
Microsoft.PowerShell.Core\FileSystem::C:\WINDOWS\SET8.tmp

------------------

 

PS E:\> Get-ChildItem c:\ -Recurse -Include *.tmp | select-object fullname

FullName
--------
C:\WINDOWS\system32\CONFIG.TMP
C:\WINDOWS\system32\setb6.tmp
C:\WINDOWS\SET3.tmp
C:\WINDOWS\SET4.tmp
C:\WINDOWS\SET8.tmp

-----------------------------------

PS E:\> Get-ChildItem C:\Softwares -Recurse | where {$_.length -gt 100MB}

Directory: Microsoft.PowerShell.Core\FileSystem::C:\Softwares\SeverSupportTools\ServicePack01-Win2k3

Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 14/10/2006 20:21 345322744 WindowsServer2003-KB889101-SP1-x86-ENU.exe

-------------------------------------

Get-ChildItem C:\WINDOWS\system32 | Select-Object extension | Sort-Object extension -Unique

 

-------------------------------------

 

Get-ChildItem C:\backupfiles.bak -Recurse | ForEach-Object{$D=get-date;$_.lastwritetime=$D}

Technorati Tags:

No comments: