- This topic has 2 replies, 2 voices, and was last updated 5 days, 23 hours ago by
November 20, 2020 at 9:48 am #272986ParticipantTopics: 40Replies: 119Points: 646Rank: Major Contributor
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 wuauserv
When I run the scriptPowerShell123456PS 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
- This topic was modified 5 days, 23 hours ago by kvprasoon. Reason: code formatting https://powershell.org/forums/topic/where-are-all-my-posts-over-the-years/
November 20, 2020 at 10:15 am #272998ParticipantTopics: 16Replies: 1842Points: 3,514Rank: Community Hero
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 #273019ParticipantTopics: 40Replies: 119Points: 646Rank: Major Contributor
Thanks that worked.
- The topic ‘Powershell -Confirm’ is closed to new replies.