Copilot Experiments: A little PowerShell help

It’s been a little while since I’ve had time to relax a bit and try some AI help. This is another experiment I made.

A user on SSC asked about PowerShell to copy files with a date appended.

This is part of a series of experiments with the ChatGPT and other AI systems. Lots of Copilot lately.

I added some code to a new file and typed a prompt:

2023-07-31 14_57_41-● copyfiles.ps1 - sqlsatwebsite - Visual Studio Code

If I run this, it does work. Sort of.

2023-07-31 14_58_51-fileloading

It made a folder copy, not a file copy. However, the filter worked.

2023-07-31 14_58_58-fileloading

Let’s try again. I’ll modify the prompt and get Copilot to explain what it’s doing in the code. I get this:

2023-07-31 15_00_59-● copyfiles.ps1 - sqlsatwebsite - Visual Studio Code

Which works:

2023-07-31 15_01_04-fileloading

Hmmm, can it do what I want.

I tried a few prompts in the code window, but I kept getting things that wouldn’t work, like call copyfiles.bat, or something that didn’t work.

Let’s move on.

Copilot Chat

I got access to the Copilot Chat as part of Redgate. There is a new chat extension to add to VS Code, which I did. I opened it and got this with my prompt:

2023-07-31 15_05_17-● copyfiles.ps1 - sqlsatwebsite - Visual Studio Code

Good, this code will copy the files, but does all of them.

2023-07-31 15_07_23-fileloading

One advantage of AI bots is I don’t need to start over. I did this:

2023-07-31 15_08_04-● copyfiles.ps1 - sqlsatwebsite - Visual Studio Code

This worked correctly.

2023-07-31 15_08_38-fileloading

This was a simple example, but it produced about the same code as I did, albeit slightly cleaner. Mine was this:

$source="c:\fileloading" #location of starting directory
$destination="c:\filecopy"; #location where files will be copied to
$files="*dys_ihhist*" #files matching this pattern

# write a powershell command to get a list of files in $source matching the $files pattern
$a = get-childitem $source -filter $files
$a | foreach {write-host $($_.basename)-$(get-date -f yyyyMMdd)$($_.extension)}

# write a powershell command to copy files from source to destination appending the date to the filename
$a | foreach {copy-item $_.fullname $destination\$($_.basename)-$(get-date -f yyyyMMdd)$($_.extension)}

I don’t know enough PoSh to know which is really better. And honestly, I don’t feel like testing at scale. Let me know if you have knowledge here.

However, the chat window for copilot produced this quicker than I did, without me having to try and remember the PoSh parameters and structures of the functions. I had to dig around on SO to remember basename was what I needed and look up the parameter for get-date.

The code window isn’t great, and partially I think because I don’t know how to get prompts to work in the comments, but I do like the chat window. I’ll keep playing.

Posted in Blog | Tagged , , , | Comments Off on Copilot Experiments: A little PowerShell help

Flexible Work Policies are Preferred

The great post-pandemic, post-Great-Resignation, hybrid/remote/in-the-office work debate continues. It seems almost every week I see more stories that report on, hype, attempt to prove, or otherwise stoke emotions about whether the future of work for many people is more likely in any of these three situations. One company mandates everyone back in the office, another goes completely remote, and it seems many can’t decide and have some sort of hybrid approach.

Your boss might have strong opinions on one of these situations, which may or may not align with your organization. I see CEOs wanting one thing and individual managers sometimes wanting another. As much as I like remote working, and I’ve been based out of my home for over two decades, I also like seeing people and I am regularly traveling to the various Redgate offices (along with Grant and Ryan).

If you want to try and sway your boss to let you work more flexibly, which is likely remote or hybrid, perhaps this article will help. There’s research from at least one company showing that having a flexible policy has helped a number of companies hire faster in 2023. While this isn’t in any particular geography, industry, or role, it does show that finding employees seems to be faster with flexible policies. That makes sense as the more remote you are, the more people in your pool of potential candidates.

Of course, this doesn’t say if these people stick around, or if they’re qualified. Certainly many of us in the tech industry see plenty of candidates (or even coworkers) that don’t seem qualified for many, or any, roles. Hiring faster isn’t always good if there aren’t good candidates, but having more choices of who to hire does give you an edge in finding qualified candidates.

