Securing Passwords with AES in Powershell

Securing credentials can be a difficult issue for your scripts. While this method may not be the best its worlds better than just placing plain text credentials directly in your script. Note, that there are other methods that may be more appropriate depending on the situation.

Read more...

Event Logs with Powershell

While troubleshooting an issue I had the need to use a login script to modify some services available to end users. I also wanted to log status of, and changes to the device that the script made. The logical place for this would be to write to the windows event log.

The first step is to register an event source with windows that we will write the logs to.

Read more...

Monitor DHCP Pool on Cisco WLC

I needed to monitor the pool utilization on the internal DHCP server for a Cisco WLC but couldn’t find any good documentation on how to pull this information. I’ll skip the story of how I found it but if you do an SNMP walk on 1.3.6.1.4.1.9.9.193999.0.4.1.1 you should get back an output like:

Read More...

Faster querying of AD for null fields

For a while now I’ve been running a task that required me to query AD for all accounts that have any value in the ipPhone field.

My first idea was to run the following command.

Read More...

Auto Prompt for Credential using Profile.ps1

Like many I have two user accounts on my domain. My regular user that does all my user things, login into my PC, check my email, etc. and my superuser account that I use for administering servers. This poses a little annoyance, that every time I try to do something awesome on my desktop in powershell I have to provide my superuser credentials.

Read More...

Tracing Network Cables with CDP

Over the years I have more then once found myself in the position of needing to trace a cable/jack back to the switch its plugged into. Often this is because the label is missing, wrong, illegible or simply never existed. There are a number of ways to do this and every method has its pros and cons. But if you happen to be in the lucky scenario where 1. the cable is plugged into a switch and 2. the switch speaks CDP you can use this to your advantage.

Read More...

Count Mailboxes in all Exchange Databases

I was looking for a quick way to return the total count of mailboxes in each one of my Exchange 2013 databases. I jumped on google and came up with this line on several sights.

Read More...

Setting and Removing the ipPhone field with Powershell

We currently have a project going on that requires we populate the ipPhone field of several hundred users. Sounds like this should be a simple call to Set-ADuser like this:

Read More...

Copy OU Structure between domains

In the process of building a new domain to run in parallel to our existing one for a re-branding project we needed copy parts of our OU structure. In our scenario the site is broken into buildings, rooms and occasionally smaller units. Accounting for hundreds of nested OUs. That would be a pain to build by hand.

Read More...

Log Cleanup with Powershell

It’s a very common task to need to remove all files in a path older then a number of days. Because of this there are countless methods to accomplish this task. Since I’m on a Powershell kick I decided to toss one together to handle a little log clean-up I needed to do. The goal is simple, given an array of paths delete any file that is older than the specified date and while we’re at it delete any empty folders.

Read More...

Using Powershell to Send an Email

A few months back I switched jobs, I decided this was as good of a time as any to switch from using vbs to do my scripting to using Powershell. One of the first things I was looking to do is have my scripts send out an email for one reason or another.

Read More...

Here be dragons, or a footer. Both work.