Bulk creation of Active Directory User accounts via Powershell v2

Most system administrators that I know has the burden (or the joy if you like a challenge) of creating and managing large quantities of users in Active Directory. I, myself face creating 150+ at the start of every year and I for the most part we have developed a new way to do it every year.

This year I chose to taken it upon myself to come up with the method and couldn’t think of a better solution than Powershell. Considering all the work Microsoft seems to be putting behind this scripting & command engine it couldn’t hurt to try.

The script I cobbled together is VERY basic (as I have practically zero knowledge of PS) but worked for me, hopefully it can be of use to anyone else.

Requirements:

  • Powershell v2
  • Active Directory Module for Powershell (installed by default on WK8R2 Domain Controllers or available in the latest RSAT tools)

import-csv .\import.csv | %{new-aduser -Name $_.Name -DisplayName $_.DisplayName -GivenName $_.GivenName -SamAccountName $_.SamAccountName -UserPrincipalName $_.UserPrincipalName -Description $_.Description -Surname $_.Surname -Path ‘OU=example,DC=domain,DC=com' -CannotChangePassword $false -ChangePasswordAtLogon $false ; Set-ADAccountPassword -identity $_.SamAccountName -NewPassword (ConvertTo-SecureString -AsPlainText $_.AccountPassword -Force) -Reset ; Enable-ADAccount -identity $_.SamAccountName}

Save the above code, paste into your favourite text editor and save as a .ps1 (Powershell Script).

Next, create import.csv in the same directory as the script file and open it up in Excel. Now lets get the following headers inserted:

Name DisplayName GivenName SamAccountName UserPrincipleName Description Surname AccountPassword

All that is left is to fill in the csv with your data from where-ever that may be and run the script.

If I ever get around to it I hope to improve the script so that all that is required is GivenName, Surname & SamAccountName as the rest should either be generated from the 3 listed or grabbed from the environment (UserPrincipleName). Currently I perform a bit of Excel formula magic to do this but it adds time and that’s what we are trying to cut down right?

I would also like to be able to add group memberships in the future but one thing at a time.

Hopefully that saves any SysAdmin’s a day on trying to workout their own solution, if not, it certainly was a fun experience and a achievement for the day!

Joined the Twitter Sensation

Hey all, looking at how long it has been since I have updated my blog I decided it would be much simplier to start doing micro-blogging or “tweeting”. You can catch my “tweets” at the right hand side of this blog or alternatively goto http://twitter.com/DXPetti. I may decide in the future to make my tweets appear as blog posts but given the nature of most tweets (aka small and to the point, not very bloggish) at this stage they will stay in the sidebar!

Cheers!

Aus Government planning mandatory ISP level internet filtering

Yup thats right, our goverment is trying to implement filtering of internet content at the Internet Service Provider level. What does this mean for the humble internet user you ask? Slower internet, the most accurate filter which the government has tested slows down internet access by roughly 70 percent. Not only that but as a Network Administrator myself I know how easy it is to have false positives when filtering internet content. You could be simply searching for 4″ screw and the filter might interpret that as something of sexual nature. Or maybe you are researching weaponary used in the Iraq conflict….smells like terrorism in the making to the ISP filter. The government does something controversial, you won’t find it on the internet. Yup just like that your freedom to browse the internet ‘as is’ is gone. Its like the digital Great Wall of China all over again.

This not only has ramifactions on the general user but on the country as a whole? How can Australia compete on a global scale business-wise when they are at such a disadvantage (the current speed of Broadband in Australia is appauling in its current state but thats another issue for another time)?

You might ask “Surely they will let the user decide if filtered internet is for them?”. Uh Uh, the filtering is mandatory though the user can opt for a “less filtered” option which has yet to described. Internet is modern freedom, its like when you first get your license, the world in all its shining light and dark shadows opens up to you. How can a government force everyone to not have that freedom!

You can do something about it though; NoCleanFeed.com has the answers. Head on over and help us fight the good fight!

Watch this space

Yarp, I am back after a short hiatus in between providers. Now DXPetti.com lives on Jumba Webhosting and I couldn’t be happier. After restoring my SQL DB for me (for some reason I don’t have permissions to restore .SQL files…weird) they even edited my WordPress config files to reflect the changes. Nice chaps!

Anyhoo my 22nd B’Day has been and gone and out of it I have scored some nice camera gear to allow me to do some long exposures shots among other things!

Tools of the Trade

Tools of the Trade

So look out at my flickr page (http://www.flickr.com/photos/10867582@N08/) in the near future to see what I can produce using my new tools of the trade :)

I am also looking for a suitable solution to particularly wide images being cut off due to my love of themes that have a set width instead of a flexible one. Hopefully I can implement that quick smart!

Thats enough from me, back to WipeoutHD/Force Unleashed on the Playstation 3 :)

STI Spec C spotted, details seeping through

In Friday’s CarGuide in the Herald Sun (Aussie Newspaper) they had a article detailing the new Subaru Impreza WRX STI Spec C. Little background; the Spec C version of the Impreza WRX STI was the race ready, lightened and tightened edition in which Subaru used to homologated (see: http://en.wikipedia.org/wiki/Homologation) their WRC car. These rules no longer apply but Subaru still make the Spec C to treat the fans to a limited version (along with other treats like the S20x series and the Type RA/RA-R).

Anyhoo back to the article; The new Spec C is focusing on lightening the body weight and improving handling rather than add anymore/much power to the existing STI. More details can be found http://forums.nasioc.com/forums/showthread.php?t=1557819&page=3 (my post is at the very top).

It looks the goods and if it does infact hit Australia I will be definately getting one. By the time they hit I will be off my Ps and legally able to drive one too :D

One last thing. Australia’s current rating system for videogame is shall we say….crap. Its very outdated and does not reflect the attitude of the modern Australian. There are more gamers these days than there ever was. In fact there is a gaming console per 5 people in Australia. Thats pure consoles like your Playstation 3s and Nintendo Wii etc and not things that CAN play games like Personal Computers.

One man trying to change this is Greg Tannahill. He is running as a candidate in October in the Australia Capital Territory’s state election. We wish him all the best and when you have a few minutes drop by his website @ http://amongthedust.blogspot.com/.

Vista Issue Solved: Cannot Save Favourites

Okay I have been having this issue where whenever I try to save a website into my favourites and in a folder I have moved from a backup where it would throw up a error message with the delightful error description “unspecified error”. After a bit of a google hunt here is how to fix it:

Drop to a Elevated Command Prompt (Start>type cmd>right-click on cmd icon and hit "Run as Administrator"
Navigate to your user profile folder (cd c:\users\username\)
Type icacls Favorites /setintegritylevel (OI)(CI)low

And hey presto its fixed!

This problem occurs as Internet Explorer in Windows Vista runs under Protected mode (low integrity level) by default, and therefore will only be able to modify objects marked with a low integrity level in their system ACLs. This is to save the moronic users from killing their computer via spyware and other nasties on the Internet.

A good read on integrity levels can be found @ http://blogs.technet.com/steriley/archive/2006/07/21/442870.aspx

Another problem solved :)

Subaru Impreza NA Concept by STI(Tokyo Auto Salon 08)

Subaru Impreza NA Concept by STI

Basically a MY08 Impreza 2.0R with these bits!

1. front lip spoiler
2. spoiler lip
3. front grill
4. rear spoiler lip
5. flexible tower bar
6. Recaro bucket seats
7. seat bracket
8. shift knob
9. pedal pads
10. rear view mirror seal
11. black interior trim
12. stainless muffler
13. intake manifold
14. oil filler cap
15. front height adjustment type suspension
16. rear height adjustment type suspension
17. front 4-pot brake
18. rear 2-pot brake
19. lateral link front+rear (pillow)
20. aluminium wheels (17×7.5j)
21. Bridgestone tires (Potenza RE070; 225/45R17)
22. wheel nuts

All from the Subaru’s factory tuning house STI (Subaru Tecnica International)!

I was just about to dump some cash on my current MY03 RS to get STI springs and strut bars for front and rear but if this thing comes out in Aus and is priced right (closer to current 2.0R pricing and not near the WRX) then I will be waltzing down to Subaru Docklands and trading in my current one for a demo (so I can bargin like a true bastard :P ).

I always entertained the notion of Continue reading

Quantum of Solace

Hey All,

Wow, long time since I have attended to this blog. Main Computer has been down for a long time (died just before I went away to Hong Kong; more on that later) and I have been focusing my attention on other things like my Cert 4 in IT (which I now have) and work in general instead of getting my main rig up but now its up and expect some more regular entries.

There are two very awesome movies coming out this year. In the not too distant future we have Batman: The Dark Knight but even further down the track a personal favourite of mine is getting a direct sequel for the first time…Bond, James Bond!

Entitled Quantum of Solace, the plot picks up directly where Casino Royale left the audience, with Bond wanting answers (from the elusive Mr White) after his only true love Vesper killed herself in an attempt to shield James from a organisation described as being bigger than any one could possibly fathom!

Check out everything QoS at http://www.007.com or have a play with the cool widget below!

Thats it for now, look forward to some articles about The Dark Knight, Hong Kong, Metal Gear Solid 4 and more in the near future.
Cheers