-
Redshift JDBC Driver Download
Need to download the Redshift JDBC client driver? Here’s how you can do it quickly:
> From the AWS Redshift Console: Navigate to the Configure tab and download the JDBC driver.
> Download From AWS Docs: Download the JDBC driver directly from the AWS Documentation.I’m sharing this quick guide because it’s something I often do. In this post, we’ll cover downloading the Redshift JDBC driver and configuring it. Hope it helps!
1. How to Download the RedshiftJDBC Driver
As mentioned we can download the Redshift JDBC driver from AWS Docs.
Alternatively we can download from within the AWS Redshift Console. Navigate to the Configure tab and click to download the JDBC driver:
We should also copy / note down the endpoint address for your Redshift Cluster:
2. Configuring AWS Redshift Driver
Once we have the drive downloaded and installed, we can configure the JDBC driver properties.
I’m configuring the Redshift JDBC driver within DBeaver for this example:
All I’ve changed here is the Redshift host address, database name and login details. The test connection is looks good:
And finally for this demo I’m verifying the driver has been configured successfully by connecting to the Redshift Cluster and running a query:
-
PowerShell Guide: Creating Folders and Files
This guide walks you through the steps to create new files and folders using PowerShell. Additionally, at the end I’ll show how to add text to files directly within PowerShell.
The
New-Item
cmdlet will create new files or folders in PowerShell. By adjusting the-ItemType
parameter toFile
orDirectory
and specifying a name, you can quickly create the structures you need.For further details and the latest examples, refer to the Microsoft Documentation on New-Item, which includes examples for creating PowerShell profiles, symbolic links, and more.
Contents:
> Creating New Folder in PowerShell
> Creating New Files in PowerShell
> Adding Text to Files in PowerShellCreating New Folder in PowerShell
To create a new folder in PowerShell, use the
New-Item
cmdlet with the-ItemType
parameter and set it toFolder
.The command below creates a folder in the directory you are currently navigated to within the PowerShell Terminal. So, the new folder is being created in
c:\users\pete\
# PowerShell create new folder New-Item -ItemType Directory -Name Test_Stuff
This command creates a folder named
Test_Stuff
in that location:Creating Files in PowerShell
Creating a file is just as simple as creating a folder. We just need to change the
-ItemType
param toFile
and replace<FileName>
with your desired name including the file extension.For example, the following command creates a file named
Test_File.txt
in the current working directory:# PowerShell new file New-Item -ItemType File -Name Test_File.txt
Note: The only difference between creating a folder and a file is the value provided to the
-ItemType
parameter (Directory
vs.File
).Adding Text to Files in PowerShell
As a bonus, here’s how to add content to a file using the
Add-Content
cmdlet. After adding text, you can verify the file’s contents using theGet-Content
cmdlet.Here’s an example:
# PowerShell add text to file Add-Content .\Test_File.txt -Value 'Hi hi!... just a wee message here.' # PowerShell show file content Get-Content .\Test_File.txt
This approach is good for appending information to files directly within a script or terminal session. If doing development and coding, you’ll more likely be using a tool like Visual Studio Code for amending file contents.
For more advanced examples and best practices, don’t forget to check out the official Microsoft documentation which I’ve linked throughout this post.
-
AWS CLI: List All Users in Account
Managing AWS IAM (Identity and Access Management) users is essential for maintaining security and proper control over your AWS environment. The AWS CLI provides a simple and easy way for us to list all users in your AWS Account, helping administrators monitor and manage access effectively.
This guide will show you how to use AWS CLI to retrieve IAM user details and filter the output for better readability.
How to List AWS IAM Users using Command
To retrieve a list of all IAM users in your AWS account, run the
aws iam list-users
command. This command returns a JSON-formatted list containing details such as usernames, ARNs, and creation dates.To display specific user information, add the
--query
option as shown in the example below:aws iam list-users --query "Users[*].{Name:UserName, ARN:Arn, Created:CreateDate}"
This will return a cleaner, more focused output, making it easier to review user details without unnecessary clutter.
Example output:
[ { "Name": "AdminUser", "ARN": "arn:aws:iam::123456789012:user/AdminUser", "Created": "2022-04-15T12:34:56Z" }, { "Name": "DeveloperUser", "ARN": "arn:aws:iam::123456789012:user/DeveloperUser", "Created": "2023-01-10T08:22:30Z" } ]
Additional IAM Commands
Here are some other useful IAM-related commands:
List IAM Roles:
aws iam list-roles
Get Details of a Specific IAM User:
aws iam get-user --user-name AdminUser
List IAM groups:
aws iam list-groups
List attached policies for a specific user:
aws iam list-attached-user-policies --user-name AdminUser
For a full list of available IAM commands, refer to the official AWS CLI IAM Documentation.
Using AWS CLI to manage IAM users simplifies user administration. By filtering command output, you can quickly access the most relevant details without sifting through large JSON responses. You can always view this same information via the GUI (AWS Console), however using command-line for managing security is needed in larger organizations.
-
Get Database Sizes & Free Space Info In SQL Server
Monitoring database file sizes and free space within data and log files is an important part of monitoring SQL Server health. This information, along with other metrics such as growth events, can help you to better predict and plan for future disk space provisioning needs.
The following script provides a quick way to view database file size information. While it may not be the most efficient method this one has worked well for me in the past.
The query output shows each database on the instance along with its current size and available free space. Here’s an example of what the output may look like:
Conclusion
This script provides a quick way to assess database sizes and available free space in SQL Server, helping you quickly check space database space.
It’s important to consider the impact of the recovery model, as log file free space can vary based on whether you’re using Simple, Full, or Bulk-logged. Autogrowth settings may also cause file sizes to increase in small increments, making it more important for you to track these growth patterns for future storage planning.
While shrinking database files is possible, it’s generally not recommended in production due to the risk of fragmentation and performance issues while running shrinks. Instead, proactively plan your storage needs.
Always test any script changes in a non-production environment before applying them to critical systems, for any random blog you read.
-
SQL Server: Searching for a String (Text) in All Tables
When working with SQL Server, you might need to find where a specific string exists in a database. This is especially useful when working with large or unfamiliar schemas.
For example, you may want to check where a value like a username, email, or other data is stored without knowing which table or column contains it. This script automates that process by searching all tables and relevant columns in a database for your desired string.
This is particularly helpful when:
– You don’t know the exact table or column where the data is stored.
– You want to avoid manually inspecting each table.
– You need a quick count of how many times a value appears in each column.The script dynamically searches all character-based columns for a specific value, and provides a way to search to certain column names if needed.
SQL Script to Find a String (Text) in Tables
This script has been in my toolbox for years. I couldn’t trace the original author, but it’s simple and works reliably for SQL Server 2019.
The script dynamically generates queries to scan all matching columns, focusing only on text-based data types like
char
,varchar
, andnvarchar
.Inputs:
@valueToFind
: The string to search for, with optional wildcards (%
) to expand the search.@columnName
: Filters columns by name (use'%%'
to search all columns).I’m searching for my name with wildcards at both ends in this example.
The result is as expected within my test database, it contains 2 occurrences of my name.
The script shows which tables and columns contain the string you searched for, along with how many times it appears in each. In this example it’s showing a row for each table that has name in it.
Now I’m going to check the data within those tables for the string I searched for.
Instead of manually inspecting each table or using SSMS filters, this script I’m sharing automates the process. It’s good for one-off searches and provides a clear, actionable output. Just run the script in the database where you want to search, set the variables, and review the results. Perfect for those “I don’t know where this data lives” moments, hope it helps!