Tuesday, December 8, 2009

List the files greater than given size using powershell

Below powershell code helps you to list the files which are greater than given size(2GB in this case) and output the file sizes in MB/GB format.

PS C:\local> Get-ChildItem -path c:\mydata\ -recursive | where  { ($_.Length /1GB) -gt 2 } | foreach { ($_.length/1GB).Tostring("0.00") }

Do write in comments section here if you need any charification.

Tuesday, December 1, 2009

Find password last set/reset time using Powershell

This small piece of code helps you to know when a active directory user has changed his password last time. Use your own inventions to make the output appear the way you want.

$user = "user1"
$searcher=New-Object DirectoryServices.DirectorySearcher
$changedtime = [datetime]::fromfiletime($results.properties.pwdlastset[0])
write-host -b blue -f red The user, $user has changed password last time at $changedtime

Happy Learning..,
Sitaram Pamarthi