VMware Cloud Community
efloriot
Contributor
Contributor

Remove-Folder error Powercli 12

Hello

I wrote a script to create folder with no problem except a mistake and folder are notre create to the right folder I write a script to revert using get-fowler and filtering some folder are not to right place but when I try to remove  folder using command like get-folder -id xxxxx | remove-folder -confirm $true I've error about $true

Remove-Folder : Cannot bind parameter 'Folder'. Cannot convert value "True" to type "VMware.VimAutomation.ViCore.Types.V1.Inventory.Folder". Error: "Invalid cast from

'System.Boolean' to 'VMware.VimAutomation.ViCore.Types.V1.Inventory.Folder'."

At C:\Users\xxxxxxx\xxxxxxx\Data\PowercCli\10-1-PSCLI-MoveAppliToApps.ps1:39 char:53

+ Get-Folder -Id $NoExist.id | Remove-Folder -confirm $true

+                                                     ~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Remove-Folder], ParameterBindingException

    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.RemoveFolder

If some one have an idea.

rads.

Eric

Never stop discovering. Eric Floriot
Reply
0 Kudos
3 Replies
berndweyand
Expert
Expert

there is a typo - you have forgotten the colon:

-confirm:$true

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

Moderator: Thread moved to the PowerCLI area.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
LucD
Leadership
Leadership

Since $true is the default for the Confirm, you can leave it out completely.

When you don't want to see the Confirmation prompt, you use $false (with the colon).

Get-Folder -Id $NoExist.id | Remove-Folder -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos