Change a file marked as system

Hi
I’m trying to change the attribute of a file called folder.jpg from System/Hidden to Normal.

I am using this code:

$SFile = Get-ChildItem folder.jpg -System -Force
$SFile.Attributes = ‘Normal’

but I get the following error[blockquote]The property ‘Attributes’ cannot be found on this object. Verify that the property exists and can
be set.
At line:1 char:1

  • $File.Attributes = ‘Normal’
  •   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyNotFound[/blockquote]
    

Is there something wrong with what I’ve done
Thanks
Tony

Hard to tell from what I can see here. What do you get if you run $File.GetType().FullName?

Hi Dave

$SFile.GetType().FullName returns System.IO.FileInfo

The error message you posted mentions a variable named $File, not $SFile:

The property 'Attributes' cannot be found on this object. Verify that the property exists and can
 be set.
 At line:1 char:1
 + $File.Attributes = 'Normal'
 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo : InvalidOperation: (:) [], RuntimeException
 + FullyQualifiedErrorId : PropertyNotFound

If you’ve got two different variables / objects involved here (or if $file just doesn’t exist), that could be the problem.