Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set file to 'Writable' with PowerShell

I'm trying to set a few files to writable, but I'm having an issue. I have tried using:

 $file = "path/to/my/file.dat"
 $file = Get-Item $file 
 $file.IsReadOnly = $false

As well as everything listed here:

How to Remove ReadOnly Attribute on File Using PowerShell?

But it still isn't working, at least I don't think it is because when I check the file properties the 'Read-Only' box is still checked:

UPDDATE::

When I run:

$file.isReadOnly

it returns $false, but the box below is explicitly checked? Are these two different things?

enter image description here

I'm wondering what I'm doing wrong, or how to make it so this file is editable.

like image 658
BlackHatSamurai Avatar asked Dec 06 '22 06:12

BlackHatSamurai


2 Answers

This works:

Get-Item -Path "path/to/my/file.dat" |
    Set-ItemProperty -Name IsReadOnly -Value $false
like image 192
Aaron Jensen Avatar answered Dec 08 '22 18:12

Aaron Jensen


You can actually skip the first line:

$file = Get-Item "path/to/my/file.dat"
Set-ItemProperty $file -Name IsReadOnly -Value $false
like image 35
Dreami Avatar answered Dec 08 '22 20:12

Dreami