Strict Standards: Redefining already defined constructor for class wpdb in /var/www/myfoto.se/jbits.se/blog/wp-includes/wp-db.php on line 56

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/myfoto.se/jbits.se/blog/wp-includes/cache.php on line 36

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /var/www/myfoto.se/jbits.se/blog/wp-includes/cache.php on line 384

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 541

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 560

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 659

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el($output) in /var/www/myfoto.se/jbits.se/blog/wp-includes/classes.php on line 684

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/myfoto.se/jbits.se/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/myfoto.se/jbits.se/blog/wp-content/plugins/code-highlighter/codehighlighter.php on line 42
jbits.se » 2011 » March
Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/myfoto.se/jbits.se/blog/wp-includes/kses.php on line 627

jbits.se

Jörgen Björkmans blog

Archive for March, 2011

Mar
10

Disk Space Dictator ™

Posted by jbjorkman on March 10, 2011 under
Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/myfoto.se/jbits.se/blog/wp-includes/formatting.php on line 82
Powershell

Use this script to remind users logging on to Mgmt or TS machines to keep their profile and recycle bin size down. 

# Disk Space Dictator (tm)
# (c) 2011 / jbjorkman

$PSWarning=199
$RSWarning=99

[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
$ProfileSize=[math]::truncate((New-Object -com Scripting.FileSystemObject).GetFolder($Env:Userprofile).Size/1024/1024)
$RecyclerSize=[math]::truncate((New-Object -com Scripting.FileSystemObject).GetFolder("C:\RECYCLER\"+(new-object system.security.principal.NtAccount($Env:userName)).translate([system.security.principal.securityidentifier]).Value).Size/1024/1024)
$msg="Please help keep disk space usage down.`r`n`r`n"
$msg=$msg+"This popup will warn you if your profile exceeds 200Mb,`r`n"
$msg=$msg+"or if your system drive recycle bin exceeds 100Mb.`r`n"

$Warn=$False
If ($ProfileSize -gt $PSWarning) { $msg=$msg+"`r`nYour profile is $ProfileSize Mb." ; $Warn=$true}
If ($RecyclerSize -gt $RSWarning) { $msg=$msg+"`r`nYou have $RecyclerSize Mb in the recycle bin" ; $Warn=$true}
If($Warn) {
 $icon=[system.drawing.icon]::ExtractAssociatedIcon((join-path $pshome powershell.exe))
 $notify = new-object system.windows.forms.notifyicon
 $notify.icon = $icon
 $notify.visible = $true
 $notify.showballoontip(20,"Disk Space Dictator (tm)",$msg, [system.windows.forms.tooltipicon]::Info)
 Start-sleep 15
 $notify.visible=$false
}