how to get the correct path This topic contains 4 replies, has 3 voices, and was last updated by Marco_wen 5 months, 1 week ago. Author Posts February 16, 2017 at 7:03 am #64332 Marco_wenParticipant this is my script： cmdkey /add:184.108.40.206\zonghang_data /user:xxxxxxx /pass:xxxxx $b = '\\220.127.116.11\zonghang_data' $fin = Get-Childitem $b -Directory | Sort-Object LastAccessTime -Descending | select -First 1 Copy-Item $fin $dis -Recurse but when i run COPY-ITEM..i cant get the correct path about of the $fin!! the $fin show the path is " c:\ " not the server directory! help！ February 16, 2017 at 7:09 am #64333 Sonny PuijkParticipant Your code is fine but if $fin doesn't show the correct path then it's fairly easy to troubleshoot. Does the below line produces the correct folder? Get-Childitem $b -Directory | Sort-Object LastAccessTime -Descending | select -First 1 February 16, 2017 at 7:40 am #64338 Marco_wenParticipant yes..when i run the commend can get the correct folder! then i put the object to the variable and use the Copy-ITEM commend , it cant get the correct folder! the error msg: Copy-Item (Get-Childitem $b -Directory | Sort-Object LastAccessTime -Descending ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Windows\system32\20171210:String) [Copy-Item], ItemNotFoundEx Actually the $fin path is "\\18.104.22.168\zonghang_data" not "c:\windows\system32" ! i dont know why ! February 16, 2017 at 9:19 am #64347 DudebroParticipant Not entirely sure why, but this seems to work: Copy-Item -Path $fin.PSPath -Destination $dis -Recurse February 17, 2017 at 1:11 am #64497 Marco_wenParticipant the command no problem..just didnt know why cant get the correct path. Author Posts You must be logged in to reply to this topic.