The input object cannot be bound to any parameters

Hi Everyone,

i am new Powershell, I’m having a small issue. i just need to echo yes to the Remove-Item command. but i am getting “Remove-Item : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:1 char:12”

not sure what that means? what am i doing wrong?

 

code:

ECHO 'Y' | Remove-Item –path C:\Users\UserName\Desktop\test_DIR\NightlyBK

 

 

 

 

 

 

 

 

 

If you are passing input to the confirmation prompt of Remove-Item cmdlet, then what you need here is -Force switch.

More information here in

Get-Help Remove-Item -Parameter Force

That’s not really what the pipeline is for, recommend that you get a book and understand the basic concepts. Adding a -Force or -Confirm:$false should override the prompt:

PS C:\WINDOWS\system32> Remove-Item -Force -Confirm:$false

[quote quote=198005][/quote]
ah, ok. thanks i will look into it!

Hi Rob, I appreciate your feedback. I am currently reading many different articles and watching many videos on the subject. As mentioned in my original post I’m new to this, hence why came to a forum with experts looking for advice. i am struggling with the pipeline concept. In my mind it would seem an echo yes would go before the command to delete the directory, since you’re going to be prompted for a yes or no responce. And since the pipeline just connects the output of the first into the input of the second, conceptually I thought this made sense.

But as I pointed out my post (I’m doing something wrong) and looking for expertise in helping me understand where I’ve made my mistake. I appreciate your feedback, but next time could you add some recommended reading. Again I’m new to power shell commands, I’m just struggling with this one very simple command. Once I get it figured out I will continue researching more power shell until I get stuck on the next one.

I assume forms like this are meant to help people like me who are not as proficient as people like you.

Again thanks for the feedback

thanks guys,

with both your help, i got it working. The only extra thing I need to do outside of your advice was to add the Recurse switch to the command to clear out the sub items.

Remove-Item –path C:\Users\Username\Desktop\test_DIR\NightlyBK -Force –recurse

Maybe this could help

and look for Learning Powershell in a month of Lunches. The Book, not just the Videos. It’s great for a solid foundation

[quote quote=198539]Maybe this could help

Understanding Streams, Redirection, and Write-Host in PowerShell
<iframe class="wp-embedded-content" title="" src="https://devblogs.microsoft.com/scripting/understanding-streams-redirection-and-write-host-in-powershell/embed/#?secret=dU3diphXqF" width="600" height="325" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" sandbox="allow-scripts" data-secret="dU3diphXqF" data-mce-fragment="1"></iframe>

and look for Learning Powershell in a month of Lunches. The Book, not just the Videos. It’s great for a solid foundation

[/quote]

 

this is great, thanks!