PowerShell / WindowsCompatibility

Module that allows Windows PowerShell Modules to be used from PSCore6
Other
137 stars 33 forks source link

IISAdministration does not work on PowerShell 7. #84

Open PeterHodges15 opened 3 years ago

PeterHodges15 commented 3 years ago

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 commented 3 years ago

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.

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
iSazonov commented 3 years ago

Dup #79

iSazonov commented 3 years ago

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

rjmholt commented 3 years ago

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:

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

brettpostin commented 3 years ago

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 commented 3 years ago

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