Forum Discussion

dyckwal's avatar
dyckwal
Copper Contributor
Mar 05, 2025

changing file attribute/metadata

Hello all,

when I run a script that gives all of the file properties, I can see one named 'protected' and the value is 'yes'? Now I want this changed to 'No'.

I am new to powershell and have been searching everywhere, but did not find any solution for my issue.

The script I run to get the file information looks like this:

$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace((Get-Item .).FullName)

$filenameWithExtension = "24 Africa (Single Version).m4a"

$objFile = $objFolder.ParseName($filenameWithExtension)
$fileMeta = [ordered]@{}
for($id = 0; $id -le 266; $id++){
    $fileMeta[ $($objFolder.GetDetailsOf($objFolder, $id)) ] = $(
        if($objFolder.GetDetailsOf($objFile, $id)){
            $($objFolder.GetDetailsOf($objFile, $id))
        }else{ "" }
    )
}

print ordered hashtable
$fileMeta

 

you get a list of properties and one of them is the Protected.

Can anyone help on this? thx

    • LainRobertson's avatar
      LainRobertson
      Silver Contributor

      Hi dyckwal,

       

      I've had a read of the old Windows Scripting Host COM object documentation and while I can see a couple of different ways for reading the values (such as yours from your original script), there doesn't appear to be anyway to set the values out-of-the-box (I did notice some third-party solutions but you can probably find those yourself if you run a search).

       

      I'd be happy to stand corrected on this as - like I said above - I don't work with the COM model these days, meaning I'm no authority on this space.

       

      As an afterthought, I did wonder if the attribute named "Protected" isn't reflective of the DRM protection state, where if it is, I'm fairly certain that's not something you could clear anyway. But that's only guesswork on my part.

       

      Cheers,

      Lain

      • dyckwal's avatar
        dyckwal
        Copper Contributor

        Hello LainRobertson ,

        meanwhile found some third-party software,  DRmare Apple Music Converter for Windows, which does the trick. need to buy a license off course 😁, so for now going to think about it.

         

        Thanks for your time and effort to look at my issue.

         

         

    • LainRobertson's avatar
      LainRobertson
      Silver Contributor

      dyckwal,

       

      Sorry, I completely misunderstood. I'd assumed you were talking about removing the "block" from a file downloaded from the Internet. I clearly wasn't paying attention.

       

      I don't work with COM objects meaning I can't answer your question off the top of my head, but I'll have a look at your MP3 scenario above later today and see what can be done - if anything.

       

      Cheers,

      Lain

    • dyckwal's avatar
      dyckwal
      Copper Contributor

      Hello Lian,

      I executed this line:

      Unblock-File -Path "D:\Walter\Pictures\Safari Fotos Februari 2025\Music List\2-02 Baby Elephant Walk.m4a";

      but the outcome is that the Protected value is still Yes

      So, it does not do what is expected. Is there code to change that specific field?

      this is driving me up the wall 🤔

Resources