Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

IISAdministration does not work on PowerShell 7. #84

Open
PeterHodges15 opened this issue Jul 16, 2020 · 6 comments
Open

IISAdministration does not work on PowerShell 7. #84

PeterHodges15 opened this issue Jul 16, 2020 · 6 comments

Comments

@PeterHodges15
Copy link

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

@jborean93
Copy link

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

@rjmholt rjmholt transferred this issue from PowerShell/PowerShell Jul 17, 2020
@iSazonov
Copy link

Dup #79

@iSazonov
Copy link

See also PowerShell/PowerShell#11792

@rjmholt
Copy link

rjmholt commented Jul 17, 2020

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 #84 (comment).

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

@brettpostin
Copy link

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.

@PeterHodges15
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants