Security for Apartment Dwellers

Introduction

I’m at the stage in my life where my wife and I are becoming empty nesters. My youngest daughter Anna is moving several states away to start a new life and I couldn’t be prouder of her.

As she’s been packing I’ve shared some security advice she can use at her new apartment. I got to thinking "hey, this is good stuff I should share it with others!" Next week I’ll continue my series on PowerShell Enums, but for this week let’s talk security.

By the way, this advice can apply to apartment dwellers, dorm rooms, or even rental houses. For simplicity I’ll refer to these as your home in this article, meaning any place you live in and rent.

The Need for Security

Whenever you rent, you are in someone else’s property. That means they too have keys to your dwelling.

And they use them. Exterminators come in on a regular basis to spray for bugs. Folks from the maintenance crew come in to check smoke alarms, air conditioning filters, and more.

Now let me be clear, I firmly believe that 99% of these people are good, hard working, and honest. But all it takes is that one bad egg to ruin your day, maybe even your year.

Some places provide notification in advance that someone will be entering your place of residence. But not all places, back when I was a renter it wasn’t unusual to come home and find a "your friendly neighborhood exterminator was here today" note on my door.

Or you may not know at all, one complex I lived in never told you, I only knew if a neighbor mentioned it.

A quick disclaimer before we get started: I mention several products in this post. These are not ads, I’m not making any money from these endorsements. I just like them and paid my own hard earned cash for them.

So that said, let me get into the suggestions.

Computer Security

Desktops

If you have a desktop computer, you should always lock your screen before you leave home. By locking your computer you’ll require the entry of a password or pin to use the computer. Most people keep all types of things on their computer.

Web browsers are often set to automatically login to email, financial, even gaming accounts. Family photos populate your drive. Important documents like tax returns are often scanned and stored on your hard drive.

On all operating systems there will be menu options to lock the screen, but there are also keystroke shortcuts that will allow you to quickly lock your computer.

On Windows, the Windows Key + L combination will lock the screen. This frequently works on many Linux distributions as well, although you should check your documentation to be sure.

On macOS, you can use the Ctrl + Command + Q key combination to lock the screen.

If you are on macOS, and have an iPhone, there’s a nifty app called NearLock. Actually it is two apps, one runs on your Mac, the other on your iPhone.

When your phone gets more than 3 feet away (you can change the distance in your configuration) it locks your Mac. It’ll also unlock your Mac when you get back into range.

I can’t stress how important this one tip is, because this is the situation where someone could steal from you and you wouldn’t know it. A bad guy could copy your personal info onto a USB key, and you’d be none with wiser.

Laptops – Cable Lock

If you leave your laptop turned on when you leave home, then follow the advice for desktops about locking your screen.

I’d also suggest getting a cable lock. This Kensington lock, found on Amazon is a good choice that I use, but there are many options.

Almost all laptops have a small slot the end with the lock will fit into, with the possible exception of some of the very thin laptops such as some recent MacBooks. Check your laptop to be sure before ordering.

Make sure you have a strong, secure spot to loop the cable through. A desk leg that you can just pick up and slip off the cable is a poor choice.

Some locking cables come with an adhesive hook you can use, but I don’t trust those. With just a little effort many can be easily ripped or pried off. But it is better than nothing.

Instead of the adhesive hook I suggest going to your local hardware store and getting an eye bolt with the hole big enough to get the cable through, or perhaps a handle that would go on a chest or garage door. Screw it into your desk, or even better the wall (assuming that doesn’t violate your lease).

Cable locks come in two types, a combination lock and one with a key. They key is faster to unlock, but if you are the kind of person who leaves their keys by the front door the combination may be more convenient.

The combination has another advantage if you share a laptop with your spouse or other family member. It’s easy to share the combination with other trusted people.

Note that many desktop computers these days also have the ability to have a cable lock. If not, you may be able to bolt a secure hook to yours. In addition to cable locks they also make cables with just loops on both ends such as this one from Amazon. Slip one end through the hook, then use a good heavy duty padlock to connect the loops.

Laptops – Lock it up

Another way to secure your laptop is to get a small, two (or more) drawer filing cabinet that has a lock on it. Plenty of space to store one or more laptops in.

A nice bonus is the ability store other valuables in it. Perhaps you have some nice camera equipment, portable gaming gear like a Nintendo Switch, and iPads or Android tablets.

Anything small but expensive could be placed in your file cabinet. I’ll admit, a determined thief could just carry off the whole file cabinet, or your desktop.

The security tips in this article are more geared toward the opportunist thief, ones who didn’t set out to take anything but when the opportunity arises they jump on it.

If you really wanted to carry it to an extreme, you could attach eye bolts or something similar to the file cabinet, desk, even the wall, then connect them using a steel cable with loops on either end like the one I suggested in the previous section. Use a heavy duty padlock to hook them all together. It will make the whole collection to big, heavy, and unwieldy to simply carry away.

Mail Call

If it wasn’t for junk mail I wouldn’t get any mail at all!

Well not quite, in addition to the stack of junk mail I still get bills (despite my best efforts to go paperless). These bills often have account numbers or enough information for a crook to hijack your accounts.

In my pile of junk mail I get credit card offers or "take out a loan with us with the low interest rate of 53%!" Of course this is annoying, but can also be dangerous as someone could take out a loan or credit card in your name, but changing the address to them.

Keep these secured in your file cabinet (you did buy one for your laptops, tablets, and other expensive stuff didn’t you?). One stack for junk, the other for bills and other info to retain.

You should always take time to shred junk mail with monetary offers, as well as bills when you are done with them. (Obviously you’ll also want a shredder to go with this setup.) If you want to keep copies then you can get printer/copier/scanners at reasonable prices and store on your computer. You know, the one you lock everytime before you leave home.

If you don’t want a scanner, just take pictures of these items with your phone. On my iPhone I use an app called Scanner Pro.

Not only does it take the picture but it also handles things like skewed pics, making the document nice and square (well rectangular for pieces of paper). If I’m only scanning in one or two pages, I use Scanner Pro rather than going to my multi-function printer.

I highly recommend getting an app like this for your phone. Feel free to post a comment with your favorite app, especially if you are an Android user.

Cold Hard Cash

I believe it is useful to keep a bit of cash on hand. You might lose or have your credit/debit card stolen and have to wait for a replacement. Perhaps there is an extended power or internet outage, and cash is the only way to purchase supplies.

Never leave cash laying around. Most crooks, even the casual opportunist, knows to check under the mattress or the underwear drawer in your dresser.

Use the file cabinet, or get a small safe. If you carry a purse, but sometimes leave it at home, maybe to go jogging, swimming, or other exercises, secure it in your file cabinet or safe when you are gone.

If you normally carry a wallet, but leave it behind for exercise or other reasons, lock it up as well.

Conclusion

After reading this you may think I’m a little paranoid. But remember, just because you’re paranoid doesn’t mean they’re not out to get you!

Most of these suggestions can be had for little cost, plus a few seconds of time, but can save you a lot of headaches and money in the long run. All it takes is one incident to ruin your credit, put you in debt, and deprive you of valuable, daily used tools like laptops and tablets.

Fun with PowerShell Enums

Introduction

This post begins a series on using Classes in PowerShell. As a first step, we will cover the use of an Enum, as enums are frequently used in combination with classes.

An Enum is a way to provide a set of predetermined values to the end user. This allows the user to pick from a finite list, and assure a value being passed into a function or class will be valid.

We’ll take a deeper look in a moment, but first let me mention that for all of the examples we’ll display the code, then under it the result of our code. In this article I’ll be using PowerShell Core, 7.2, and VSCode. The examples should work in PowerShell 5.1 in the PowerShell IDE, although they’ve not been tested there.

To run a snippet of code highlight the lines you want to execute, then in VSCode press F8 or in the IDE F5. You can display the contents of any variable by highlighting it and using F8/F5.

Basic Enum Declaration

Enum is short for enumerated value. As mentioned in the intro, it is a set of predetermined values that will ensure users of your script select a valid value required by your PowerShell code. Let’s start by defining a basic Enum.

Enum MyTwitters
{
  ArcaneCode
  ArcaneTC
  N4IXT
}

As you can see, the basic declaration is very simple. You simply use the keyword Enum followed by what you wish to name it. In the squiggly braces you list the valid values.

Here I’ve listed three of my Twitter accounts. The first is the main one I use, ArcaneCode. The second is the one I use for my company ArcaneTC (short for Arcane Training and Consulting). I use it primarily to announce new Pluralsight courses, so it doesn’t see a huge amount of use.

One of my hobbies is amateur radio, also known as ham radio. N4IXT is my FCC assigned amateur radio call sign I use to identify myself on the air. I don’t post a lot, I use it mostly to read through the latest news in the ham radio world.

Note that Enums cannot have spaces in their names, although you could use separators such as an underscore. Arcane_Code would be a valid value for an enum.

What are my valid Enum values?

You’ve now created an Enum, perhaps you’ve included it within a module you are providing to other programmers in your company. How can they retrieve a list of valid values?

Hopefully you’ve provided documentation, but it’s also easy for a user to have PowerShell return a list of values. First, make sure you have executed the code above by highlighting it and using F8 (VSCode) or F5 (PowerShell IDE) to get the Enum into memory. Then you can run the line of code below.

[MyTwitters].GetEnumNames()

Result:

ArcaneCode
ArcaneTC
N4IXT

As you can see, it simply returns a list of the values that we declared in the Enum.

Assigning an Enum to a Variable

Now we have our enum, and know what the values are. We’re now ready to use our enum in our script. Here I’ll just assign it to a variable, but we could also pass an enumerated value into a function.

Begin typing out the following code sample, and note what happens when you hit the second colon.

$tweet = [MyTwitters]::

When you have entered the second colon, you should see a list of the enumerated values in VSCode.

I say should as sometimes I’ve had VSCode return enums that were declared in my script, and not for the specific enum I was working with.

In the PowerShell ISE though, I’ve had it work right every time.

