Hi Scripting Guys,
thanks for you favorite scripts. but
one question: the script abovementioned
running. But I have to enter a -value
for each file. If the script is not
written so that each file checked for the archive
and then changed? Apparently it
does not work right with me.
Here is the script again
and also a screenshot. Over a short help I
would be delighted.
Stephan
$path = "C:\fso"
$files = Get-ChildItem -Path $path -Recurse
$attribute = [io.fileattributes]::archive
Foreach($file in $files)
{
If((Get-ItemProperty -Path $file.fullname).attributes -band $attribute)
{
"$file.fullname has the $attribute bit set, removing the bit."
Set-ItemProperty -Path $file.fullname -Name attributes
-value ((Get-ItemProperty $file.fullname).attributes -BXOR $attribute)
"New value of $file.Fullname attributes"
(Get-ItemProperty -Path $file.fullname).attributes
}
ELSE
{
Write-host -ForegroundColor blue
"$file.fullname does not have the $attribute bit set, setting the bit."
Set-ItemProperty -Path $file.fullname -Name attributes
-value ((Get-ItemProperty $file.fullname).attributes -BXOR $attribute)
"New value of $file.Fullname attributes"
(Get-ItemProperty -Path $file.fullname).attributes
}
} #end Foreach