Testing Ports are up
As usual, some more requests came to me, this time for soem monitoring, once again I took a look at the Script Centre and the Script Repositiory and found this very amazing cmdlet: http://gallery.technet.microsoft.com/scriptcenter/97119ed6-6fb2-446d-98d8-32d823867131
This is wonderful work as it allows you to not only test TCP ports, but also UDP ports. I will post up my monitoring script based upon this shortly.
FQDN to IP
I needed to make a script resolve an hostname (FQDN) to the IP address, my first stop for most of these sorts of scripts is the Microsoft Script repository, where I found a lovely function to do just that!
Check out Get-IPAddress at http://gallery.technet.microsoft.com/scriptcenter/44e9fef7-a04b-40b3-bb05-97659e56e27e
Cheers out to Ben Wilkinson for his great work!
Incomming! lots of Powershell!
I have a small fleet of scripts to post in the coming weeks.
I am not posting them in full as that will take too much space, I may put some of these up in the download section but need to clearance to do so first.
For all the posts I have used my standard template that I have discussed previously and is available for download (here).
When I post the code there will be two sections
Parameters:
If i needed to add extra parameters from the default ones, they will be listed here.
Body:
Code here is in the body of the script and does the work
Infrastructure Saturday
Just a quick post to let everyone know that I will be presenting at this years Infrastructure Saturday (infrastructuresaturday.com).
You can see my session at: http://www.infrastructuresaturday.com/session-details/
Understanding PKI and Certificate Services
Speaker: Kieran Jacobsen http://aperturescience.su
Level: 200
In every organization there is a growing need for a strong well designed public key infrastructure solution and in many of these, Active Directory Certificate Services will be used. This session will guide you through a solution based on best practice, shed some light on common issues encountered and some shortcuts to assist in management through the use of PowerShell.
Regular Expressions in Powershell
As part of a script I am working on, I needed to parse some web content which was stored on a remote server; in this case, I needed to scrap a particular set of web links of the page and report back.
The best way to get content of the internet from within a script is wget, which from within Windows you can make use of the GNUWin32 project. I will post about how useful this project is to Windows Scripting and administration later!
Back to the topic at hand.
After getting the content from the web and saving it as a file, I then put the content into a variable using Get-Content, from there, searching the content was pretty easy. First you need to make a RegularExpression.Regex object, and from there, you can feed any string into that object, and it will return the matches.
For Example:
Server Timezone Script
Time for another one of my quick powershell scripts.
This script was created because we discovered we had servers at the Brisbane site, who were running with Daylight Saving time, and also found some servers in Sydney who were not.
For a list of computer names, this script will check that the timezone is "Brisbane" and output the ones who are not to a file.
Creating 1.5 million users in AD
Ever needed to create A LOT of user accounts?
Try this script: (uses Quest CmdLets)
Service Monitoring and Recovery with PowerShell
Recently, Symantec Backup Exec was crashing quite regularly on me.Every Saturday at 4am, the main Backup Exec service would coem crashing down, taking the weekly backups with it and then causing my Monday morning to be painful (unless whoever was on call managed to see that the backups had stopped).
I know that this sort of monitoring should be done with something like SCOM, but that wasn't something I could do in this situation.
The solution was a PowerShell script running hourly (or more or less depending on the needs) that would look at the running state of all the Backup Exec services and start any that were not running, as well as send the person on call an email to tell them something bad was happening.
Using my standard template (see previous postings), I added one parameter to the script, $query, which is simply the query string that I would pass to get the services I want to monitor. For example, a query string of "backup*" will return all the Backup Exec processes, a string of "spooler" would return the print spooler.
The body of the script is pretty simple: