I created this function because I needed to know if a path supplied to a script was a file or a folder.

It uses a combination of Test-Path and Get-ChildItem to work it out.

You could just as easily use the words object / container instead of file / folder and test a registry path.

Cheers

PowerShell
Edit|Remove
function Get-PathType($strPath)
#Function by Matthew Painter 27/06/2010
#Determine if a path is a file or a folder. 
{
   If ( (Test-Path $strPath) -eq $true ) 
   {
      if ([string](Get-Childitem $strPath | Where-Object { $_.PSIsContainer }) -eq "")
      {
         return "File"
      }
      else
      {
         return "Folder"
      }
   }
   else
   {
      return "Invalid Path"
   }   
}

Get-PathType c:\