Welcome › Forums › General PowerShell Q&A › Powershell -Confirm
- This topic has 2 replies, 2 voices, and was last updated 2 months ago by
Participant.
Viewing 2 reply threads
-
AuthorPosts
-
-
November 20, 2020 at 9:48 am #272986
I have a small script that I need to run stand alone and it prompts me for a response.
I added -confirm:$false but it still prompts me what am I doing wrong here?
PowerShell123456789clear-hostget-service ccmexec | Stop-Serviceget-service bits | Stop-Serviceget-service wuauserv | Stop-ServiceRemove-Item -Path "c:\windows\softwaredistribution.old" -ErrorAction Ignore -Confirm:$falseRename-Item -Path "c:\windows\softwaredistribution" -NewName "c:\windows\softwaredistribution.old"start-service ccmexecstart-service bitsstart-service wuauservWhen I run the script
PowerShell123456PS C:\util> .\resetsccm.ps1ConfirmThe item at C:\windows\softwaredistribution.old has children and the Recurse parameter was not specified. If youcontinue, 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 <del class="gdbbx-bbcode-strikethrough"></del> Suspend [?] Help (default is "Y"):If the file exists then rename it otherwise continue and no prompt
Thank you
Tom
-
This topic was modified 2 months ago by
kvprasoon. Reason: code formatting https://powershell.org/forums/topic/where-are-all-my-posts-over-the-years/
-
This topic was modified 2 months ago by
-
November 20, 2020 at 10:15 am #272998
It’s telling you that there are children (e.g. folders\files) under that directory and telling you:
and the Recurse parameter was not specified.
Add the -Recurse parameter:
PowerShell1Remove-Item -Path “c:\windows\softwaredistribution.old” -ErrorAction Ignore -Confirm:$false -Recurse -
November 20, 2020 at 10:41 am #273019
Rob
Thanks that worked.
-
-
AuthorPosts
Viewing 2 reply threads
- The topic ‘Powershell -Confirm’ is closed to new replies.