I’m stuck on a train on the way to work and kept thinking #msteched and Orlando and Disney (over and over and over……)

Sorry but this surfaced. Destroy or Enjoy at your leisure :-)

Sung to “The Mickey Mouse Song”)

Where’s the place, ya wanna be
To learn tech-nic-ally?

T-E-C—H-E-D that’s where we shall be.

Fill your mind with Hyper-V Clusters and Active Directory.

T-E-C—H-E-D that’s where we shall be

At TechEd (AT TECHED!)
At TechEd (AT TECHED!)

We’ll fill our minds and take home a lot of SWAG (SWAG! SWAG! SWAG!)

Let’s run away and spend the day
The place with all to see

T-E-C—H-E-D that’s where we shall be

Sent from my Windows Phone

Making a new Domain Controller actually wasn’t a difficult task.   It was a quick “Click, click click,type type type, click click, backspace click, enter,enter” in the GUI

Get what I’m saying?

Promoting roles was actually easy as was adding features.   REPEATEDLY doing those tasks was about as fun as chewing tinfoil while gargling gasoline and singing “Yankee Doodle Dandy” or ANY fun tune.

Until the clouds parted, Jeffrey Snover and the Powershell team’s voice boomed out “Powershell” and Windows Server 2012 began to appear.

You see something wonderful has begun to form in the Development of this new system.  Sample scripts in the Server environment!

Running through the Wizard of adding the Active Directory Domain Services  is slightly different.   The Server Manager completely different than before but oh so much more powerful.  I select a Server or VHD and add the required Active Directory Domain Services role to it.

image

imageimage

Then of course begin the promotion to a Domain Controller.   But once you play and began adding it as a Domain Controller the magic starts to flow free

imageimage

Because at the end of it all – **** DING **** DING **** DING ****

A POWERSHELL Script!

image

Choosing “View Script” will produce the EXACT Powershell script being used to turn that computer in a Domain Controller.

Below (without anything done on my part) is the exact script Windows Server 2012 generated to create a new Domain Controller in my environment

#
# Windows PowerShell script for AD DS Deployment
#

Import-Module ADDSDeployment
Install-ADDSDomainController `
-DoNotConfigureGlobalCatalog:$false `
-CreateDNSDelegation:$false `
-Credential (Get-Credential) `
-CriticalReplicationOnly:$false `
-DatabasePath "C:\Windows\NTDS" `
-DomainName "energized.local" `
-InstallDNS:$true `
-LogPath "C:\Windows\NTDS" `
-RebootOnCompletion:$true `
-SiteName "Default-First-Site-Name" `
-SYSVOLPath "C:\Windows\SYSVOL" `
-Force:$true

Now the best part, think about it.   If you like the GUI and are happy with it.  Stay with it and be as productive as you love.   But the best part of the Sample script is when the boss in the organization screams.  “I need a new DC STAT!” you can take this script and just RUN it on the box.

Oh man, the future is getting Cool

The Power of Shell is… OH MAN IT’s GETTING ROCKIN’ CRAZY COOL!

Sean
The Energized Tech

I have one phrase to utter to Microsoft.  I know this is Beta but PLEASE oh PLEEEEEEAAAAASSSSEEEEE DON’T (DON’T DON’T DON’T!!!!) remove this feature I found.

In Server 2008R2 Microsoft introduced possibly the easiest way for a Help Desk or an Administrator to manage the common day to day functions in Active Directory.   It’s called the Active Directory Administrative Center.  You’ll have seen it and heard it was built in Powershell.

In Windows Server 2012 the Powers that be kicked this tool into OVERDRIVE. 

They attached a little piece that I initially overlooked in the Active Directory Administrative Center.    A small but incredibly Powerful change for the new Administrator.

They let us see the history of Powershell cmdlets PRODUCED by the Administrative Center.  

Let me state just how unbelievably over the top, Jump up and down, Flip for Joy, Scream to the SKIES amazing this is.  This is the BEST feature they could have introduced.

Let’s take a quick look!

image

So here is the current version of the “Active Directory Administrative Center”.   Functionally it is identical to the previous version.   I can create a user with the rich interface as I had last time.

image

imageimage

With this interface all of the details an Administrator needs are placed directly in front of them in an “At a Glance Scenario” making viewing and editing the user easier

So we click “OK” and create a user and all seems normal… Or does it?

Look right near the bottom of the GUI interface and see if you spot what I almost overlooked.   “Windows Powershell History”.  The BIGGEST and BEST CHANGE offered to an Administrator.

image

Simply click on “Windows Powershell History” to see the EXACT Cmdlets that were used to produce you action in the GUI!  No more muss and fuss!

image

You can copy the contents by right clicking and selecting Copy to copy a single line and paste it elsewhere.

You can even do a CTRL-A and CTRL-C to copy the content used directly into a NOTEPAD.EXE instance or better yet, paste it straight to the Powershell ISE for editing and debugging!

You can even (if you choose) have it clear off the history each time so you can see the Cmdlets being used to generate other functions of Active Directory.   How about just adding a user to a group or unlocking a user?  

