Using Test-Path to find folder within another folder.
hello all,
i creating folders based off of date. check see if folder created, , running issue since folder name unique each day, can't folder "x". think ran mental block.
here code.
$destdir = "c:\users\desktop\folder" $date = (get-date).tostring("mm-dd-yyyy") $foldercheck = (test-path -path $destdir -pathtype container $date)
the first line location of $destdir.
the second line grabs date , stores in $date.
the third line have issue.
i looking folder under $destdir has name of current $date.
the error getting this,
test-path : positional parameter cannot found accepts argument '01-12-2013
any appreciated, thanks!
$destdir = "c:\users\desktop\folder" $date = (get-date).tostring("mm-dd-yyyy") $foldercheck = (test-path -path $destdir -pathtype container -include $date)
this works.
adding -include parameter fixed issue.
thanks looking.
Windows Server > Windows PowerShell
Comments
Post a Comment