Skip to main content
ubuntuask.com

Back to all posts

How to Remove Read-Only Attribute Of A Folder By Powershell?

Published on
2 min read
How to Remove Read-Only Attribute Of A Folder By Powershell? image

Best PowerShell Tools to Buy in October 2025

1 Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

BUY & SAVE
$47.34 $59.99
Save 21%
Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools
2 Learn PowerShell Scripting in a Month of Lunches

Learn PowerShell Scripting in a Month of Lunches

BUY & SAVE
$50.26
Learn PowerShell Scripting in a Month of Lunches
3 Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects

Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects

BUY & SAVE
$0.99
Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects
4 Windows PowerShell in Action

Windows PowerShell in Action

  • BRAND NEW CONDITION GUARANTEES TOP-NOTCH QUALITY.
  • COMPLETE WITH ALL ESSENTIAL ACCESSORIES INCLUDED.
  • READY TO USE RIGHT OUT OF THE BOX-CONVENIENCE PACKAGED!
BUY & SAVE
$59.99
Windows PowerShell in Action
5 Windows PowerShell 2 For Dummies

Windows PowerShell 2 For Dummies

BUY & SAVE
$21.00 $33.99
Save 38%
Windows PowerShell 2 For Dummies
6 Windows PowerShell Step by Step

Windows PowerShell Step by Step

BUY & SAVE
$48.60 $59.99
Save 19%
Windows PowerShell Step by Step
7 PowerShell For Beginners: Learn Quickly with Real World Scripts

PowerShell For Beginners: Learn Quickly with Real World Scripts

BUY & SAVE
$0.99
PowerShell For Beginners: Learn Quickly with Real World Scripts
8 PowerShell for Beginners: Learn PowerShell 7 Through Hands-On Mini Games

PowerShell for Beginners: Learn PowerShell 7 Through Hands-On Mini Games

BUY & SAVE
$22.39 $54.99
Save 59%
PowerShell for Beginners: Learn PowerShell 7 Through Hands-On Mini Games
9 Learn Windows PowerShell in a Month of Lunches

Learn Windows PowerShell in a Month of Lunches

BUY & SAVE
$30.39 $44.99
Save 32%
Learn Windows PowerShell in a Month of Lunches
+
ONE MORE?

To remove the read-only attribute of a folder using PowerShell, you can use the following command:

(Get-Item "C:\Path\To\Folder").Attributes = 'Directory'

Replace "C:\Path\To\Folder" with the actual path to the folder that you want to remove the read-only attribute from. This command will set the attributes of the folder to 'Directory', which effectively removes the read-only attribute.

What is the quickest way to remove the read-only attribute of a folder by PowerShell?

One way to remove the read-only attribute of a folder using PowerShell is by using the following command:

Get-ChildItem -Path "C:\path\to\folder" -Recurse | foreach { $_.Attributes = $_.Attributes -band (-bnot [System.IO.FileAttributes]::ReadOnly) }

Replace "C:\path\to\folder" with the path to the folder you want to remove the read-only attribute from. This command will recursively remove the read-only attribute from all files and folders within the specified directory.

How do I remove the read-only attribute from a directory in PowerShell?

To remove the read-only attribute from a directory in PowerShell, you can use the following command:

Set-ItemProperty -Path "C:\Path\To\Directory" -Name Attributes -Value ((Get-Item -Path "C:\Path\To\Directory").Attributes -bxor [System.IO.FileAttributes]::ReadOnly)

Replace "C:\Path\To\Directory" with the actual path to the directory you want to remove the read-only attribute from. This command will toggle the read-only attribute of the directory.

What is the best practice for removing the read-only attribute of a folder in PowerShell?

The best practice for removing the read-only attribute of a folder in PowerShell is to use the Get-ChildItem and Get-Item cmdlets to access the folder and then use the Select-Object cmdlet to select the Attributes property. Finally, use the Set-ItemProperty cmdlet to change the attribute to remove the read-only designation.

Here is an example of how to remove the read-only attribute of a folder named "FolderName":

# Get the folder $folder = Get-Item "C:\Path\To\Folder\FolderName"

Check the current attributes of the folder

$folder.Attributes

Remove the read-only attribute

$folder.Attributes = $folder.Attributes -bxor [System.IO.FileAttributes]::ReadOnly

Verify that the read-only attribute has been removed

$folder.Attributes

By following this method, you can safely and effectively remove the read-only attribute of a folder in PowerShell.