The guesswork of using the Active Directory modules is now gone!  Just clear the history, execute the action in the “Active Directory Administrative Center”, check the Windows Powershell History and grab a copy of what you just did.

Now this is where Windows Server 2012 really just…well it just KICKS ASS!  I can use the GUI the way I will be comfortable, but if I need to learn to automate it, the very commands being used are place right square in FRONT OF ME!

The Future is looking pretty DAMN GREAT with Windows Server 2012 and Powershell. 

THE NEW DYNAMIC DUO!  w000t!

Sean
The Energized Tech

I thought I’d pull together something that might prove interestingly useful for those new to Powershell.   Passing credentials.

Interactive

Here’s your typical scenario.   You have a script that requires credentials internally.  So to provide those credentials you would do something like

$MyCredentials=GET-CREDENTIAL –credential “CONTOSO\Username”

and you of course see a box like this normally on the screen

image

Then you would type in the password and life would go on about it’s Merry Little Way…

Build from clear text in a Script

The other method you could leverage would be to embed the credentials in a Powershell script like this.

$MyDomain=’CONTOSO’
$MyClearTextUsername=’Username’
$MyClearTextPassword=’SuperSecretPasswordShhh’

$MyUsernameDomain=$MyDomain+’\’+$MyClearTextUsername

$SecurePassword=Convertto-SecureString –String $MyClearTextPassword –AsPlainText –force

$MyCredentials=New-object System.Management.Automation.PSCredential $MyUsernameDomain,$SecurePassword

This second method is of course very insecure as the credentials are stored directly and viewable within the script.   But the advantage to this is the ability to work with a legacy setup like a BAT, CMD or vbScript as the calling system.  

You can pass the credentials to a Powershell and have it invoke the Cmdlets (like those in Exchange 2007) with the same flow and no modification to the source script.

Store Credentials in an XML file

Using the EXPORT-CLIXML and IMPORT-CLIXML gives us a better option.   We can store away the entire System.Management.Automation.PSCredential Object as an XML file.   It’s actually VERY easy to use.

Create your credentials in any of the normal manners.   Let’s use the Interactive one as an example

Instead of just doing this for Credentials and keying in the password

$MyCredentials=GET-CREDENTIAL –Credential “CONTOSO\Username”

You can pipe the output EXPORT-CLIXML

$MyCredentials=GET-CREDENTIAL –Credential “CONTOSO\Username” | EXPORT-CLIXML C:\Scriptfolder\SecureCredentials.xml

Now if you ever need to re-use those credentials it’s just a simple matter of running an IMPORT-CLIXML and bringing the data back in as an Object.

$MyCredentials=IMPORT-CLIXML C:\Scriptfolder\SecureCredentials.xml

Now wherever this XML file exists SHOULD be a secure location.  That goes without saying.   But the beautiful part here is if you have a series of systems or scripts that may need to have those credentials reset, you’re just into rebuilding a single XML file and just having the scripts use an IMPORT-CLIXML file to bring in the data.

Remember Powershell is just another technology to get you home earlier.   Leverage these credential methods in your environment in whatever suits your organization best.

Remember, the Power of Shell is in YOU

Sean
The Energized Tech

Do you feel it in the air?  A spark floating and crawling beside you nudging you forward?

Do you find the urge to just make things happen?   the Desire to launch a Powershell console and see where it will take you?

Do you occasionally find yourself singing out loud in the office about Powershell much to your coworkers dismay?

THEN THE 2012 SCRIPTING GAMES are for you!

Register now at http://2012sg.poshcode.org and see where your skills take you.     Judged by celebrity Powershell judges from the worldwide community and Microsoft, it is a chance for the Enthusiast to gain practice in real time scenarios.  It’s the opportunity for the Specialist to stand up and shine amongst their peers.

It’s a chance to haul out some bragging rights for some kick butt one liners!

Oh heck, just sign up and try, it’s a great way to learn.

….Rumor has it there might even be fabulous PRIZES!

So register now at http://2011sg.poshcode.org for the 2012 Scripting Games.   Join us all together.

For in the 2012 Scripting Games… WE WILL SCRIPT IT!

 

WP_000342

And the summit began.   A normal flight after massive warnings of some crazy snow storm across Ontario I got lucky and NOTHING.  Yet my poor roommate Cory “SyntaxC4” got stuck with some Air Canada Hell for 28 hours.   Bummer.

First day in was Saturday and an opportunity for MVP’s worldwide to give back through www.geekgive.org .   Over 50+ people pulled together bagging food for Northwest Harvest in Seattle Washington.   The Passion and Energy flowed from them all in a massive stream.   7500 pounds of beans bagged in one hour.   All available product was done, and far faster than expected.

WP_000108WP_000107WP_000109

WP_000105WP_000111

Then forward we had a gap in time where I spent the day learning about Seattle with fellow Powershell MVP’s Bartek Bierslawski, Shane Hoey and Azure MVP Cory Fowler.   We had an interesting tour of the lost underground city in Seattle, Washington after a run on the Monorail.    As a tribute to the coffee gods, we had to visit the original Starbucks in Pike’s Place Market of course.  (All praise the coffee gods…)

