So I have some really old application servers. Six in production and the same number in test. Each server has a unique service that must be stopped in a specific order and then the IIS default website stopped before bringing down the servers (for patching, maintenance or whatnot.) Rather than going through the servers one at a time, I decided to create a little script to automate the shutdown, reboot and starting of services for me. Seeing as these are Windows 2000 servers, and the services are non-Microsoft services, they tend to be picky. So I added in a do-while loop to keep attempting to start the services until the service.status equals running. It was a fun Thanksgiving self made project that I’m sure no one will use but was a lot of fun to get working. Read the rest of this entry »
Archive for the ‘Powershell’ Category
Application Servers w/Services
Posted by superhumanben on December 8, 2009
Posted in Powershell | Tagged: Active Directory, Powershell, Servers, services | Leave a Comment »
New Distribution Lists
Posted by superhumanben on November 25, 2009
Recently I’ve had to create 100+ distribution lists at the same time. Each with a different owner. Rather than create each individual one at a time, I figured I’d throw together a quick Powershell script. It’s a very simple script for those who’re used to scripting languages but it’s my first without help and it just plain works. So I’m happy with it. Note however, you will need the Active Directory PowerPack to create DLs. We are running Exchange 2007 at my work so I also needed Microsoft Exchange Server 2007 SP1 Management Pack to create email enabled DLs.
$file = Import-Csv r:\Test.csv
foreach ($entry in $file) {
$null = New-DistributionGroup -name $entry.name -SamAccountName $entry.SamAccountName -type Distribution -ManagedBy $entry.owner -OrganizationalUnit $entry.Location
Set-QADGroup -Identity $entry.Name -Description ("Owner: " + $entry.owner)
Add-ADPermission -Identity $entry.Name -User $entry.owner -AccessRights "WriteProperty" -ExtendedRights "Self-Membership" -Properties Member -InheritanceType None
}
The greatest thing about Powershell is the logic just makes sense. In line 3, “-name $entry.name” calls to the CSV column named appropriately name. This corresponds directly to Display Name. SamAccountName corresponds to Pre-Windows 2000 name. The rest are self explanatory. See an example of the CSV below.
Posted in Powershell | Tagged: Active Directory, Distribution Group, Powershell | Leave a Comment »
Shortfuse meets Powershell
Posted by superhumanben on November 24, 2009
Well, I’ll give it one more chance before I give up on blogging all together. I’ve owned 2 websites and barely updated either. Shortfuse being my first, stood the test of time much longer than my short lived, utterly failed last attempt that will go unmentioned. Lately I’ve been digging myself into learning my first scripting language Powershell. I’ll post some of my scripts (edited slightly for work related secrecy) for any of my computer geeks to pick apart or use for themselves. And try to see if I can keep updating this thing again… time’ll tell.
Posted in Blog, Powershell | 1 Comment »
