2011-04-02

The Holy Grail of PowerShell Wisdom?

I can't believe I've gone this many years without the writings of James Brundage (@JamesBru) as a part of my daily scripting life (no offense @ScriptingGuy you'll always be my first).

2011-03-27

2011 Scripting Games - Judges


Aleksandar_Nikolic

Andy_Schneider

Arnaud_Pettijean

Bhargav_Shukla

Brandon_Shell

Claus_Nielsen

Doug_Finke

Ed_Wilson

Gary_Siepser

Georges_Maheu

 Jan_Egil_Ring

 Jonathan_Medd

 Marco_Shaw

 Matt_Johnson

 Michael_Frommhold

 Niklas_Goude
 
Oliver_Lipkau

Ragnar_Harper

Richard_Siddaway

 Sean_Kearney

 Shay_Levy

 Steven_Murawski

 Tome_Tanasovski

Trevor_Sullivan

How many ways can you say March 27?

Not that March 27 (my birthday) is more important than any of the other 364 days of the year but I like it. And if you've ever asked yourself "Self, I wonder how many ways I can use PowerShell to display today's date." ask no more.

It's 133.




2011-03-24

TEC2011

I'm going to The Experts Conference 2011 (TEC2011) PowerShell Deep Dive!
Yes!

2011-03-23

Welcome HomeDir (Sanitarium)

Welcome to where time stands still.
No one leaves and no one will.



We have a case of allowing the inmates to run the asylum at our organization. For years we've provided unlimited storage space for office file shares and home directories. We've imposed some restrictions mind you. We don't let the inmates keep knives, guns, or narcotics but we're fine with allowing them to pretty much dictate all the other rules.

So here we are, years down the road, millions (literally) of files and thousands of folders. We have 4% of our users consuming 90% of HomeDir storage, backups that take days, not enough tapes to keep more than 90 days of backups...did I mention if seems like an asylum some days?

On a lighter note, we're ready to implement an archival utility to free up some storage space but we have some decisions to make and policies to implement in our organization:
1) Policy: Files with lastAccessTime older than 6yrs should be deleted.
1a) Dilemma: Management wants us to notify users whenever we're about to delete files so they can have the option to recover, recycle, or save a copy to DVD. Unfortunately, we have 500K+ files in this category. Many of these files exist in office shares that potentially have hundreds of valid owners.

Obviously PowerShell has come in handy with querying to analyze this situation. I've created reports with path, owner, size, lastAccessTime for each file meeting this condition. (Shameless PowerShell plug) As often is the case, software we've purchased to handle some process can't turn out information that I can produce sometimes with a one-line PowerShell script.

My current plan/proposal to management:
Code Name: Straight-Jacket
-Strictly enforce our Policy of 6yrs
-Notify users of policy
-Provide users with means to create their own DVD copies of files
-Setup temporary recycle bin (storage) for deleted files for 3-6mo period.

Now to convince management that trying to notify users of individual file deletion is putting all the responsibility on us and not on the folks who have already have a vested interest in managing files. Wish me luck!
(Metallica - Welcome Home (sanitarium))

2011-03-18

Displaying IIS Properties

Typically at some point during the week someone will either email, call, or show up at my desk reporting problems with or needing to update a web site. We host several internal web applications and it's not easy remembering settings such as...
* Friendly Name
* ASP.NET Version
* AppPoolId
* Path

With help from the Hey, Scripting Guy! I was able to add ASP.NET version to the output of a PowerShell script I wrote. Script Center Repository Link: get-iisProperties

Enjoy. Hope you find it helpful.

2009-05-18

welllll, isn't that Special...(Folders)



I was building a Batch script to push out a desktop shortcut to workstations on our domain via SMS. I ran into some issues with the %ALLUSERSPROFILE% environment variable reading from the server environment versus the local workstation environment. Anyhow, I stumbled across the .NET class Environment which provides a static method named GetFolderPath().


List Special Folders...
[environment+specialfolder]::GetNames([environment+specialfolder])

Desktop
Programs
Personal
MyDocuments
Favorites
Startup
Recent
SendTo
StartMenu
MyMusic
DesktopDirectory
MyComputer
Templates
ApplicationData
LocalApplicationData
InternetCache
Cookies
History
CommonApplicationData
System
ProgramFiles
MyPictures
CommonProgramFiles


Retreiving specific Special Folders...
$myDocuments = [Environment]::GetFolderPath("MyDocuments")
Once you've defined the variable you can then reuse it...


get-childitem $myDocuments
Mode   LastWriteTime        Length   Name
----   ------------------   ------   ----
d----  5/3/2009 7:47 PM            folder1