PowerShell: Import-Module IISAdministration Fails With "Could not load file or assembly 'Microsoft.Web.Administration..."
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
On Windows, run the following script in PowerShell 7.2.1:
Install-Module -Name IISAdministration
Import-Module IISAdministration
Get-Module -ListAvailable
I have confirmed on a VM running 19042 that the Windows 10 build is not a factor as far as I can tell, because on a 20H2 VM I still see the problem behavior. I have also enabled IIS Management Console and IIS Management Scripts and Tools. The bulk of the documentation I could find referred to earlier versions of PowerShell 7 not supporting IISAdministration, but this doesn’t seem to apply to 7.2.1 - if it did globally, I wouldn’t have myself and multiple other team members running the scripts with no issues. I appreciate any help!
I did see in issue #13818 the reporter was told to look in the https://github.com/PowerShell/PowerShellModuleCoverage repo and I reported the issue there as well, but then I saw the repo appears to be defunct. Its last commit was literally 4 years ago. ALl the other issues I can find reported for IISAdministration and PowerShell Core / 7 are at least two years old and refer specifically to earlier versions of PowerShell being incompatible, but I can see from the fact that the module works on several developer machines in my department that is no longer true.
Expected behavior
The import should succeed and the module should be listed:
Script 1.1.0.0 IISAdministration Core,Desk {Get-IISServerManager, Set-IISConfigAtt…
Actual behavior
The import fails with the following error:
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.
The Get-Module list shows no cmdlets associated with IISAdministration:
Script 1.1.0.0 IISAdministration Core,Desk
Error details
No response
Environment data
On the machine exhibiting the problem behavior:
PS C:\Users\thoma> $PSVersiontable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
On the machine working successfully:
PS C:\Users\thomas.parikkaADM> $PSVersionTable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (8 by maintainers)
@doctordns Unfortunately, I did not had any luck with this method. I cannot replace the existing files in
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\IISAdministration
All my tests are done in Windows Server 2019 v1809 build 17763.4499
This version of the OS come with version 1.0 of
IISAdministration
and for multiple reasons I need the version1.1.0.0
The commandImport-Module IISAdministration -RequiredVersion 1.1.0.0
(With or without-SkipEditionCheck
) fail. So I need to install the latest version present in the PowerShell Gallery.As mentioned above, install the module in PS7 with the following command:
After the installation:
To solve this, copy
C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll
in the directory where IISAdministration 1.1.0.0 is installed:C:\Program Files\PowerShell\Modules\IISAdministration\1.1.0.0
Now import the module again and it will work:
I hope this can help.