Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

PowerShell WMI explorer update for PowerShell V2 CTP

I got a question from Dee about using alternate credentials with my PowerShell .

This is not possible in version 1.0 of PowerShell because of a bug in the WMI adapter, hence I removed this from my PowerShell WMI explorer also at that time, but if you are using the PowerShell V2 CTP this will be possible again .

When you doubleClick the Server field in the status you can set the connection options, if you fill in the username in the options (there will be no password field ), when you click the connect button you will get asked for credentials and can connect with different credentials.

Doubleclicking the server field works also in former version and all other connections options can also be set, but you will not get the credential box, you can use this new version (only 2 lines added) also in V1 but connection using alternate credentials will fail anyway.

 As Dee did upgrade to the PowerShell V2CTP for this I posted this quick fix, I will make it more discoverable in a later update.

Enjoy,

Greetings /\/\o\/\/

Published Wednesday, March 05, 2008 5:16 PM by MoW
Filed under: ,

Attachment(s): WmiExplorer.ps1

Comments

# re: PowerShell WMI explorer update for PowerShell V2 CTP

Thank you so much!  I downloaded the above attachment, but when executing the WmiExplorer.ps1 I get the following error:

File C:\@#@@@\@@#@#@@\WmiExplorer.ps1 cannot be loaded. The file Wmi

Explorer.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" fo

r more details..

At line:1 char:18

+ ./wmiexplorer.ps1 <<<<

Thanks!

Dee

Thursday, March 06, 2008 9:16 AM by dee

# re: PowerShell WMI explorer update for PowerShell V2 CTP

nevermind.. i found the trick:

To run an unsigned script:

Save the script file on your computer.

Click Start, click My Computer, and navigate to the saved script file.

Right-click the script file, and then click "Properties."

Click "Unblock."

Thanks!

Dee

Thursday, March 06, 2008 9:19 AM by dee

# re: PowerShell WMI explorer update for PowerShell V2 CTP

It worked like a charm!  thank you so much!  many thanks to you!  FYI to any other users that want to put in credentials.  at first when I put just the username it did not work.  The trick was to do username@domain.com

Awesome!  thanks!

Dee

deepakm@rice.edu

Thursday, March 06, 2008 9:29 AM by dee

# Interesting Finds: March 6, 2008

Thursday, March 06, 2008 9:43 AM by Jason Haley

# re: PowerShell WMI explorer update for PowerShell V2 CTP

I must be doing something wrong.  I have not problem conneting to the remote server, but when browsing the namespaces to ROOT\CIMV2 or any of the other namespaces, I get the following error:

"Unhandled exception has occured in a component in your application.  If you click Continue, the application will ignore this error and attempt to continue.

Exception calling "GetInstances" with "0" argument(s): Acces is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

I have no issues accessing via other apps or what not with these credentials.  If I select continue it just continues with the same error...  any ideas  thank you so much.  i look forward to this!  :)

Dee

Thursday, March 06, 2008 9:46 AM by dee

# re: PowerShell WMI explorer update for PowerShell V2 CTP

Here is the details of the error as well:

See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************

System.Management.Automation.MethodInvocationException: Exception calling "GetInstances" with "0" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

  at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

  at System.Management.ManagementScope.InitializeGuts(Object o)

  at System.Management.ManagementScope.Initialize()

  at System.Management.ManagementObject.Initialize(Boolean getObject)

  at System.Management.ManagementClass.GetInstances(EnumerationOptions options)

  at System.Management.ManagementClass.GetInstances()

  --- End of inner exception stack trace ---

  at System.Management.Automation.DotNetAdapter.AuxiliarMethodInvoke(Object target, MethodBase method, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)

  at System.Management.Automation.DotNetAdapter.MethodInvokeDotNet(String methodName, Object target, MethodBase[] methods, MethodInformation[] methodInformation, String[] methodDefinitions, Object[] arguments)

  at System.Management.Automation.DotNetAdapter.MethodInvoke(PSMethod method, Object[] arguments)

  at System.Management.Automation.Adapter.BaseMethodInvoke(PSMethod method, Object[] arguments)

  at System.Management.Automation.PSMethod.Invoke(Object[] arguments)

  at System.Management.Automation.ParserOps.CallMethod(Token token, Object target, String methodName, Object[] paramArray, Boolean callStatic, PSMethodInfo targetMethod, Object valueToSet)

  at System.Management.Automation.MethodCallNode.InvokeMethod(Object target, Object[] arguments, Object value)

  at System.Management.Automation.MethodCallNode.Execute(Array input, Pipe outputPipe)

  at System.Management.Automation.PipelineNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList)

  at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList& resultList)

