Powershell equivalent of "dir /a"

Abstract: Use Get-ChildItem -Force to list all files and directories, including hidden and system items, in PowerShell.

Created: 2026-08-01 by
The PowerShell equivalent of the dir /a command is Get-ChildItem -Force. This cmdlet retrieves all items in a directory, including hidden and system files that are typically excluded from standard listings. By default, Get-ChildItem only shows visible items, but adding the -Force switch overrides this behavior to expose every file attribute stored on the filesystem. Understanding how to list all files is crucial for system administration, debugging configuration issues, or performing deep cleanups of temporary data. While the Command Prompt uses flags like /a, /ah, or /as to filter by attribute type, PowerShell takes a different approach by exposing object properties rather than just text output. This allows for more robust scripting and filtering capabilities later in your workflow.

Basic Usage and Equivalency

In Windows CMD, running dir /a lists all files regardless of their attributes. In PowerShell, you achieve the exact same result with:
Get-ChildItem -Force
This command works in any directory context. If you are currently in C:\Users\Public, it will list every single item there. The -Force parameter is the key differentiator here. Without it, PowerShell hides items marked as Hidden or System, which matches the default behavior of dir without switches. You can also combine this with path specification:
Get-ChildItem C:\Windows -Force
This explicitly targets the Windows directory and forces the display of protected system files, such as bootmgr or registry hives, which are usually invisible to casual users.

Difference Between CMD Flags and PowerShell Switches

CMD offers granular control over attributes using specific flags. For example, dir /ah shows only hidden files, while dir /ad shows only directories. PowerShell does not have direct one-to-one flag equivalents for these filters because it treats files as objects with properties. Instead, you use pipeline filtering with Where-Object. To replicate dir /ah (hidden files only):
Get-ChildItem -Force | Where-Object { $_.Attributes -band [System.IO.FileAttributes]::Hidden }
To replicate dir /ad (directories only):
Get-ChildItem -Force -Directory
Note that -Directory is a built-in switch in modern PowerShell versions that simplifies filtering for folders. It is much cleaner than using Where-Object checks for PSIsContainer. For those interested in managing history or cleanup tasks after listing these files, see our guide on View PowerShell History Without PSReadline: A Comprehensive Guide which helps manage session data effectively.

Filtering by Specific Attributes

Sometimes you need to find files that are both hidden and read-only, or perhaps exclude system files entirely. PowerShell’s bitwise operators make this precise. To find all files that are NOT system files:
Get-ChildItem -Force | Where-Object { -not ($_.Attributes -band [System.IO.FileAttributes]::System) }
This script block checks the Attributes property of each item. The -band operator performs a bitwise AND operation. If the result is non-zero, the attribute exists. Wrapping it in -not excludes those items. You can also filter by name patterns simultaneously:
Get-ChildItem -Force -Filter "*.log" | Select-Object Name, Attributes, Length
This command finds all log files, forces visibility, and then selects only the relevant columns for easier reading. Using Select-Object transforms the output into a custom view, which is often more useful than the default table format.

Recursive Listing with Force

The dir /a command in CMD does not recurse by default; you must add /s for subdirectories. In PowerShell, recursion is handled by the -Recurse switch. Combining it with -Force ensures you see everything in the entire tree structure.
Get-ChildItem -Path C:\Data -Recurse -Force
Be cautious when using -Recurse on large drives, as it can generate significant output and impact performance. You might want to limit the depth or filter aggressively. If you plan to delete unwanted files found during such a recursive scan, refer to Unlock and Delete Files/Folders via Command Line (cmd/PowerShell) on Windows - Preferably Using FLOSS Tools for safe removal strategies.

Common Pitfalls and Permissions

Even with -Force, some system files may still not appear if your user account lacks sufficient permissions. Administrator privileges are often required to access certain protected directories like C:\Windows\System32\config. Always run PowerShell as Administrator when dealing with critical system files. Another common issue is confusing Hidden file attributes with Archive attributes. Many backup tools set the Archive bit. If you want to see files marked for backup, ensure you understand that -Force reveals them, but they are not necessarily "hidden" in the UI sense.

Frequently Asked Questions

Why does Get-ChildItem hide files even with -Force?

If files remain hidden despite using -Force, you likely lack administrative permissions. Some system folders require elevated rights to enumerate contents. Run PowerShell as Administrator to resolve this access denial.

How do I list only hidden files without system files?

Use a pipeline filter combining the Hidden attribute check and excluding the System attribute. The command Get-ChildItem -Force | Where-Object { $_.Attributes -band [System.IO.FileAttributes]::Hidden -and -not ($_.Attributes -band [System.IO.FileAttributes]::System ) } achieves this precise selection.

Is there a shortcut for Get-ChildItem?

Yes, you can use the alias gci, ls, or dir. These aliases map directly to Get-ChildItem. Typing gci -Force works identically to the full cmdlet name and is faster to type in interactive sessions.

Can I export the list of all files to a CSV?

Absolutely. Pipe the output of Get-ChildItem -Force -Recurse into Export-Csv. For example: Get-ChildItem -Force -Recurse | Select-Object FullName, Attributes, LastWriteTime | Export-Csv -Path files.csv -NoTypeInformation creates a structured report of all items.

What is the difference between /a and /ah in CMD?

The /a flag lists all files regardless of attributes. The /ah flag lists only files with the Hidden attribute set. In PowerShell, -Force acts like /a, while filtering with Where-Object acting like /ah provides the selective visibility.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More