One of the first configurations I always set on my test Windows Server instances is to show file extensions. This small tweak can significantly improve efficiency and accuracy when working with files, as it eliminates ambiguity about file types.

Why Show File Extensions? Link to heading

By default, Windows hides file extensions for known file types. While this setting is aimed at making the user experience simpler, it can sometimes lead to confusion, especially when dealing with files that have similar names but different extensions. Showing file extensions helps you:

  1. Identify File Types Quickly: Easily distinguish between files like file.txt and file.bat.
  2. Enhance Security: Prevent malicious files from masquerading as harmless ones (e.g., document.txt.exe appearing as document.txt).
  3. Simplify File Management: Manage and organize files more effectively, especially when working with scripts, configurations, and multiple file types.

How to Make File Extensions Visible Link to heading

You can configure this setting manually via File Explorer, but as an automation enthusiast, I prefer using PowerShell to make this change. Here’s a simple PowerShell script that modifies the registry to ensure file extensions are always visible.

PowerShell Script Link to heading

<#
.SYNOPSIS
This script configures Windows to show file extensions.

.DESCRIPTION
The script modifies the registry to ensure that file extensions are not hidden in File Explorer.

.NOTES
Run this script with administrative privileges.
#>

# Define the registry path and value name
$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
$valueName = "HideFileExt"
$valueData = 0  # 0 to show file extensions, 1 to hide

# Set the registry value
Set-ItemProperty -Path $registryPath -Name $valueName -Value $valueData

# Notify the user
Write-Output "File extensions are now configured to be visible."

Explanation Link to heading

  1. Registry Path and Value: The registry path for the setting is HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced. The value name is HideFileExt, and setting its data to 0 makes file extensions visible.
  2. Set-ItemProperty: The script uses Set-ItemProperty to change the registry value.
  3. Output Notification: The script outputs a message indicating that the configuration has been changed.

Steps to Run the Script Link to heading

  1. Save the Script: Save the script as show_file_extensions.ps1.
  2. Run the Script:
    • Open PowerShell as Administrator.
    • Navigate to the location where you saved the script.
    • Execute the script: .\show_file_extensions.ps1

Conclusion Link to heading

Setting file extensions to be visible is a simple yet powerful configuration that I always implement on my test Windows Server instances. It enhances file management, improves security, and makes life a bit easier for developers and administrators alike. By using PowerShell to automate this task, you can ensure consistency and save valuable time.


Get the Ultimate Guide to PowerShell and AWS

Unlock the full potential of PowerShell within the AWS ecosystem with my book, "Pro PowerShell for Amazon Web Services." Dive into a comprehensive resource packed with insights, examples, and practical knowledge designed to help you master automation and management of your AWS environment. Don't miss the opportunity to elevate your skills and streamline your AWS workflows—get your copy today!

Buy "Pro PowerShell for Amazon Web Services" on Amazon.com

Disclaimer: This link is an Amazon affiliate link. If you make a purchase after clicking it, I may earn a small commission at no additional cost to you. Your support helps me continue creating valuable content—thank you!