Set-Location IIS:\AppPools Error

HI,

I am spending a lot of time trying to figure out why a PowerShell will not run on a new server. The offending line of code is "Set-Location IIS:\AppPools" .

When running PowerShell ISE 32 bit I get this error:
Set-Location : Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception 
from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\Temp\PowerShell Temp\BPR App Pool.ISE.ps1:47 char:1
+ Set-Location IIS:\AppPools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-Location], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.SetLocationCommand

Open in new window


Note that I have tried importing WebAdministration although that does not seem to be a requirement when working on the same OS on a different server. Note the server OS is Server 2012 R2 X64.

When I try the same command in PowerShell ISE x64 I get the following error:
Set-Location : Cannot find drive. A drive with the name 'IIS' does not exist.
At line:1 char:1
+ Set-Location IIS:\AppPools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (IIS:String) [Set-Location], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

Open in new window


I then drop back to the PowerShell (X86)  and PowerShell X64 command prompt and enter Set-Location IIS:\AppPools and get this error:
Set-Location : Cannot find drive. A drive with the name 'IIS' does not exist.
At line:1 char:1
+ Set-Location IIS:\AppPools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (IIS:String) [Set-Location], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

Open in new window


What am I missing that is causing the errors? I am especially interested in the Class not registered error. Googling has returned some results with no definitive working answer. I have tried those solutions.

The same commands work fine on another system that appear to be identical in configuration.

Thanks for any insight and help.
ckelsoeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
PS x86 (no ISE) behaves the same? That would be very strange.

The "Class not registered" error occurs if the registry info in the HKEY_Class_Root key is incomplete. The name-to-GUID reference has been found there, but the entries corresponding to that GUID (which is an own key in the registry) are missing. Those missing entries contain the name of the DLL to use, for example, and other parameters.
There is a remote possibility that the key is ok, but the DLL is not found - I'm not positive whether this would show the same error.

Maybe you should just try to install IIS.
ckelsoeAuthor Commented:
"Maybe you should just try to install IIS." - I even tried plugging in the server before turning it on.

PS C:\Windows\system32> Import-Module Servermanager
PS C:\Windows\system32> Add-WindowsFeature Web-Server -IncludeAllSubFeature

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             NoChangeNeeded {}

Open in new window

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Can you try to de- and re-install the feature?
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

ckelsoeAuthor Commented:
Ok - I did a uninstall and reinstall of all IIS features. That has made no difference.

I think part of the issue is that the WebAdministration stuff does not appear to work in PowerShell 32-bit.  That really does not make a lot of sense. Adding to the confusion is there does not seem to be a way to validate which version of ISE I am using (32 vs 64).
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
When I try, the behaviour is consistent:

None of PS or ISE, x86 or x64, is able to find the IIS drive if module WebAdministration is not imported first (note that PS 4 imports modules automatically if you use cmdlets well known to PS, so you might not see a difference if you explicitely import the module).

The x64 ones do not have an issue after importing WebAdministration.

So:
a) You have to import WebAdministration
b) It only works in x64 (on the server itself), because the COM objects are only registred for the original bitness.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Thanks for closing, but do you think a "B" grade is justified?
ckelsoeAuthor Commented:
The solution to this issue is to run the X64 version of PowerShell ISE. IT is not obvious which version of PowerShell ISE you are in from looking at the PowerShell ISE user interface (Unlike the standard PowerShell prompt which clearly indicates X32 or not).
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Of course it is obvious, there is no difference if using PS or ISE:PS-and-ISE-x86.PNG
ckelsoeAuthor Commented:
Thank you for clarifying that Qlemo. I was incorrect in my previous statement. I apologize.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
So you have been confused by not seeing that (visible) difference? That stands to reason then ...
ckelsoeAuthor Commented:
Yes it does. I never saw the X32 marking thus the ISE instance I was in was the X64 version. Which means that the issue should never have occurred since this was a X64 OS and I was in X64 ISE. In the initial post the error was documented (a different error) based on which PowerShell command prompt I was in - X32 or X64. Unfortunately I cannot go back to that VM as I reverted to an earlier snapshot and no longer have that instance available.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.