-1

How can I install Posh-SSH in a Runbook Powershell?

I need to download files from a SFTP server to Azure Disk using a Runbook Powershll. However there is no Powershell mothod for this and I need to install Posh-ssh module. When I execute Install-Module -Name Posh-SSH -Force inside my Runbook it generates following error:

Exception calling "ShouldContinue" with "2" argument(s): "A command that prompts the user failed because the host program or the command type does not support user interaction. The host was attempting to request confirmation with the following message: PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\Client\AppData\Roaming\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?"

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
user217648
  • 3,338
  • 9
  • 37
  • 61
  • 1
    The error message states that it's waiting for a confirm prompt (but since interactive prompts are not possible within the host Azure Automation uses you can't click yes or no). You can use -Conform:$False to auto approve this OR (even better): install the module within Azure Automation (this is the supported scenario) on the Modules part. – bluuf Jun 22 '20 at 11:14
  • Thanks. How can I install the module within Azure Automation? – user217648 Jun 22 '20 at 11:16
  • I tried -Conform:$False, but it says: A parameter cannot be found that matches parameter name 'Conform'. I downloaded Posh-SSH module as zip file from Github and tried to import it to Azure automation, but it failed. it says: "Error importing the module Posh-SSH-master. Import failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: Cannot import the module of name Posh-SSH-master, as the module structure was invalid." – user217648 Jun 22 '20 at 11:55
  • 1
    In Azure Automation there is a blade called "modules" where you can upload your own (zipped) modules. – bluuf Jun 22 '20 at 15:30

1 Answers1

1

You can import this module as per steps below:

1.Go to your Automation account in azure portal.

2.Under Shared Resources, select Modules.

3.Select Add a module.

4.Select the .zip file that contains your module.

5.Select OK to start to import process.

The official document is here. I also attach a screenshot of the progress here:

enter image description here

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60