Showing posts with label automation. Show all posts
Showing posts with label automation. Show all posts

January 26, 2010

You Can Do -Help
[Building HELP into your custom functions is a good thing! Here's a template to help you through it...]


Do you write your own Powershell functions for use in your AD or Exchange environment? Are they user friendly? Do others use them, or would you like them to? Do you add a -Help switch and display help text in your custom functions? You should! It's well worth your while to build in some HELP for a few reasons...

First, they won't be running to you to ask you syntactical questions even though you've told them six times already. Additionally, you won't be asking yourself those same questions when you try to use your awesome new function three weeks from now. Lastly, building inline help into your functions will force you to better understand how they work, as well as demonstrating your superior scripting abilities to your boss (make sure you demo the function at an upcoming staff meeting). Read on to see if your functions measure up.

Copy the code (link at end of post) and paste it into your Powershell session window to define the function called "MyTestFunction". To test the functionality, type the following at the Powershell prompt:

MyTestFunction (to show usage syntax)
MyTestFunction -Help (to display abbreviated help)
MyTestFunction -Help -Full (to display full help)
MyTestFunction SomeArgument (to simulate processing of SomeArgument)



Notes and Code for this post:
Get the shell function code here.
Although the copy code & "paste into your Powershell session" method of defining the function works for testing the function, the content should really be copied and pasted into an editor such as notepad.exe, then saved as a .ps1 script. This will retain the HELP text formatting (blank lines) that get stripped out when copy/paste into session window is used. Try it, you'll see what i mean.

This code works with Powershell v1 and v2.

Was there enough detail in this post?




.end


more...

June 18, 2009

Confluence Automation with Powershell
[aka Scripting your Wiki - Part I of a series]

For those of you who use the Confluence wiki to maintain documentation, this post will show you how we at ITEC use Powershell scripting to automate reports and build pages using the Confluence Command Line Interface (CLI). The Confluence CLI is a Java based set of procedures for automatically creating/updating pages in your Confluence spaces.

We have several systems that report their status to various tools that generate reports for internal staff. Read on for details on how we use Powershell and the Confluence CLI to automate documentation for internal system status reporting as well as usage statistics for campus applications that we host.

How We Use It
Responsible for managing and maintaining our Exchange environment as well as our hosted mailboxes, I am always looking for ways to streamline procedures and to minimize the chances of human error through automation. The discussion that follows shows a detailed example of how we use both Powershell and Confluence to produce high quality, accurate, and timely system status information for our campus customers.

Exchange Mailbox Status Reporting
The goal here is to provide our campus customers easily accessible, up-to-date information on the status of their mailboxes. Information such as current mailbox sizes per user, mailbox forwarding, time of last logon, etc.

to be continued...

more...