Azure Batch account start task to install powershell module

Wu, Jack 1 Reputation point
2023-01-09T16:20:45.343+00:00

Hi,

I try to use azure batch service's pool start task to in stall powershell modules, I used the pool user with admin, run cmd as : powershell "install-module sqlserver -force" , but it got stuck at nodes start.

If I use remote desktop to login into a node as run as admin role to invoke powershell, then I can install that module, but it has prompt interaction session, such as install nuget tool ,etc . I have to asnwer "yes"...

I believe the start task is stuck due to wait the input as prompt.

How do I resolve that issue?

Thanks

Jack

Azure Batch
Azure Batch
An Azure service that provides cloud-scale job scheduling and compute management.
330 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Luke Murray 11,086 Reputation points MVP
    2023-01-09T19:48:22.527+00:00

    There is a few PS options here: https://stackoverflow.com/questions/16657778/install-nuget-via-powershell-script

    You may need to register the PowerShell gallery etc as well to auto trust modules from them: https://copdips.com/2018/05/setting-up-powershell-gallery-and-nuget-gallery-for-powershell.html

    0 comments No comments

  2. Prrudram-MSFT 24,546 Reputation points
    2023-01-10T17:49:33.037+00:00

    Hi @Wu, Jack ,

    It is likely prompting you because the PSGallery repository is unstrusted.

    install-module sqlserver -Repository PSGallery

    Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):

    As the module says, look at running Set-PSRepository first to trust the PSGallery repository

    Set-PSRepository -?

    NAME Set-PSRepository

    SYNTAX Set-PSRepository [-Name] <string> [[-SourceLocation] <uri>] [-PublishLocation <uri>] [-ScriptSourceLocation <uri>] [-ScriptPublishLocation <uri>] [-Credential <pscredential>] [-InstallationPolicy {Trusted | Untrusted}] [-Proxy <uri>] [-ProxyCredential <pscredential>] [-PackageManagementProvider <string>] [<CommonParameters>]

    Hope this helps. Please accept as answer and upvote if the above information is helpful for the benefit of the community.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.