0
votes

I'm running Win7 Enterprise.

My goal is to use the webadministration Powershell module with Powershell 2.0 and PowerGUI.

The module works correctly, but I get errors the next time I launch PowerGUI.

Here are the steps to reproduce the problem:

1) Open PowerGUI 3.1.0.2058.

2) Install the "webadministration" module for IIS.

I can do this with the Import-Module cmdlet or the "File > Powershell Libraries" menu item in PowerGUI.

It doesn't matter. I get the same results either way.

3) The webadministration module works as expected.

4) Quit PowerGUI.

5) Open PowerGUI.

I get a long list of error messages that seem to indicate that webadministration is causing name clashes with itself.

Example:

Import-Module : The term 'Microsoft.IIS.PowerShell.Provider\Start-WebCommitDelay' resolved to a cmdlet name that is ambiguous. Possible matches include: Microsoft.IIS.PowerShell.Provider\St art-WebCommitDelay Microsoft.IIS.PowerShell.Provider\Start-WebCommitDelay. At line:1 char:288 + @('C:\Windows\system32\WindowsPowerShell\v1.0\Modules\webadministration\Microsoft.IIS.PowerShell.Provider.dll','C:\Windows\system32\WindowsPowerShell\v1.0\Modules\webadministration\webadm inistration.psd1') | Where-Object { @(Get-Module | %{$.Path} ) -notcontains $ } | %{ Import-Module <<<< $_ } + CategoryInfo : ObjectNotFound: (Microsoft.IIS.P...-WebCommitDelay:String) [Import-Module], ParentContainsErrorRecordException + FullyQualifiedErrorId : CmdletNameAmbiguous,Microsoft.PowerShell.Commands.ImportModuleCommand

If I use Remove-Module to uninstall webadministration before quitting PowerGUI, I don't get the error messages the next time I launch PowerGUI.

Is there a rule that modules have to be uninstalled before quitting PowerGUI?

I've tried the same set of steps (don't use Remove-Module) with Microsoft's ISE and I don't have any problems there.

Where is PowerGUI remembering the import? I thought Import-Module was only per Powershell sesssion.

Please enlighten me.

Thanks!

Adam Leffert http://www.leffert.com

2

2 Answers

0
votes

A few things to check:

The profile scripts, current and all user from the PowerGUI file menu.

Go File / PowerShell libraries and make sure it's not checked in there.

Also under Tools / Options / Debug options select reset PowerShell run space and uncheck load profiles.

0
votes

Both profile files are empty.

I set the Debug options as you described.

If I only use the "File > Powershell Libraries" menu and don't use the command line to import modules, PowerGui still does not work correctly with the webadministration module.

Steps:

1) Open PowerGui (PG).

2) Check the "webadministration 1.0.0" module in the PS Libraries dialog.

Click OK to close the dialog.

webadministration module is loaded and works.

3) Quit PG.

4) Open PG again.

All looks to be well (but it isn't).

5) Quit PG.

6) Open PG again.

PG fails to import the module and throws the errors.

This failure makes some sense if you peek at the "File > Powershell Libraries" dialog between steps 4 and 5.

When you do this, you'll see that although you only checked the "webadministration" module, when you look at this dialog between steps 4 and 5, you'll see that this module and the

"Microsoft.IIS.Powershell.Provider" module are both checked.

To work around this problem, you can check "Microsoft.IIS.Powershell.Provider" instead of "webadministration" in step 2.

If you do this, PG works correctly.

So thanks for setting me on the right path.

I'm somewhat curious why "webadministration" doesn't work, but of course I can just use the module that works correctly.