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

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL