[Win10] Help with PS script to set all folders in a directory to "details" view

Hey all,

First time posting on these forums. I can usually figure out scripting issues with some google searching, but I am having a hell of a time finding help on this one.

I’m currently attempting to write a PowerShell script that will change all of the folders and sub-folders of a specified parent directory to windows built in Details view. I’d like to do this programmatically so that I don’t have to manually go through every folder and change the view myself. I could simulate key presses to do this, but that seems cumbersome and potentially problematic. Especially because each folder has it’s own set of sub-folder structures. Below is the code that I’ve pieced together through research and trial and error.

$wshell = New-Object -Com WScript.Shell
$WorkingFolder = "C:\Users\Colton\Desktop\Test"
ii $WorkingFolder
start-sleep -m 100
Start-Sleep -m 100
Start-Sleep -m 100
for ($i = 1; $i -le 100; $i++ ) {
	Write-Progress -Activity "Setting all folders to 'Details' view..." -Status "$i% Complete:" -PercentComplete $i
	Start-Sleep -Milliseconds 250
		Get-ChildItem -Path $WorkingFolder -Recurse | ForEach-Object {

I have the F6 key bound to set the view to Details, which works when I use it manually. Currently, the script successfully opens the parent directory that I want it to, but then does nothing more to the folder structure(s). I’ve tried to debug it with tracing enabled but haven’t had much luck.

Any help with this would be greatly appreciated. This all started when I needed to move all the data on an external HDD to format and re-partition the drive. I’d like to not have to manually reset my view options for every folder should I do this again in the future.

Hi, welcome to the forum :wave:

Editing the registry seems to be the way to go. There’s a solution on StackOverflow that looks like it should work (I’ve not tested it). It sets it to List view, but they provide the other integer options to set it to Details view:

Edit: actually re-reading your post, I’m not sure if you want all folders or all folders under a specific sub-folder?

1 Like

Thanks, but yes, I’m looking to do this for a specific folder structure and not globally. Actually I want to do it for an entire HDD partition specifically. Should’ve mentioned that in the original post.

May I ask the reason for this requirement?

Could an alternative file manager be an option? … like FreeCommander for example, or something similar?

An alternative file manager would work. I was just trying to avoid having an additional application just to view files in a specific location the way I want to.

Plus, now that I’ve gone down this rabbit hole, it’s bothering me that I can’t get it to work :sweat_smile:.

Well … you cannot teach a cow to fly. No matter how much it bothers you. :man_shrugging:t3: :wink: :smiling_face:

This is true…

Tommy Boy - Holy Schnikes!