Monday, August 29, 2016

PowerShell v2 Function Hide Folder

,
While working on a project I came up with a quick need to hide a folder, so, I wrote this canned function:
function Hide-Folder
{
      param(
            $foldername
      )
     
      if(Test-Path $foldername)
      {
            $(Get-Item $foldername).Attributes = Hidden
      }
      else
      {
            Write-Error "The folder ($($foldername)) was not found."
      }
}
The source of the .Attributes trick was:
 Get or set filedirectory attributes using Powershell

0 comments to “PowerShell v2 Function Hide Folder”

Post a Comment

 

Computer Info Copyright © 2016 -- Powered by Blogger