Monday, December 20, 2010

three wee scripts in powershell 2...

'tis the season of giving. several of my students have been asking for advanced user interface examples in powershell, so here are three scripts (and a module) for them, you, and anyone else who cares to look. they are heavily commented so i'll not go into details, but this is what i got you for christmas...

screenctl.psm1 is a module that contains three useful functions used by the scripts in this set. set-cursor places the cursor exactly where you want it on the screen, so that whatever you print starts displaying there. clear-lines clears a specific number of lines from the screen, rather than the whole thing. combined with set-cursor you can clear just a small section of the screen if you wish. out-wrappedstring is a variation of the text-wrapping function i talked about here.

addusers.ps1 walks you through adding a user account to active directory. it uses the screenctl module to customize the output and the activedirectory module to read and write the database.

get-weather.ps1 provides current conditions and forecast from an internet xml stream. it uses the screenctl module to wrap long forecast strings.

netcfg.ps1 provides a graphical interface to the network information for machines listed in active directory. it uses the active directory module to locate computers.

read the example scripts, improve them, have fun with them this holiday season. it's better than listening to uncle lloyd snore in front of the television, right?

No comments:

Post a Comment