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

Related Post:

0 comments:

Post a Comment

 
Copyright 2009 Information Blog
Powered By Blogger