Category Archives: PowerShell

OSD – HP Driver Tips

Working on certifying drivers for some older model HPs in the shop. My options are:

1. Use Mikael Nystrom’s PowerShell is King – Export drivers from Windows good stuff if you have a box already configured how you want and it’s not Windows 7

(do a get-command export* and you'll see you can't use export-windowsdriver in Win 7)

(do a get-command export* and you’ll see you can’t use export-windowsdriver in Win 7)

Good Windows 7 Options:

2.  If you get stuck installing a driver as an application, check in Program Files/Program Files (x86) for the unpacked files to see if an .inf was dropped there.  Be careful pulling the .inf file as some of the softpaqs need the software stack to work properly (see method 4 below for this scenario).

Found the driver for bluetooth in this folder in Program Files (x86)

Found the driver for Bluetooth for a ZBook in this folder in Program Files (x86)

3. If HP, I generally find the majority of the unpacked files in c:\swsetup and then I search Program Files.

C:\SWSetup is a common unpack directory for Support Assistant and manual installs.

C:\SWSetup is a common unpack directory for Support Assistant and manual installs.

4.  Another HP trick is to use the HP Softpaq Download Manager.  Once you load up the model you want, you can right click on any of the given drivers to get the fly out menu and select cva file.  If it exists, it will give you install + silent install instructions for those pesky drivers that need to be installed as applications.

Using HPSDM to get the driver package and install instructions.

Using HPSDM to get the driver package and install instructions.

Install instructions are in a cva that you open with notepad - then scroll to the install section.

Install instructions are in a cva that you open with notepad – then scroll to the install section.

A fun tip about the cva file is if you know the softpaq number, you can just find it in this URL  (this only works if there is actually a cva – not everything has one – but better than nothing, right??)

Find text using PowerShell

I totally broke the setup of a non ConfigMgr system that I’ve been tasked with setting up.

Oops, I did something wrong!

Oops, I did something wrong!

Some how, in some way, I hard coded the TEST SQL server/database rather than the PROD SQL server/database into a config file.  The bigger problem was that this is a system I had never heard of  until a few days ago, so my only hope was combing through logs to find my error.

Log files always have the answer ;)

Log files always have the answer 😉

Once I found it, I started clicking through the install directory only to see there were too many config files and folders to know where to start.  I had two options, open every file or find it in PowerShell.

Here’s what I came up with to find what I was looking for:
dir "C:\program files\Ami FP Test" -I *.* -R | select-string SQLTEST
Sure enough, here’s the very config file where I made the mistake.

PowerShell is KING!

PowerShell is KING!

Found my mistake!

Found my mistake!

Hey, Scripting Guy has a more “pretty” and correct way of using this same method and you should read it.  But if you’re new to PowerShell, I want you to know that if it works, it doesn’t have to be pretty.  Use what works as your base to learn better ways to do things.

Exchange Powershell 1/18/2016

I was tasked with the old “give me a list of all the active users by office and their mailbox stats”. Easy enough, but I’m a bad admin (falling on the sword for those who came before me and also those who sit next to me – you’re welcome and you owe me a beer.), so I don’t really have all of this broken down by office OU. What I DO have is a distribution group for each office which reflects current staffers so here’s how I did it:

get-distributiongroupmember ‘fake list’ |get-mailboxstatistics |export-csv c:\fakestats.csv

 

You can actually do a lot with get-mailboxdistributiongroupmember.

For example, you can grab just their email address and mailbox size and send it to your csv (or show it on screen by dropping the |export-csv bit)

example:

get-distributiongroupmember ‘fake list |select primarysmtpaddress, totalitemsize |fl c:\fakestats1.xls

 

BUT totalitemsize always returns blank (which is why I just used the original csv to hand in as my work and called it a day.) However, if you know anything about me, it became a personal challenge to actually do it the “right way” or better documented way or whatever you want to call it for the next time somebody calls on me for such an annoying list of information.  So, in the spirit of stealing with pride, I found a nice script and modified it to match the fact that I want to return info on a distribution list.

get-distributiongroupmember ‘chicago staff’ | get-mailboxstatistics |add-member -membertype scriptproperty -name totalitemsizeinMB -Value {$this.totalitemsize.value.ToMB()} -passthru | format-table displayname,totalitem* |out-file c:\fun.xls