It also gives you more work to do in separating those you’d consider hiring from those you wouldn’t. The flip side as well is that if you are flexible, then perhaps you can convince some already employed, talented workers to come to your organization.

To be fair, many of us with these options are very lucky. There are lots of jobs where this isn’t a debate and people must show up to work every day. Cooks, taxi drivers, retail workers, and many, many more. This is a luxury issue, but it is still an issue. My view is that lots of knowledge work can be done remotely. However, I also think that teams gain something when they bond and get to know each other in person. Day-to-day work is great remote, but brainstorming and creativity work better sometimes when people are in the same room. Not always, but there are times it is better.

So let your boss know that they might be able to better fill their open positions if they’re flexible. Maybe you’ll convince them to be more flexible with you as well.

Steve Jones

Listen to the podcast at Libsyn, Stitcher, Spotify, or iTunes.

Posted in Editorial | Tagged , | Comments Off on Flexible Work Policies are Preferred

A New Word: Idlewild

idlewild – adj. feeling grateful to be stranded in a place where you can’t do much of anything, which temporarily alleviates the burden of being able to do anything at any time and frees up your brain to do whatever it wants to, even if it’s just flickering your eyes across the passing landscape.

I get to do this regularly. I’m often stranded in planes, trains, cars, etc. where I can’t do anything. Even in airports. Certainly I could work in some of those situations, but I also recognize the fatigue I feel and the need to relax and try to take care of myself.

The drive from LHR to Cambridge is a little over 2 hours (sometimes more). When I get a car, and I’m not too tired, I can sit and watch the world go by. Sometimes thinking of things, sometimes letting thoughts just flip through my head.

From the Dictionary of Obscure Sorrows

Posted in Blog | Tagged , | 2 Comments

Things I Carry in My Travel Bag

A friend asked me for some travel tips and ideas recently. One of their questions was on what types of things do I actually carry on the road, both for work and personal trips. Since I travel a lot, 18 trips so far this year, I decided to list out a few products that I’ve found helpful and why.

One thing to note is that these are things permanently in suitcases or laptop/backups. I have separate items at home and never mix the two. That’s a good way to inconvenience myself somewhere.

Cables and Adapters

Number one for me are multiple cables and adapters. Many of us live with devices and keeping them charged when you’re busy and moving can be a challenge. Here’s a few things I keep around:

  • USB A and C Fast Charger – I started carrying two of these around since modern devices use lots of power. I keep one in my carry on and one in my roller, so they’re handy if I’m in a hotel, gym, or a convention center.
  • USB-C cables – I’ve found these long ones to work well. I have multiple ones, usually 3 foot and 10 foot lengths in my carry one and a 3ft and a 1ft one in my carry on. I find these die periodically, so I keep spares in bags. Home has separate cables
  • Garmin Watch charger – I have a Garmin, and this is a weird cable, so I have one at home and one in my carry on. My wife has a Samsung one and I’d certainly keep a spare Apply Watch charger around if I used that brand.
  • Worldwide power adapter – I’ve used a few iterations of these over the years. Not sure if it’s always this brand, but I’ve used this style for nearly 10 years. It’s been great to be able to plug in multiple things. In airports, I’ve even gotten someone to let me have the plug and they can plug into my adapter along with me.
  • Power Banks – I carry two. I used to have a third, but I gave this one to my wife. She loves it. Now I have one of these large Anker ones and a credit card sized one. The big one is for airplanes or airports or anywhere I can set it down. Handy when power plugs in planes don’t work or I’m at some event. The credit card one I carry in my pants, and it’s small and light and doesn’t bug me. It also doesn’t do a lot of charging, but it’s for emergencies.

Clothes

