So i'm trying to clear all file attributes and just set Archive bit,
Currently I have Archive,Offline. I recalled a file from an object store and it still says its offline
gci file | Select attributes
Archive,Offline
I wanted to force clear all the attributes but I couldn't figure out the best way to do this.
I found a few links on google, including the this code
functionGet-FileAttribute{
param($file,$attribute)
$val= [System.IO.FileAttributes]$attribute;
if((gci $file-force).Attributes-band$val-eq$val){$true;} else { $false; }
}
functionSet-FileAttribute{
param($file,$attribute)
$file=(gci $file-force);
$file.Attributes=$file.Attributes-bor ([System.IO.FileAttributes]$attribute).value__;
if($?){$true;} else {$false;}
}
functionClear-FileAttribute{
param($file,$attribute)
$file=(gci $file-force);
$file.Attributes-= ([System.IO.FileAttributes]$attribute).value__;
if($?){$true;} else {$false;}
}
param($file,$attribute)
$val= [System.IO.FileAttributes]$attribute;
if((gci $file-force).Attributes-band$val-eq$val){$true;} else { $false; }
}
functionSet-FileAttribute{
param($file,$attribute)
$file=(gci $file-force);
$file.Attributes=$file.Attributes-bor ([System.IO.FileAttributes]$attribute).value__;
if($?){$true;} else {$false;}
}
functionClear-FileAttribute{
param($file,$attribute)
$file=(gci $file-force);
$file.Attributes-= ([System.IO.FileAttributes]$attribute).value__;
if($?){$true;} else {$false;}
}