Powershell -Confirm

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?

clear-host
get-service ccmexec | Stop-Service
get-service bits | Stop-Service
get-service wuauserv | Stop-Service
Remove-Item -Path "c:\windows\softwaredistribution.old" -ErrorAction Ignore -Confirm:$false
Rename-Item -Path "c:\windows\softwaredistribution" -NewName "c:\windows\softwaredistribution.old"
start-service ccmexec
start-service bits
start-service wuauserv

When I run the script

PS C:\util> .\resetsccm.ps1

Confirm
The item at C:\windows\softwaredistribution.old 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"):

If the file exists then rename it otherwise continue and no prompt

 

Thank you

 

Tom

It’s telling you that there are children (e.g. folders\files) under that directory and telling you:

Add the -Recurse parameter:

Remove-Item -Path “c:\windows\softwaredistribution.old” -ErrorAction Ignore -Confirm:$false -Recurse

Rob

 

Thanks that worked.