************** Loaded Assemblies **************

mscorlib

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

----------------------------------------

Microsoft.PowerShell.ConsoleHost

   Assembly Version: 1.0.0.0

   Win32 Version: 6.1.6480.1

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.PowerShell.ConsoleHost/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.ConsoleHost.dll

----------------------------------------

System.Management.Automation

   Assembly Version: 1.0.0.0

   Win32 Version: 6.1.6480.1

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Management.Automation/1.0.0.0__31bf3856ad364e35/System.Management.Automation.dll

----------------------------------------

System

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

----------------------------------------

System.Xml

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll

----------------------------------------

System.Configuration.Install

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration.Install/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.Install.dll

----------------------------------------

Microsoft.PowerShell.Commands.Management

   Assembly Version: 1.0.0.0

   Win32 Version: 6.1.6480.1

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.PowerShell.Commands.Management/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Commands.Management.dll

----------------------------------------

System.Management

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Management/2.0.0.0__b03f5f7f11d50a3a/System.Management.dll

----------------------------------------

System.ServiceProcess

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.ServiceProcess/2.0.0.0__b03f5f7f11d50a3a/System.ServiceProcess.dll

----------------------------------------

Microsoft.PowerShell.Security

   Assembly Version: 1.0.0.0

   Win32 Version: 6.1.6480.1

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.PowerShell.Security/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Security.dll

----------------------------------------

Microsoft.PowerShell.Commands.Utility

   Assembly Version: 1.0.0.0

   Win32 Version: 6.1.6480.1

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.PowerShell.Commands.Utility/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Commands.Utility.dll

----------------------------------------

System.Data

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll

----------------------------------------

System.DirectoryServices

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.DirectoryServices/2.0.0.0__b03f5f7f11d50a3a/System.DirectoryServices.dll

----------------------------------------

System.Windows.Forms

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

----------------------------------------

System.Drawing

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

----------------------------------------

Accessibility

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

----------------------------------------

System.Design

   Assembly Version: 2.0.0.0

   Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)

   CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Design/2.0.0.0__b03f5f7f11d50a3a/System.Design.dll

----------------------------------------

************** JIT Debugging **************

To enable just-in-time (JIT) debugging, the .config file for this

application or computer (machine.config) must have the

jitDebugging value set in the system.windows.forms section.

The application must also be compiled with debugging

enabled.

For example:

<configuration>

   <system.windows.forms jitDebugging="true" />

</configuration>

When JIT debugging is enabled, any unhandled exception

will be sent to the JIT debugger registered on the computer

rather than be handled by this dialog box.

Thursday, March 06, 2008 9:46 AM by dee

# re: PowerShell WMI explorer update for PowerShell V2 CTP

@dee,

are you sure you try this on the PowerShell V2 CTP ?

as I can not reproduce this and it's looks like the WMI wrapper bug in PowerShell V 1.0

If you are using the CTP posting on the powershell newsgroup (linkin sidebar) might be good idea.

Greetings /\/\o\/\/

Friday, March 07, 2008 4:38 AM by MoW

# re: PowerShell WMI explorer update for PowerShell V2 CTP

MOW,

I get the same crash v2 CTP and Vista Enterprise SP1 as both std user or with elevated privs. PSCX is loaded as well.

Does the same when called from PS+ as well.

Best regards,

Pete

