-Confirm:$false not working inside of Start-Job script block

Welcome Forums General PowerShell Q&A -Confirm:$false not working inside of Start-Job script block

Viewing 2 reply threads
  • Author
    Posts
    • #239858
      Participant
      Topics: 1
      Replies: 1
      Points: 14
      Rank: Member

      Noob Alert.  Powershell 7.0.1 on Windows 10.

      As part of a larger script, am trying to submit an ActiveDirectory command, that doesn’t support the -Credential option, with alternate credentials.  The best way I found was using Start-Job

      The issue I am running in to is that I still get this confirmation prompt:

      The configuration of the scopes specified on host server DC1 will be replicated to the partner server. Do you want to perform this action?
      [Y] Yes [N] No [?] Help (default is “Y”):

      I guess I am curious why -Confirm:$false doesn’t work inside of the script block.  And, is there a way I can work around it so the Invoke-DhcpServerv4FailoverReplication command will execute without prompting?

      Just to try, I set $ConfirmPreference to ‘none’ inside the script block…

      ..but that didn’t seem to make any difference.

    • #239864
      Participant
      Topics: 7
      Replies: 123
      Points: 599
      Helping Hand
      Rank: Major Contributor

      Have you tried using -Force and leaving out -Confirm altogether?

    • #239897
      Participant
      Topics: 1
      Replies: 1
      Points: 14
      Rank: Member

      -Force was the answer.  Thanks a bunch.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.