I'm implementing a custom PowerShell provider. I'm now working on the remove-item cmdlet implementation.
The RemoveItem method has the following signature:
protected override void RemoveItem(string path, bool recurse)
When I type: Remove-Item .\Myobject -recurse
the PowerShell infrastructure provides me with the value true
in the recurse
parameter of the RemoveItem method.
However when I type: Remove-Item .\MyObject' I get a question:
The item at MyObject has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to continue? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
I guess this question is presented to my by the PowerShell infrastructure. This is perfectly fine because the object that I want to remove is a container. If I answer yes to the above question the PowerShell infrastructure does not set the recurse parameter. In fact it is false when my RemoveItem
method is called. I would except the parameter to be true because I answered yes to the question.
My questions are:
Why does PowerShell not set the bool recurse parameter to the correct value?
Do I need to get the value (answer to the question) in some other way? How?
If above is not possible is there a way to suppress the question?