WindowsCompatibility icon indicating copy to clipboard operation
WindowsCompatibility copied to clipboard

IISAdministration does not work on PowerShell 7.

Open PeterHodges15 opened this issue 5 years ago • 6 comments

IISAdministration does not work on PowerShell 7, even the latest release candidate. I understand that the install does not install a required DLL.
There is also talk that some required 'bits' might not yet be ported to .Net Core. the result is no known (decent) way to manage IIS services via PowerShell 7 WebAdministration is not being ported).
Get-ChildItem IIS: not functional (yet)

Steps to reproduce

install-Module -Name IISAdministration -allowclobber 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.

Expected behavior

Works on Powershell 5

PeterHodges15 avatar Jul 16 '20 23:07 PeterHodges15

I believe these modules are managed by different teams and not the PowerShell team so any fixes to make it compatible needs to be done in the module itself, i.e.

  • DLL compiled to work with .NET core
  • Functions need to use functions/cmdlets that are supported in PowerShell 7

In the case that this isn't available you can use implicit remoting to import the module under PowerShell 5 but call them from PowerShell 7. This is done with the -UseWindowsPowerShell parameter.

PS C:\Windows\System32> Import-Module -Name IISAdministration -UseWindowsPowerShell
WARNING: Module IISAdministration is loaded in Windows PowerShell using WinPSCompatSession remoting session; please note that all input and output of commands from this module will be deserialized objects. If you want to load this module into PowerShell Core please use 'Import-Module -SkipEditionCheck' syntax.

There are some caveats with this, mainly that objects outputted by the module are a de serialized object so you cannot invoke methods on them. You can still access properties like normal though. If you need to get an object and invoke methods on them you can use Invoke-Command and run it in the context of PowerShell v5

$winPS = New-PSSession -UseWindowsPowerShell
Invoke-Command -Session $winPS -ScriptBlock {
    Import-Module -Name IISAdministration

    # Do work here
    ...
}
$winPS | Remove-PSSession

jborean93 avatar Jul 17 '20 01:07 jborean93

Dup #79

iSazonov avatar Jul 17 '20 03:07 iSazonov

See also https://github.com/PowerShell/PowerShell/issues/11792

iSazonov avatar Jul 17 '20 03:07 iSazonov

Dup #79

I think this is technically different since they are different modules, but I believe there has been discussion elsewhere to the effect that:

  • IISAdministration is the newer module and is where any work is likely to be focused
  • I think even IISAdministration depends on APIs that are not intended to be ported to .NET Core (possibly the System.Web.* APIs)
  • Possibly the module does things like export a provider and other things that won't work over a remoting session

So the current guidance is to invoke code as needed with Invoke-Command as in https://github.com/PowerShell/WindowsCompatibility/issues/84#issuecomment-659780181.

The right place to ask for improvements in IISAdministration is probably here but may also be worth providing feedback in the PSGallery

rjmholt avatar Jul 17 '20 03:07 rjmholt

Is the information in this issue still up to date?

Please see my linked issue above.

I have found the IISAdministration module works fine in Powershell Core 7.0.3 however only on my local Windows 10 machine. The 1.1.0.0 version on the PSGallery does not appear to have been updated to work on Core and is missing the required Microsoft.Web.Administration DLL.

brettpostin avatar Oct 20 '20 14:10 brettpostin

Best I can figure, this should be filed to the Forum on: https://login.iis.net/ I did a search and did not find it there.
So I made an entry: https://forums.iis.net/p/1251639/2163053.aspx?p=True&t=637393121339392487

PeterHodges15 avatar Oct 26 '20 19:10 PeterHodges15