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

Related Posts by Categories

0 comments:

Post a Comment