1

I'm trying to remove a file after checking some thing in that. I'm capturing the whole path into a variable and passing it to Remove-Item command and I'm getting below error:

Remove-Item : An object at the specified path E:\Import\IRIS_Import\working\RP
LS_BAI_20120719092600450-20120719093206.csv    does not exist.

At E:\Import\IRIS_Import\FIX_IRIS_49_FILES_kr.ps1:53 char:13
+  Remove-Item <<<<  $file
    + CategoryInfo          : InvalidArgument: (:) [Remove-Item], PSArgumentEx 
   ception
    + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RemoveIte 
   mCommand

Not sure why Powershell is complaining about file not being there even I can see the file there physically. Any ideas please?

1
  • Do Test-Path 'E:\Import\IRIS_Import\working\RP LS_BAI_20120719092600450-20120719093206.csv' Commented Jul 20, 2012 at 23:10

2 Answers 2

1

I faced this exact same issue when I ran an Azure powershell webjob. I followed the answer in another thread in addition's to justinf's answer in this thread and modified my remove-item command as below.

remove-item filesystem::\\uncpath\folder
Sign up to request clarification or add additional context in comments.

Comments

0

Your problem is that the file had an - in the file name and powershell does not like this it would seem.

This code worked for me. If it does not work for you post more of your code up and I will take a look.

$test = "c:\test\LS_BAI_20120719092600450-20120719093206.csv"

Remove-Item -LiteralPath $test

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.