I was super excited to find an article about a week or so ago about how to reduce the Windows 10 footprint on your computer.
Now, those of you that have been listening to me for a while may know that I have a problem — well, many problems. But one of the problems that I talk about a lot is my addiction to adorable little tablets.
And, without exaggerating, within arms reach that I could touch — without stretching anything —one, two, three, four, five Windows tablets and two other little devices, stand alone HDMI devices that run Windows 8 and 10 and all that.
I Upgraded All of Them to Win10
What I liked best about a couple of these devices was their price. They were cheap, $79 dollars, or $100.
I also I like them because they have small drives. Some of them have 32 gig drives, some of them have 16 gig.
They all came with Windows 8.1, which had this feature called WinBoot, which used your recovery partition as your Windows partition. That was pretty ingenious because it lets you use that space twice.
But what it didn't handle updates very well. You could never update that WinBoot Part, so, as windows updates came out, the little devices just kept getting fuller and fuller until the 16GB drive filled up.
For Windows 10, Microsoft removed WinBoot. It's not there.
Small and Bloated
There are a couple of different things they do to try and size down. But I have a couple of these 16GB tablets that keep getting full. So I can't download all my pictures of cats doing funny things and all that. the drive gets full.
So I ran across this article last week about how to reduce your footprint, and it's working pretty well so far.
It all hinges on using the compact command. You may remember the compact command from operating systems such as Windows 8.1, Windows 7, probably Windows NT.
"COMPACT" is the command you use from the command line to compress files, and it's been around forever. New in Windows 10 is a switch compact OS.
What Does the Switch Do?
It does exactly what you think it will do. It goes through and compresses the OS files for your operating system.
So the slash compact OS has a few switches that you can run. The first one I ran -- well, I did a /? first to see everything in the new switches.
But then I ran one called "compact OS query" and that tells you the state of whether your OS has been compacted or not.
Mine says, “The system is not in the compact state because Windows has determined that it's not efficient for the system.”
This system has a C: drive that has four GB free on it. If anything was ever a candidate for a compact state, it’s this machine.
So I decided to just drive ahead because then again, if I kill this tablet, if I screw this tablet up, I've got like four tablets within reach that I can replace it with.
I went ahead and did the upgrade and gave it a "compact OS: always." The machine stated churning through and compacting the OS files. It said the stuff that I read online would take 10 to 20 minutes.
This is a box with a 16GB drive, 2GB RAM,and Intel3735F processor, one of the slowest machines known to man.
It took about an hour for this thing to run. When it got through, it had compacted 22,000 files, and saved me a little over well, almost 2GB space. So I went from having 4 something to 6 something.
Saving 2GB of space on a 16GB drive is pretty good. At the end, it tells me the compact ratio is now 1.6:1, and when you do some of the other commands it's 1:1.
Good News Folks
We’ve now got a machine with restricted hardware, a weak processor, crappy RAM, just a lot of things working against it.
So lets say I compress all of this and find out that it just can't keep up, that the decompression of the OS is too much for it.
No problem. I can just go back up and set that "compact OS:never" and it will decompress all the files and move them back to the way that it was.
So, if you've got some of these little devices — I plan on running it on a few of them to see how much it helps — but if you've got one of these with small amounts of hard drive space, or if you've got a full machine but have an SSD in one, you can get a couple of gig back.
You can do the regular cleanup stuff, too. This is just another level, a way to get some space back. So, that was a good one. I’ll be curious to see if you guys have tablets out here, if you use that this and how it works for you.
A couple of weeks ago I started the PowerShell Tip O’ the Week, and I don’t want to skip it this week.
To recap, last week’s Tip O’ the Week was adding parameters to your PS1 files. And I don't think I mentioned that tip will also tie into podcast 260, where I talk about snippets inside of the ISE.
So, if you're wanting to do the parameters in your PS1 files, like I talked about in podcast 262, you can use the snippets that I talked about in podcast 260 to get that framework set up for you.
The tip that I want to mention this week is about error checking, and that it's something that none of us do well enough — in our PowerShell scripts, in our programming or any of that.
So one of the next frontiers I've been tackling with my PowerShell scripts is putting in more error checking. That can be kind of tricky. We all know of different tricks, but getting them all to work at the same time is kind of tough.
To Block or Unblock
One of them I keep having to learn the hard way is the difference between a blocking and an unblocking error. We’ve all seen this: you've got a bunch of PowerShell, and sometimes when a PowerShell command doesn't work, it just kills your script dead.
Splat!Red text all over the screen, and everything just grinds to a halt.
That is a "blocking error." But sometimes, when the command fails, it throws red text on the screen but just keeps charging on.
Normally, that command is important, or you wouldn't have had it there in the first place and then the rest of you script failed or more bladdy bladdy blah.
That’s an unblocking error. It's not blocking the rest of the program.
Those unblocking errors get tough to do error checking on because they don't stop the program. So it's tough to get things wrangled and error out gracefully.
PowerShell Tip O’ the Week
Today’s PowerShell tip of the week is to kind of read up about the difference between blocking and unblocking errors.
Again, an unblocking error is one that you want the program to stop, but it doesn't stop and it keeps going.
The thing that you can do to handle that, is, at the end of the command, every PowerShell command has a bunch of default parameters. One of them is Error Action and that tells the cmdletwhat to do if there's an error — Continue Normally, Silently Continue" or Stop.
That’s how you can turn this unblocking error into a blocking error: by giving it "-ErrorAction: Stop." That will bring your script to a halt, and lets you do some error checking on it.
Hungry for more from Podcast 263? Sit back and watch the podcast or just listen.
Title image by hang_in_there
Learn how you can join our contributor community.