Powershell – How to change a file’s attribute using Powershell

powershell

I have a Powershell script that copies files from one location to another. Once the copy is complete I want to clear the Archive attribute on the files in the source location that have been copied.

How do I clear the Archive attribute of a file using Powershell?

Best Answer

You can use the good old dos attrib command like this:

attrib -a *.*

Or to do it using Powershell you can do something like this:

$a = get-item myfile.txt
$a.attributes = 'Normal'