Today I just wanted to write a quick note about how to authenticate to a proxy within a Powershell script. Most corporate networks have proxies, and most also require authentication. The problem is, if you try to connect to any Internet resource, such as installing a Powershell module via the Install-Module command or downloading a file or other info from a website, you may see something like this: Continue reading
Category: Powershell
Getting IP Network Information with Powershell
Those of us that have tried to manipulate IPv4 information in Powershell know that out of the box, it isn’t the easiest thing to do. Problem is that in calculating IPv4 information such as broadcast address, network address, and host range properly, you have to manipulate it in it’s 32-bit form, and not its integer format.
After having to do this the hard way a few times, I decided to write a script that I could use for a wide array of scenarios to get this information, and now I’m passing the time savings onto you! Continue reading
Convert Julian Date to Gregorian Date in Powershell
So the other day I was presented with the issue of converting a Julian Date (YYYYDDD) to a Gregorian Date (MMDDYYYY). After a few minutes in Powershell I realized that there was no built in way to do this. A few minutes a Googling yielded a few long, bloated scripts. I knew there had to be a better way, and there is!
Working with Scheduled Tasks in Powershell on Windows Server 2008
Windows Server 2012 / Windows 8 and above include some nifty Powershell cmdlets for working with scheduled tasks. However, when the need arises to programmatically work with them on older OS versions, mainly Windows Server 2008 , try out the code below.
Testing For an Array in Powershell
I’ve seen lots of methods for checking whether or not a variable in Powershell contains an array. All of them work, so really it comes down to which one is the easiest. Some cmdlets and constructs will error out if you treat them like an array, or more commonly, produce unexpected results. Here are the two methods I’ve used for this over the years, I’ll let you be the judge of which one is the easiest.
Debugging Powershell Scripts for Orchestrator 2012
Let me start by saying I love Powershell. It’s a extremely powerful and strangely fun language to code with that can make virtually any aspect of my day faster and easier. Along those same lines I love Orchestrator, because it can take those tasks and automate them. You can even integrate your runbooks with something like Service Manager Self Service Portal to offer delegation of your automated tasks to other users so you don’t spend your day running reports off of scripts you wrote or some other tedious task.
With all of that being said, writing Powershell scripts that work as expected with Orchestrator can be a pain, unless you’re running a 32-bit Windows 7 machine, more on that later.
Load Balancing SCOM 2012 Agents
So we’ve recently stood up SCOM 2012 and after weeks of planning we deployed it into our environment. We used SCCM 2012 to push out clients, which isn’t as well supported as I would like, considering they’re sister components of Microsoft System Center, but I digress. Our application deployment in SCCM pointed to one of our two management servers, which rapidly began to fill up with clients, while the other management server sat idle. I wasn’t about to start moving clients manually, so I set out to automate the process of load balancing agents between management servers on a nightly basis.
Automating Orchestrator 2012 Runbooks with Scheduled Tasks
I was recently faced with the challenge of having some Orchestrator 2012 runbooks fire off on a schedule, mainly for custom Active Directory reports that other teams want to receive on a regular basis. Since the days of doing such tedious tasks manually are (thankfully) long gone, I decided to use Orchestrator to automate the creation and distribution of these reports.
The Problem
While it’s a fairly well known fact that Orchestrator has this ability built in via the Monitor Date/Time Activity, I have a hard time stomaching the fact that the runbook has to be running all the time just for its five minutes per week to be useful. So naturally you think about scheduled tasks, but they you have to write a Powershell script for every runbook you want to automate, then create a corresponding Scheduled Task, label it something useful, set it up, test it, and so on. I also considered launching all periodic runbooks from a master scheduler runbook, which wasn’t a bad idea, but everytime I wanted to add another report, I would have to rework this master runbook which would eventually swell to a Krakken-esque monster of lines, activities, data passing, and other headaches.