An Engineers Notebook

PowerShell | Modifying Item Properties

In this example i’ll use PowerShell to change the property of a file on the file system. I’ve created a text file called “test” in my Documents folder and launched PowerShell. 

To see the file properties I can do this:

cd $home

cd Documents

Get-ItemProperty -Path .test.txt | select *

This displays the full list of attributes for the file. In this example I’ll set the file as “read only”.

Set-ItemProperty -Path .test.txt -Name IsReadOnly $true

We can test to see if this worked by repeating the first cmdlet.

Get-ItemProperty -Path .test.txt | select *

This can be repeated on any PSDrive such as HKCU & HKCM, Active Directory.

cd HKCU:

cd SoftwareMicrosoftWindowsCurrentVersionExplorer

If we do a ‘dir’ here we can see all of the item properties within the Advanced container. This shows all of the properties within. We can see the HideFileExt property is 1. We’ll change this to 0 like this:

Set-ItemProperty -Path .Advanced -Name HideFileExt -Value 0

As you can see if we run another dir, it’s changed. We can further verify by logging of and on again and we should now see that file extensions are displayed by default in the GUI. 

Leave a Reply

Your email address will not be published.