Use Powershell to Append Data to an Excel Spreadsheet

As you learned in my previous post my client has a change management process. It includes filling in forms in a PDF and appending a row to an Excel spreadsheet. Here’s the code I’ve used to append to the spreadsheet. This was pretty straightforward other than finding the first row to add to and stopping the Excel process. This spreadsheet has a border around all the cells. The Excel COM object treats this as being “in use”. This means you’ve got to get the value of the cell “in use”. If it’s $null, then I know there’s no text in it. When I went to close the COM object, excel.exe would never stop. This is why you see three different ways of killing it off; the Quit() method, releasing the COM object and finally I just kill the process completely.

Read more

You Can Use Powershell to Fill Forms in a PDF

Whenever I first started using Powershell, I thought it’d only be used for IT admin stuff. I was expecting it to manage Windows services, start/stop computers, add users to Active Directory, etc. I didn’t even fathom doing other routine tasks like filling in PDF forms. It just goes to show you expect the unexpected with Powershell. Here’s a script I created to automate making a change request in my client’s environment. They have a pretty rudimentary process that entails filling out a PDF and then adding a row in an Excel spreadsheet. I wanted a single place to do both of these tasks so I decided to write a quick script. This is the piece of the script that fills in the PDF fields. I could never have even attempted this if it weren’t for the iTextSharp PDF library. The library did all the heavy lifting. I was just a […]

Read more

Here Is Why You Should Automate Your VPN Connection

I’m lazy. I don’t want to do anything twice, and if you read my blog I have a feeling you’re just as lazy as I am. I’ll automate anything! Here’s a prime example. Rather than waste 30 seconds of my time every day when I VPN into my client’s site and fire up remote desktop, I want to do it with a script. All this script does is connect to a VPN gateway then connect to a device via remote desktop. It’ll save you 25 seconds of your time every day, but it’ll easily save you an hour’s worth of time over the year! I use this with the older Cisco IPSEC VPN client so I make no guarantees with other VPN clients. To prevent typing in your RDP password every time, save your RDP credentials to a file.

Read more

Managing a Write Filter Remotely

I manage around 900 thin clients in my client’s environment. They’re mostly all hpT* models. Recently, a policy was implemented to ensure the enhanced write filter (EWF) was disabled on all of them. Rather than loading up HP’s way of doing this through HP Device Manager I decided Powershell could do the job just as well. I also didn’t have to load some bloated software on a server somewhere! HP has an EXE called ewfmgr.exe that manages the write filter locally. However, there’s no way to natively do this remotely. I wasn’t about to remote to the console of 900 thin clients and run the command. Powershell to the rescue! I decided to write two extremely simply cmdlets to get the job done. 95% of this code is just setting up the cmdlets. The real meat simply uses Sysinternals’ tool PSEXEC to kickoff the ewfmgr EXE and report back the […]

Read more

ConfigMgr: How to Find Failed Packages with Powershell

I try to take 1 day out of the week to manage the health of my SCCM infrastructure. One of the activities I was doing every Monday was checking the status of each package. If it failed, I’d then have to check the distribution point that it failed on and troubleshoot why it failed. It was extremely time consuming. One of my ongoing projects is to automate the majority of this infrastructure health check. This one-liner is my first contribution. This is an extremely simple one-liner. However, the problem was not writing the script; it was finding out where the data I needed was stored in WMI. Luckily, with a little help from this MyITForum post I was able to make it happen. I haven’t changed it up much from that post but what I did do is simply output the package ID and the DP that the failure occurred […]

Read more

I Don’t Have Time to Learn Powershell

Why Do You Need to Learn Powershell? We’re all busy.  I get that.  IT professionals wear many hats.  We’re always going around putting out fires in between the projects we’re trying to work on.  I understand you’re busy; I really do!  However, are you too busy to work on furthering your career and developing more advanced skills?  That may sound too pie in the sky for you but it’s true.  You’re busy in the now but if you’re like many of us you’re not busy in the 5 years from now and don’t realize that until 5 years IS now.  By that time, it’s too late.  Look at this Google trend and tell me how successful you’d be with Powershell 5 years ago. Us humans are hard-wired for an action/reward system.  We all don’t like doing something that we can’t see an immediate reward from.  Sticking to the theme of this blog, Powershell, […]

Read more
1 26 27 28