Pushing PowerShell Set-PSRepository

Comments

7 comments

  • Colby Bouma

    It looks like it's trying to display an "Are you sure?" type of prompt. Trying adding -Force.

    0
    Comment actions Permalink
  • Joseph Monarch

    There is no -Force cmd for Set-PSRepository

    0
    Comment actions Permalink
  • Colby Bouma

    Oops, I should have checked the documentation first.

    Are you sure you need Set-PSRepository? When I wrote this module installation script I never ran into a situation where I needed to use it.

    https://github.com/pdq/PowerShell-Scanners/blob/master/PowerShell%20Scanners/_Shared/Install%20and%20Import%20Module.ps1

    0
    Comment actions Permalink
  • Joseph Monarch

    I disabled step 2 and still received the same error.  I am assuming this is the correct syntax for the module install:

    Install-Module -Name SqlServer -Confirm:$false -AllowClobber

    0
    Comment actions Permalink
  • Colby Bouma

    I use -Force instead of -Confirm:$false on Install-Module.

    0
    Comment actions Permalink
  • Joseph Monarch

    Changed to -Force and still same error.

    0
    Comment actions Permalink
  • Joseph Monarch

    Had to add -Scope CurrentUser to step 1 and 3.  Here is what I have now and it works like a charm with no prompts for the client workstation.

    • Step 1
    • Install-PackageProvider -Name "NuGet" -MinimumVersion "2.8.5.201" -Scope CurrentUser -Force
    • Step 2
    • Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
    • Step 3
    • Install-Module -Name SqlServer -Confirm:$false -AllowClobber -Scope CurrentUser
    0
    Comment actions Permalink

Please sign in to leave a comment.