Showing posts with label Hidden files and folders. Show all posts
Showing posts with label Hidden files and folders. Show all posts

Wednesday, January 25, 2012

Script to reset “Hidden files and folders” to normal using PowerShell


Hi,

yesterday one of my users laptop get infected with virus. After removal of virus i saw that “Virus” hide every file and folder in the laptop.  It was quite a pain to “Choose file and folder” right click on it, choose properties and un-tick the hidden option.

Then i decide to write a script which can do this for me.

Download it from here : http://gallery.technet.microsoft.com/scriptcenter/Reset-Hidden-files-and-27d70766
so here is the script:
## Change "D:\P-temp" with your folder path
$Filepath = Get-ChildItem -Recurse -path "D:\P-Temp\" -Force 
$HSfiles = $Filepath | where { $_.Attributes -match "Hidden"}
$HSfiles
foreach ( $Object in $HSfiles ) {
       $Object.Attributes = "Archive"
       }
### End of script #####
This script search for “Hidden file and folder” in the path you defined in $Filepath and the it sets the “Archive” attribute on every file and folder it found.

Screen Shots:

You can see that the i highlighted the “hidden” files and folder below.

25-01-2012 17-05-46

we run the Script  and it done something ;-)

25-01-2012 18-15-42

You can see that , all hidden folder are back to normal. :)

25-01-2012 17-06-33

Download it from here : http://gallery.technet.microsoft.com/scriptcenter/Reset-Hidden-files-and-27d70766

Thanks for viewing .
Aman Dhally
messenger_freak_adp1 (8)

How to find Hidden files and Folders using PowerShell.

 

Hi,

In Old days when we need to saw the hidden files we used Dir /a command to view them. If you don't know let me show you the example

first we run a simple Dir *. command to show the us the list of folders are it is showing only 11 Directories.

Secondly we run the Dir *. /a command and it showing us 18 Directories , which means we have 7 hidden directories.

25-01-2012 17-20-45

how we can access the same information using PowerShell? it’s very easy just use the Get-ChildItem Cmdlet.

first Run Get-ChildItem only and we can see that it is showing  only few directories.

25-01-2012 17-26-59

OK Now run the Get-ChildItem with –Force Switch.

and you can see now we have more directories listed here. You can notice in the front of some directories the Mode is “h” {green arrow} ,which means the attribute for these directories is set to hidden.

25-01-2012 17-31-48 

or the other way to see the the Hidden files are folder in current folder is to run this command line.

Get-ChildItem  -Force | where { $_.Attributes -match "Hidden"}

this will show you only “Hidden” files and folders.

25-01-2012 17-41-00 

Thanks for reading.,..

Aman Dhally

messenger_freak_adp1 (30)