header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Cannot find path error
Last Post 26 Oct 2007 04:28 PM by eric. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
riosfUser is Offline
New Member
New Member
Posts:2
Avatar

--
19 Oct 2007 08:58 PM  
Hi:

I have the following script that attemps to read computer names from a file and

then connect to those computers to remove a folder and its subfolders.

When I run

Get-Content -path c:\list.txt | foreach {
Remove-Item -path "c:\Program Files\test" -recurse
}


I get this error:

Remove-Item : Cannot find path 'C:\Program Files\test' because it does not exist.
At line:2 char:12

The folder is there but still says it cannot find it.

Any help will be apprecieated.

Thanks,

riosf

bsonposhUser is Offline
Basic Member
Basic Member
Posts:393
Avatar

--
19 Oct 2007 09:05 PM  
Try this

Get-Content -path c:\list.txt | foreach {
Remove-Item -path "\\$_\C$\Program Files\test" -recurse
}
Brandon Shell
----------------
Microsoft Powershell MVP
https://mvp.support.microsoft.com/profile/Brandon
Blog: http://www.bsonposh.com
riosfUser is Offline
New Member
New Member
Posts:2
Avatar

--
19 Oct 2007 09:17 PM  

I just tried what you suggested and it worked.

Thanks for your assistance.

FR

ericUser is Offline
New Member
New Member
Posts:8
Avatar

--
26 Oct 2007 04:28 PM  
The delete commands were coming from your local PC and as such had to be specified relative to your PC
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer