Renaming Files by Padding Numbers with PowerShell

Some time ago I had downloaded all the SQL Saturday XML files. I’ve been meaning to flatten those into a database, but that project keeps getting away from me. And now it’s become an archive task.

In any case, I’ve been looking to work with Jekyll and get a list of events. There is one at SQLSatHistory.com, but I’m going to try and do a bit more than a simple list. In any case, I have found a small issue: my files were named SQLSat1,xml, SQLSat2.xml, etc.

That’s not a big problem, but it results in my archive looking like:

  • SQL Saturday #1 – Orlando
  • SQL Saturday #100 – Brazil
  • SQL Saturday #101 – Kansas City
  • etc.

The file names are strings, and in alpha sorting, 100 comes before 2. That’s not critical, but it’s not what I want, and I would like something that’s a bit better and easier to follow.

The easiest way to do this is to rename the files. I have some data in the files, and I have those being parsed, so if I can rename the files, I can get the events generated in an orderly fashion.

PowerShell has a Rename-Item cmdlet, which will work, but what new name? I need to parse out the filename and then come up with a new one. Likely there are better methods, but this worked quickly for me to rename some files.

The Process

My thought in doing this was first to extract out the number and then check the length. From there, I can assemble a new string. Instead, as I was starting, I thought of a better way. I decided to remove everything but the number.

There is a replace method for strings. As In, I can do this:

$EventNumber = $XmlFile.Name -replace 'SQLSat', ''

This will take away the string before the number, and results in file names going from:

  • SQLSat1.xml
  • SQLSat2.xml
  • SQLSat3.xml

to

  • 1.xml
  • 2.xml
  • 3.xml

I repeated that and removed the .xml as well, which gave me each event’s number. From here, I found a cool trick on Stack Overflow to do this. The PadLeft method is used

 % PadLeft 4 '0'

I use 4 as a padding factor. This results in giving me what I want, and when I concatenate this, I get the file names I want.

$NewFile = "SQLSat" + $EventNumber + ".xml"

From there, a simple call to Rename-Item with each file resulted in an orderly list of events.

2021-01-07 13_21_43-xml

Posted in Blog | Tagged , | 2 Comments

Default Credentials

Years ago I got a call to help someone with a database. I walked over to their desk (when this was possible) and sat down. They asked me how they could get into a database they had been told about. I quickly realized this was an Oracle database and asked for credentials for SQL*Plus. This person didn’t have any, but I was able to log in with SYSTEM and MANAGER. This was a small department system of some sort, but it always struck me that the default credentials were available. Since then, every time I’ve encountered an Oracle database, I’ve tried those credentials. I’ve been amazed how often they worked, even for production systems.

Recently there was a report that the Nissan corporation had some of their source code leaked. While I would prefer that the code running inside cars was open and widely examined, I was more dismayed that the leak was from an internal Git server with default credentials. Maybe even worse is the defaults are admin and admin, something that might not be hard to guess.

I understand people make mistakes, and I do get that there are pressures people feel to get work done, but there isn’t a good excuse to stand up any server in production with default credentials, and I’d argue a VCS server is production. Even if you didn’t install the server and were just moving it to a new role, or you take over administration, you can’t leave default credentials around. You certainly can’t accept “admin” as a password in 2021.

To me, this is grounds for termination. If nothing else, it’s certainly a reason to remove someone from a privileged position. Being this lax with security would worry me, and I don’t know that I could trust that you’d been careful with other parts of your job. If I encountered this, I would request that every other system under management be audited for improper admin accounts.

Steve Jones

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

Posted in Editorial | Tagged | Comments Off on Default Credentials

Daily Coping 18 Jan 2021

I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag. 

Today’s tip is to say positive things to the people you meet today.

For many of us, we don’t meet too many people on a daily basis. Some of us are locked down, some of us just don’t follow routines that allow this.

I am restricted, but I do still go out here and there. The grocer, the gym, etc. Recently, I was out to pick up some take-out from a local restaurant. It was quiet there, with few in-person diners, but I took a minute to chat with the employee, thanking them, telling them I’m glad they’re still working and open, and letting them know I enjoy and appreciate their food.