Friday, March 07, 2008 11:16 AM by PGomersall

# re: PowerShell WMI explorer update for PowerShell V2 CTP

I'm sure i'm using PowerShell V2 CTP.  How can I double check?  what is the linkin sidebar?  I look forward to a resolution.  Thanks!

Dee

Friday, March 07, 2008 1:42 PM by dee

# re: PowerShell WMI explorer update for PowerShell V2 CTP

Dee,

I will look into this further, but have no way to test till next week.

sorry,

Greetings /\/\o\/\/

Saturday, March 08, 2008 5:00 AM by MoW

# re: PowerShell WMI explorer update for PowerShell V2 CTP

MOW,

I think I found what the issues are (for me at least) with it crashing.

First I was connecting. Then if you hit the "Get Instances" button with either no classes received or not yet received you got the crash. Can you add some checking - maybe disable the "Get Instances" button until a valid class is received or clicked on?

Pete

Saturday, March 08, 2008 9:12 AM by PGomersall

# Sql Server, WMI and PowerShell

So I started out on a quest: a quest for the overview of installed SQL Server instances on my machine.

Wednesday, March 12, 2008 6:37 AM by Peter's Pattern

# PowerScripting Podcast - Episode 22 &quot;The One About Brandon&quot; &laquo; PowerScripting Podcast

# re: PowerShell WMI explorer update for PowerShell V2 CTP

Hi all.  I'm having allot of fun with PowerShell.  I'm learning allot thanks to you.

Few questions.  

1) What object can I query that would provide Memory size and free space?

2) What object can I query that would provide HDD space and free space?

what current partitions of the server?

what RAID level a server is?

3) How would I write an If statement to say If server is in a certain IP range write "Location: something"?

4) I am able to get the IP address via the Win32_NetworkAdapterConfiguration object, but not sure why I can't get the gateway, subnet and NIC name.  Any ideas?

Thank you so much again.  I look forward to your feedback  Cheers to ScriptingAnswres.com.  I've forwarded few other friends that are learning powershell as well.  I'm thinking of getting some books as well.

Thanks!

dee

deepakm@rice.edu

Tuesday, April 08, 2008 1:12 PM by dee

# re: PowerShell WMI explorer update for PowerShell V2 CTP

Hi all.  I'm having allot of fun with PowerShell.  I'm learning allot thanks to you.

Few questions.  

1) What object can I query that would provide Memory size and free space?

2) What object can I query that would provide HDD space and free space?

what current partitions of the server?

what RAID level a server is?

3) How would I write an If statement to say If server is in a certain IP range write "Location: something"?

4) I am able to get the IP address via the Win32_NetworkAdapterConfiguration object, but not sure why I can't get the gateway, subnet and NIC name.  Any ideas?

Thank you so much again.  I look forward to your feedback  Cheers to thepowershellguy.com.  I've forwarded few other friends that are learning powershell as well.  I'm thinking of getting some books as well.

Thanks!

dee

deepakm@rice.edu

Tuesday, April 08, 2008 1:12 PM by dee

# Weird Issues Loading Drawing.Color

I'm just starting to learn Powershell and this tool looks awesome.  I am having some trouble getting it to work though.  I get the following erorr...

Unable to find type [Drawing.Color]: make sure that the assembly containing this type is loaded.

At C:\tools\powershell\bin\WmiExplorer.ps1:757 char:40

+ Function Set-StatusBar ([Drawing.Color]$ <<<< Color,$Text) {

Any help would be great!

Wednesday, April 16, 2008 3:04 PM by bsweeney1977

# re: Weird Issues Loading Drawing.Color

I get the same message :

Unable to find type [Drawing.Color]: make sure that the assembly containing this type is loaded.

At C:\tmp\WmiExplorer.ps1:757 char:40

+ Function Set-StatusBar ([Drawing.Color]$ <<<< Color,$Text) {

Any suggestions would be great - thx

Thursday, May 01, 2008 4:38 PM by richard
Anonymous comments are disabled