WP_000205WP_000217WP_000140WP_000141WP_000144WP_000157WP_000159WP_000165WP_000166WP_000185WP_000186WP_000193WP_000194WP_000198WP_000204

Then of course it all started to roll in,  the content the information the……. “RESPECT THE NDA! RESPECT THE NDA!” *klik*

A good part of this I cannot share, but I CAN share a few things I learned outside of technical stuff you’re not allowed to hear Winking smile

Getting your friends together for a Karaoke session can be a great idea, perfect example of community.

The Highway to Powershell–Live at MVP Summit 2012–Dr. Scripto and the Cmdlets

Unlocked Cell Phones are a potential for Great amusement

When armed with large Brass Instruments Microsofties TRULY Release their passions and ROCK the Joint! (By the way, TROMBONES ROCK!)

WP_000237WP_000234WP_000235

At Microsoft they sell a PROPER size coffee cup!

WP_000245

…and bringing a group of people from different countries, religions, races and creeds can be one of the most inspirational events you will ever encounter

WP_000293WP_000297WP_000300WP_000302WP_000303WP_000304WP_000310WP_000316WP_000317WP_000318WP_000321WP_000322WP_000326WP_000334WP_000339WP_000278WP_000283WP_000292

And of course NEVER EVER leave an unattended photobooth around with Powershell MVPs on the loose…

 

IMG_0599IMG_0109IMG_0579IMG_0580IMG_0581IMG_0582IMG_0584IMG_0585IMG_0111IMG_0586IMG_0587IMG_0110IMG_0588IMG_0589IMG_0590IMG_0591IMG_0592IMG_0595IMG_0597IMG_0598IMG_0596

Yes…. Summit was a time to learn both technical know how and grow more as people and a community.   I will never forget the 2012 Summit for the rest of my days.  Thanks for the opportunity Microsoft. Smile

Sean
The Energized Tech

Now I am absolutely certain I will hear a voice from far above (or maybe a bit closer to New York) booming out at me “THIS CAN BE DONE WITH REGULAR EXPRESSIONS!”

I’m pretty certain of that.  I don’t claim to have mastered Regular Expressions.   But I had a simple need today.   Converting cases of words in Powershell.

In my case I had a list of data that was in ALL UPPERCASE and since that feels a bit like shouting I wanted to do something with it.

In Powershell we have many built in methods to manipulate string data.   There are three I’m going to play with today, toupper, tolower and substring.

For example if I have this string….

$Sonnet=“There once was a Canadian Nerd, WHO saNG like an OFFKEY Bird…”

I can switch all of the characters to lowercase by using this method

$Sonnet.tolower()

Which will give us the following output

there once was a canadian nerd, who sang like an offkey bird…

If I would like to make it look like I’m shouting so everybody in Texas can hear me I can switch it all to uppercase

$Sonnet.toupper()

Which (Cover your ears as I’ll now be shouting) looks like this.

THERE ONCE WAS A CANADIAN NERD, WHO SANG LIKE AN OFFKEY BIRD…

Sorry that was a bit loud.   But you can see switching cases is quite trivial.   But here’s the fun.  What if you have to ensure a word is just Capitalized?

For that bit of trickery we can leverage Powershell and the magic substring command.

First let’s take a look at this loud and abusive word.

$ScaryThing=“JABBERWOCKY”

If we’d to present our good friend with JUST the name capitalized, we can grab the first character with a substring, pop it into uppercase like so

$ScaryThing.substring(0,1).toupper()

J

The audience “Oooohs” and “Ahhhs” in the background.    Without knowing the length of the word, we can use substring to grab all characters from the second character to the end and switch to lowercase

$ScaryThing.substring(1).tolower()

abberwocky

….More gasping from the audience…

And so with a wave of my hand and the magic words “Snoopy Dance”

$ScaryThing.substring(0,1).toupper()+$Scarystring.substring(1)

Jabberwocky

Now our good friend will appear less frightening to the general public.  Of course I’m having a bit of fun here but I had a situation where I had a list of full names that were in all uppercase.   Yes it was my own fault, a bad accident between an auto user generator for a Demo environment and an overly caffeinated “toupper()” method (or a broken CAPSlock key, the details are fuzzy).  So in my case I had a perfectly good list of names like

Name
ANDRE GRANT
ALTHEA DOWNS
AUDRA HANEY
CHASITY MCMILLAN
CHASITY KENNEDY
CRYSTAL BURGESS
BRUCE SHEPPARD
CHRISTI MCINTYRE
CHERIE TERRY

Perfectly good, except they were all SHOUTING!

What to do? Just grab each name, split ‘em and use my new evil powers before creating their names in my demo system

$fl=$_.Name;$first=fl[0];$last=$fl[1];

$first=$first.substring(0,1)+$first.substring(1).tolower();$last=$last.substring(0,1)+$last.substring(1).tolower();

Ok, maybe it’s partially useful and the gods of Regex will probably smite me down, but I’m an ITPro.

Have mercy on me.

Sean
The Energized Tech

The Power of Shell is in YOU