Future of The PowerShell Project and Learning Python

DISCLAIMER: This was originally a way to document what I was learning when I first ran into PowerShell as a student who had no prior scripting experience. The examples given and the posts done in relation to the project most likely do not follow best practices and should definitely be reviewed if they are going to be used in any fashion. You have been warned! 🙂

Week 4 never came. Instead, the next PSP post is coming a bit late and will have drive-by posts every now and then. I am currently taking an MIT OpenCourseware course for an introduction to computer science, so there will also be little posts of Python (maybe C++ too?).

First off, you should check out this update which allows your Windows 7 workstation to have certain PowerShell cmdlets (like the Active Directory module) available locally. It’s nifty when I am just doing a query, or perhaps running Super Simple Script IV!

Here’s a quickie to use with the Active Directory when querying for the user’s name:

# Loading AD cmdlets, and requesting username
Import-Module ActiveDirectory
$thatdude = “So who ya lookin’ for?”

$thisdude = Get-ADuser $thatdude
$firstname = $thatdude.givenname ; $lastname = $thatdude.surname ; $fullname = “$lastname,$firstname”
$groups = Get-ADPrincipleGroupMembership $thatdude | ft Name
$fullname >> Info.txt ; $groups >> Info.txt ; “” >> Info.txt
notepad ./Info.txt

So whenever I am looking for a users actual name and group membership, I can run the script and just enter their name. The output in the Info.txt document will look like this:

Nietzsche, Friedrich

Name
———
Domain Users
Awesome Town

There you have it. A quick script that can help when comparing user privileges and understanding why one user is accessing something another isn’t. Anyway, see you next time with more cool stuff!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s