When complete, your assignment should look like:

$tweet = [MyTwitters]::ArcaneCode

Is it Valid?

So you have a value from the enum copied into your variable, $tweet. How do we test it?

It’s important to understand enums are objects. In addition to the values you provide they have a set of properties and methods you can use. In the previous example, you saw the GetEnumNames method being used.

Another useful method is IsDefined.

[enum]::IsDefined(([MyTwitters]), $tweet)

Result:

True

Into the IsDefined method you pass in your enumeration, then the value you want to test. Here our value is in the variable $tweet. If the value is contained in the enum, the method returns True.

What if the user passes in a value that is not contained in our enum?

$tweet = 'Invalid'
[enum]::IsDefined(([MyTwitters]), $tweet)

Result:

False

Returning False makes it easy to use an if statement and raise an error if the user tries to use an invalid value. For more on the if statement, see my post Fun with PowerShell Logic Branching.

Conclusion

For these examples we used my Twitter accounts for our enum values, but there are many more uses some of them extremely common. You could load an enum with the days of the week, months of the year, colors, and other common values your scripts might use.

In the introduction I mentioned we are starting our series on classes with the enum as enums are frequently used with classes. However this is not a requirement. You can use enums with any PowerShell code you want to write.

In the my next post we’ll continue exploring the enum. We’ll look at a few more useful methods, as well as see how to assign values to our enum values.

The demos in this series of blog posts came from my Pluralsight course PowerShell 7 Quick Start for Developers on Linux, macOS and Windows, one of many PowerShell courses I have on Pluralsight. All of my courses are linked on my About Me page.

If you don’t have a Pluralsight subscription, just go to my list of courses on Pluralsight . At the top is a Try For Free button you can use to get a free 10 day subscription to Pluralsight, with which you can watch my courses, or any other course on the site.

Solved: CMD Key Combos Not Working with Logitech K850 and MacOS Monterrey

Earlier this year I did a blog post, Working From Home – Permanently, in which I recommend using a good keyboard especially when you have multiple computers.

Since upgrading to MacOS Monterrey I’ve had an issue where some of the basic command key combos, such as CMD+X, CMD+V, CMD+C, and more were not working from my Logitech K850 keyboard. However, when I press those keys directly on my MacBook Pro they worked fine.

For those unfamiliar with it, the Logitech K850 will let you bluetooth connect to three different computers. It has three buttons labeled 1, 2, and 3 that will switch the input to a different computer.

This seemed to occur when I first powered up my MacBook. I’d go to do something and find my often used command key combos (CMD+C, etc) would not work.

The fix turned out to be fairly simple, what I needed to do is switch the input to another computer (using the 1, 2, 3 buttons). Once the keyboard was connected to another machine, I could return to my MacBook and find that the CMD keys worked like they were supposed to.

I’m guessing the K850 must power up in some default state in which it doesn’t realize it is in “Mac” mode. It isn’t until you switch from some other computer to the MacBook that it realizes “oh, hey, I’m connected to a MacBook so I’ll switch to Mac mode” and make the CMD key combos work right.

But that’s just a guess on my part, the important thing is if you are having the same issue, just switch the keyboard input to a different computer then back to the MacBook via the 1, 2, 3 buttons and the CMD key combinations should start working.

Note, in my testing I had to switch to an input that was active (i.e. to a computer that was powered up). When I switched to an unused input (not currently connected to a powered computer) and back it didn’t always work right.

No Fun with Slow Internet and Big Downloads

I’m taking this rare opportunity to post a bit of a rant.

I live in a rural part of the country. It’s a beautiful area, lots of woods, nature, a very quiet area.

With that comes some downsides, including slow internet. My home speed is a blazing twelve megabits. I have a relative’s house I work at in another part of the state, there the internet is a mere three megabits.

At the same time, software updates seem to be growing larger and larger. The most recent update to Apple’s XCode was over twelve gig. There is a video editing package called DaVinci Resolve that regularly puts out two gig updates.

These take incredibly lengthy periods of time to download at my home, assuming the connection doesn’t drop or reset mid-download. I wind up going to coffee shops or the library where there is faster internet that allows me to receive these large updates. Even in these locations the fastest speed is one hundred megabits, shared among all its users.

I’m not the only person in this situation. At conferences (back in the pre-COVID days when we had them) I often spoke with other attendees who lived under similar circumstances.

Of course, the real solution is to get faster internet to our rural communities, both here in the US and worldwide. Much of our planet is dependent on the internet for communications, business, and more, to the point where it is becoming a necessity.

Unfortunately, infrastructure is not cheap, nor is it quick to roll out. So, until that happens, I’d really like for software makers to remember those of us with slower connections.

Instead of multi-gigabyte updates, I’d love to see software makers create smaller patches for their software, instead of a basic complete reinstall of the applications. Yes, it would require more testing, but would result in lower demands on their corporate servers and bandwidth.

Perhaps if others across the planet joined our voices it may have a positive effect, both in reducing download sizes and in getting a meaningful truly high-speed internet infrastructure in place.