December 23rd, 2013

‘Twas the Night Before Scripting: Part 3

Doctor Scripto
Scripter

Summary: Dr. Scripto teaches our Admin friend how to find cmdlets in a module and get Help.

Microsoft Scripting Guy, Ed Wilson, here. If you missed it yesterday, see Sean’s latest video: Just Script It! Also be sure to read: 

Yesterday we saw how Dr. Scripto aided our good Administrator friend, a person who had never scripted, modify multiple users in Active Directory.  Yet there was still much left to do on this project, including deployment of workstations, oh my!

And so we continue with our third badly rhyme-filled session…

And so it continued

Yet not deep in the night,

For PowerShell scripting

Deleted the fright.

 

With the good Dr. Scripto

And our new Admin friend

Learning to automate,

His aid he would lend.

 

He then looked at the list

Of things left to do.

Instead of a panic,

A thought came anew.

 

“Dr. Scripto, a question,

A query for you

I wonder if PowerShell

Could make this happen to?

 

New accounts for computers

I must create now.

Is there a cmdlet or

Some easy way how?”

 

The good Doctor smiled

(Which was tricky, ya know,

Since he is made of

Plaster, not snow).

 

He pulled a list of cmdlets

From a module so keen,

Active Directory it was called,

Listed them all on the screen.

Get-Command –module ActiveDirectory

 

“Hmm, perhaps I should show

(Yes, that would make more sense)

Only those for the computer,

Would make it less dense”

Get-Command –name *Computer* –module ActiveDirectory

Image of command output 

“Looking on screen

At the list, oh so small,

I see one that makes sense,

Filling the call.”

New-ADComputer

 

“Dr. Scripto, but how…

How can I know?

To learn how to use

The cmdlet below?”

 

With his bobbly head

He bounced left and right,

“We use Get-Help

And –examples for sight.”

Get-Help New-ADComputer -examples

 Image of command output 

Our Admin smiled at the

Sample he saw now,

“This seems all too simple!”

As he blinked and said, “Wow!”

 

So then he typed

Just for fun, in a way,

A sample cmdlet

To try it today.

New-ADComputer –name “JohnnyTestPC” –SamAccountName “JohnnyTestPC”

 

And checking the results

Within the MMC,

Our Admin could view

His success for to see.

Image of menu 

“Creating accounts

For over 500 PCs

Might not be so hard

With this cmdlet for me!”

 

Dr. Scripto bobbed Yes

And jumped up and down,

Our Admin now had a smile

Instead of a frown.

 

And tomorrow we’ll

See how he’ll fare,

On setting up systems

With security to fare!

I invite you to follow the Scripting Guys on Twitter and Facebook. If you have any questions, send email to scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Sean Kearney, Honorary Scripting Guy and Windows PowerShell MVP

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.