Sunday, May 31, 2009

TechED 2009 (Pics)

Had a great time at TechED. I met a lot of great folks including quite a few from the PowerScript community. Following are a few pics from TechED - specifically the Birds of a Feather Session that Hal and Steven hosted (Practical PowerShell: Best practices from the field - Check out the recorded podcast of the session!).


Hal Rottenberg, PowerShell MVP & Steven Murawski hosting the BOF.


Hal fielding some questions.


Kirk Munro, PowerShell MVP (http://poshoholic.com/)


From left to right, Steven Murawski, the back of Ed Wilson (1/2 of the Scripting Guys) and John Merrill (IT content evangelist and publishing manager in the Windows Server and Solutions Division User Assistance group).


Steven Murawski getting ready to work the PowerShell booth.


Ed Wilson evangelizing the merits of PowerShell.


Had a great time at the TechED, especially at the BOF and at the PowerShell Dinner.

Thursday, May 28, 2009

File Migration with PowerShell

Was recently tasked with assisting our file migration project. Until the following script (assumes you are using Quest AD Commandlets), this was a manual process.
$Users = get-content -path c:\users.txt
foreach ($User in $Users) {
$SourceFolder = "\\HumanResources\vol10\Users\$User"
$NewFolderName = "$SourceFolder-Migrated"

$homeDir = "\\personal-p01\users$\" + $User.substring(0,1) + "\$User"
Copy-Item $SourceFolder -Destination $homeDir -Recurse

Set-QADUser
$User -ObjectAttributes @{'HomeDirectory'=$homeDir; 'HomeDrive'= 'P:'}
$rule=new-object System.Security.AccessControl.FileSystemAccessRule("OSUMC\$User","FullControl","Allow")

foreach ($file in $(Get-ChildItem $homeDir -recurse)) {
$acl=get-acl $file.FullName
$acl.SetAccessRule($rule)
set-acl $File.Fullname $acl
}
# set the acl on the root folder
set-acl $homeDir $acl

# Rename-item doesn't work, so copy and delete
Copy-item $SourceFolder -Destination "$SourceFolder-migrated" -Recurse
Remove-Item $SourceFolder -Recurse -Force
}
Enjoy!