Search This Blog

2020-04-23

PowerShell: Unhide Files

Product: PowerShell
Version: 1.0 above

Following command can be used to unhide files and directory, excluding

  • thumbs.db
  • desktop.ini

Get-ChildItem -Force -Recurse | Where-Object{ $_.Attributes.ToString().Contains(“System”) -or $_.Attributes.ToString().Contains(“Hidden”) -and ($_.Name -ne “thumbs.db”)  -and ($_.Name -ne “desktop.ini”) } | foreach {$_.Attributes = “Archive”}

or

Get-ChildItem -Force -Recurse | Where-Object{ $_.Attributes.ToString().Contains(“System”) -or ( $_.Attributes.ToString().Split(“, “) -contains “Hidden”) -and ($_.Name -ne “thumbs.db”)  -and ($_.Name -ne “desktop.ini”) } | foreach {$_.Attributes = “Archive”}



Following command can be used to unhide all files and directory

Get-ChildItem -Force -Recurse | Where-Object{ $_.Attributes.ToString().Contains(“System”) -or  ($_.Attributes.ToString().Contains(“Hidden”) } | foreach {$_.Attributes = “Archive”}

or

Get-ChildItem -Force -Recurse | Where-Object{ $_.Attributes.ToString().Contains(“System”) -or  ($_.Attributes.ToString().Split(“, “) -contains “Hidden”) } | foreach {$_.Attributes = “Archive”}

No comments: