Powershell Clear Archive Bit On Files

get-childitem C:\scripts -recurse | Clear-ItemProperty -Name attributes

Okay. Okay. So this script is actually resetting all of the file properties to Normal. If you absolutely cannot modify the other file attributes then you need  a much more granular (and complicated) script which can be found at: http://blogs.technet.com/b/heyscriptingguy/archive/2011/01/26/use-a-powershell-cmdlet-to-work-with-file-attributes.aspx .

MSDN article detailing different file attributes: http://msdn.microsoft.com/en-us/library/system.io.fileattributes.aspx

Afterthoughts:

So why not just use attrib -A [directory]? Because the attrib command tries to write to hidden files (like the page file) and this script does not.

One thought on “Powershell Clear Archive Bit On Files

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s