0

I am trying to containerize a webapp using IIS nano docker image.But unable to use "New-IISSiteBinding" commands as IISAdministration version is not up to date(1.0.0.0) .New version is 1.1.0.0

Currently Webapp is running on iis core docker image which is 6GB in size, whereas iis nano is ~500MB. So if I can get this working just be importing webproxy modules, then I will have a lightweight image.

I used this docker image microsoft/iis:nanoserver-sac2016

I did the below steps

1) Ran Save-Module -Name IISAdministration -Path D:\

This command was executed on another machine, Copied the D:\IISAdministration folder to "C:\Program Files\WindowsPowerShell\Modules\IISAdministration" and Restarted the Container.

When I executed Import-Module -Name IISAdministration, I saw these errors. If I remove the "C:\Program Files\WindowsPowerShell\Modules\IISAdministration" folder and execute "Import-Module -Name IISAdministration", then it works.

PS C:\> Import-Module -Name IISAdministration
Import-Module : Could not load file or assembly 'Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
At line:1 char:1
+ Import-Module -Name IISAdministration
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

PS C:\> Import-Module -Name 'C:\Program Files\WindowsPowerShell\Modules\IISAdministration\1.1.0.0\IISAdministration.psd1'
Import-Module : Could not load file or assembly 'Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
At line:1 char:1
+ Import-Module -Name 'C:\Program Files\WindowsPowerShell\Modules\IISAd ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

2) I tried installing via command Install-Module -Name IISAdministration

We are behind proxy. So in order to download, I set Proxy variable and tried to download. Then I got this error.

PS C:\> .\install_iis.ps1
New-Object : Cannot find type [System.Net.Webproxy]: verify that the assembly containing this type is loaded.
At C:\install_iis.ps1:11 char:44
+ ... equest]::defaultwebproxy = New-Object System.Net.Webproxy($proxy_url)
+                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

The property 'BypassProxyOnLocal' cannot be found on this object. Verify that the property exists and can be set.
At C:\install_iis.ps1:14 char:1
+ [system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

Pre-Install Docker Provider - need Nuget. About to Install..
Install-PackageProvider : Cannot bind parameter 'Proxy'. Cannot convert value "http://:8080" to type "System.Uri".
Error: "Invalid URI: The hostname could not be parsed."
At C:\install_iis.ps1:20 char:87
+ ...  -Verbose -RequiredVersion 2.8.5.201 -Force -Proxy $proxy_url -ProxyC ...
+                                                        ~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Install-PackageProvider], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
   kageProvider


NuGet provider is required to continue
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\ContainerAdministrator\AppData\Local\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?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Install-PackageProvider : No match was found for the specified search criteria for the provider
'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package
has the tags.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7405 char:21
+ ...     $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac
   kageProvider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro
   vider

PackageManagement\Import-PackageProvider : No match was found for the specified search criteria and provider name
'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7411 char:21
+ ...     $null = PackageManagement\Import-PackageProvider -Name $script:Nu ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (NuGet:String) [Import-PackageProvider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProv
   ider

WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Get-PackageProvider : Unable to find package provider 'NuGet'. It may not be imported yet. Try
'Get-PackageProvider -ListAvailable'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7415 char:30
+ ... tProvider = PackageManagement\Get-PackageProvider -Name $script:NuGet ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvi
   der], Exception
    + FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPacka
   geProvider

Install-Module : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201'
or newer version of NuGet provider is installed.
At C:\install_iis.ps1:22 char:2
+  Install-Module -Name IISAdministration -RequiredVersion 1.1.0.0
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Install-Module], InvalidOperationException
    + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module

I saw that nanoserver wont have [System.Net.Webproxy] modules enabled by default.
Can you please help

1) Why manual loading of IISAdministration package failed in Step 1.

2) If Step 1 is not possible, how can I install IISAdministration module 1.1.0.0 after importing [System.Net.Webproxy] modules and its dependencies.

Thanks in advance.
Vishnu

Update 1

I tried as @TheIncorrigible1 suggested as answer.
I copied "iisadministration.1.1.0.nupkg" to c:\test and executed "Register-PSRepository -InstallationPolicy Trusted -Name tmp -SourceLocation C:\test" .

I am seeing message to install Nuget. But it is already there.

enter image description here

VVP
  • 766
  • 4
  • 14
  • 39
  • The default PowerShellGet is too old. Update it first and then you might get some progress, https://learn.microsoft.com/en-us/powershell/gallery/installing-psget The same section on Microsoft Docs shows more on how to install things from the Gallery. – Lex Li Aug 31 '18 at 13:43

1 Answers1

0

Simply dropping the download into a modules folder won't set it up properly. You can get the module from the powershellgallery. From here, it can be deployed onto your nano server.

Next, you'll want to register a local repo. Point SourceLocation where you drop your module nupkg.

Register-PSRepository -InstallationPolicy Trusted -Name tmp -SourceLocation C:\tmp

And finally:

Install-Module -Name IISAdministration -Repository tmp -Scope AllUsers -Force
Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63
  • Thanks. Please see Update 1. I am being prompted to install nuget even though it is already there. Thoughts pls? – VVP Aug 31 '18 at 04:48
  • @VVP Hm.. I'm not seeing a correlating `Save-PackageProvider` that could be installed separately and don't have enough knowledge here to help further. Try using `Import-PackageProvider` – Maximilian Burszley Aug 31 '18 at 05:04