I’m a casual traveler, and I don’t need to worry about slacks and suits. However, I do often find myself away for multiple days, and I want packing simple, so I have a couple things.

  • laundry bag – I usually try to just pack what I need, but sometimes I have extra clothes. This is a great bag that lets me stuff worn (or sweaty) stuff into a separate bag. Plus, if I do laundry on the road, it’s handy to carry clothes around outside a suitcase.
  • packing cubes – The jury is out if I want more of these, but I got these three small ones. I carry two permanently in my suitcase and stuff one with socks and one with underwear. It keeps those small items together and easy to access. I pull these out in hotels and set them in a drawer, quickly letting me store them and access them.
  • clear toiletry bags – One of my best tips is to keep the health and beauty stuff you need in your suitcase. At least if you travel more than a few times a year. I can’t tell you how often I’ve forgotten something I need. I keep two of these in my bag: one for wet things, one for dry. Wet is contact solution, spare contacts, tooth brush, toothpaste and shampoo (wrap that in a zip lock). Dry is my razor, deodorant, electric razor, batteries, nail clippers, etc. Easy to grab these and drop them in a hotel bathroom and easy to pack them up and put them in my suitcase.
  • gloves – I never know if the weather in a remote city might be unpredictable, so I carry gloves, just in case. I have these, but pick your favorite pair and leave some in your bag.
  • hat – I don’t have this specific one, but I keep a couple in my bags, usually one in the carry on and one in the roller. I’m lacking hair, so I find I need these if it’s colder than expected. In the past, I’ve usually purchased one of these on a trip, so I carry a Norway one in my laptop bag and an Alaska one in my roller. Usually I’ve stuffed a UVA one in a jacket as my Mom has gotten me a few of these.
  • Windbreaker – I keep one like this in my roller, in one of the front pockets. Handy if I’ve forgotten a jacket, or it’s rainy.
  • Umbrella – I have a Redgate one, but I think a small one is helpful to have to cover yourself, your gear, or a friend.

Misc

These are random things I tend to keep with me.

  • notebook and pen – any old notebook for me, but Andy and my daughter like Moleskin. A few pens as I find taking notes to be easier on paper and it helps me remember. I don’t take a lot of notes on the computer when I’m doing something in person.
  • swim goggles, towel, and swimsuit – Pick your spare suit and add it. I don’t often use a pool or hot tub, but I do sometimes swim when I’m near the ocean or a big pool. Laps are relaxing to me and I’ve swum outside at the Rose Bowl and Jesus Green. The towel is also handy if I need one, especially in a cheaper hotel where their things might not be clean (ugh).
  • medicine – It can be hard to find meds on the road. I keep Acetaminophen and Ibuprofen with my for pain. Benedryl of allergies act up, Pepto Bismol tablets for my stomach, and dayquil/nyquil in case I feel sick. It can be surprisingly hard to find these things on the road. Sometimes availability, sometimes because I don’t have time, sometimes because I’m in a foreign land.
  • currency – I still run into places that don’t, or don’t want to, take credit. It’s fewer and fewer places, but it happens. I try to keep currency in my wallet for the places I go. That means US Dollars, Euros, Pounds, and I randomly have Kronor, HK dollars, AUS dollars, and NZ dollars. A few rupees as well. Usually $20-50 of local money. I keep a couple change purses to separate out UK and EU money.
  • Readers – I am getting blind as I age. I can’t see with my contacts anything on paper and not much on my phone. I like these travel ones.
  • sunglasses – I love Shady Rays and with the hardcase in my Everki bag, I keep a pair there, as well as separate ones in each car and one for chores. Free replacements if they break, which I’ve needed a few times.
  • bottle opener – I use Redgate ones, but they’re like these. It’s come in handy if I grab a soda or beer to relax in my room and they don’t have any openers.
  • water bottle – I got an aluminum one as a gift and I carry it. I try to avoid the plastic ones now and reduce the waste I generate. Choose one that fits in your bag. I like the Contigo ones.
  • snacks – I’m partial to Power Crunch bars (right now) and peanut butter packets. I find airlines sometimes don’t have food, or what I want, or they’re delayed. I try to keep food with me, just in case. I’ve found myself saved by these things during long delays, or when I’m stuck somewhere that isn’t serving food.

There’s likely other stuff that I have in my bag. I need to give it a cleaning, and remove things I don’t need. However, this is the major list of things that I try to ensure are with my on every trip.

If you have your own things, let me know.

Posted in Blog | Tagged , | Comments Off on Things I Carry in My Travel Bag