I got a smile, at least, I think I did. We were all wearing masks.

Posted in Blog | Tagged , , | Comments Off on Daily Coping 18 Jan 2021

Moving the Community Forward

Today is the last day that the PASS and SQL Saturday websites will be active. It’s possible that they will be shut down as this post gets published, and if so, I will be sad for their loss. I’ve already moved my SQL Saturday.com bookmark to https://sqlsathistory.com/, where André Kamman has captured quite a bit of the data.

In any case, the organization will cease to exist, though I expect to learn about the fate of SQLSaturday.com in the next few days. I put in a bid, but I know some other organizations have as well, and I expect one of them to acquire the brand.

I don’t quite know how to move forward, but I have a few ideas here, at the local and global levels, and this is my proposal.

One Day Free Tech Events

SQL Saturday was dreamed up by Andy Warren, with Brian Knight and myself helping to implement it. The idea was to bring a conference experience to many people that would not otherwise get the chance to attend an event like SQL Bits, the Data Platform Summit, or the PASS Summit. The idea was to help the local communities run their own events.

This succeeded beyond my wildest dreams, and I look forward to continuing this work. Whether under the SQLSaturday.com domain, DataSaturdays.com domain, or something else, I hope that these events not only continue virtually,  but that 2021 will see some live events in physical locations.

In order to do that, I do think that some sort of organization is needed to help steer and manage the branding and common tools. Many organizers not only appreciate, but need help in running events. My view is that this organization needs to be open and transparent, unlike how the SQLSaturday brand was managed in the recent past.

My hope is that a non-profit organization, with transparency, is formed and can manage any assets in a way that prevents a dependency on any individual or commercial organization. I would envision this as the following public characteristics:

  • open proposals from the community or board of directors
  • open discussion and debate of proposals
  • timely and open voting on issues by the board of directors
  • open source tools that enable event coordination and execution
  • open books of any and all financial details*
  • public guidelines, with limited rules or requirements for association with the brand
  • flexibility to allow organizers to run events in a variety of ways.

There are many details to be worked out, and certainly many concerns from the previous way in which the PASS organization operated, but I am confident there are ways to continue to promote and advocate for local events.

Local and Virtual Chapters

Most local chapters have operated very independently with few dependencies on PASS, and I expect they will continue to do so. I do hope that they maintain connections with each other for mutual assistance and knowledge sharing.

I would recommend that chapters ensure they have a mailing list that is accessible by at least two individuals. I would also say that they should ensure they have a public website. There are a few options available from different sources if anyone does not wish to manage their own. Please sign up with one or both of these.

I would encourage user groups to also register their meetings with https://callfordataspeakers.com/ to help them find individuals that might present at their meetings.

Andy Warren has other thoughts, and I would encourage chapter leaders to read and share them.

Speakers

Many speakers maintain their own schedules, lists of resources and more. The growth of many speakers and their willingness to present at events all over the world has been one of the incredible things that came about as SQL Saturdays grew and spread. I hope this continues, and that means speakers need to continue to find opportunities to practice and deliver their sessions.

I would encourage all speakers to do the following:

In addition, everyone should ensure they have a place to share code and Powerpoint/PDF/session materials. I have seen many options, and these are good options:

  • A blog (WordPress or otherwise)
  • OneDrive/Box/DropBox/etc.
  • GitHub repos/pages
  • YouTube – Save recordings of your sessions

There are many ways in which people share, and I would certainly encourage speakers to share their own methods that others might learn from and implement on them.

A Final PASS Chapter

I’ve seen a few people write about the end of PASS and the future (Andy, Andy, Tim, Brent, and more). I’m disappointed that there isn’t an organization (right now) that promotes things, but I am glad PASS ended. It hasn’t been run well or with a primary focus on community good in a long time.

Hopefully we can move forward in new ways that improve on what we’ve had and continue to drive the community forward.

* I do recognize that the timeliness of financial disclosures can be difficult at times, but any and all filings, revenue received, and expenses incurred should be available.

Posted in Blog | Tagged , , | Comments Off on Moving the Community Forward