Login | |
|
 |
RE: Powershell WMI Permissions issue - 9/18/2007 10:47:18 AM
|
|
 |
|
| |
dm_4ever
Posts: 1944
Score: 30
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
I think you would need to use the Get-Credential cmdlet $credentials = Get-Credential gwmi win32_process -computer "COMPUTER" -credential $credentials
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Powershell WMI Permissions issue - 9/19/2007 1:45:34 AM
|
|
 |
|
| |
ebgreen
Posts: 4411
Score: 29
Joined: 7/12/2005
Status: offline
|
Ok, some more info. I can run the powershell as an admin then get the remote processes fine. It is just when I run as a regular user and try to pass credentials that I have a problem.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Powershell WMI Permissions issue - 9/19/2007 2:23:15 AM
|
|
 |
|
| |
SAPIENScripter
Posts: 261
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
|
The first thing to remember is that PowerShell is abstracting the .NET classes that work with WMI and those are very different than the COM object we use in VBScript. So I wouldn't be totally surprised if there are differences. Now I have run into issues with WMI when the computer I'm querying FROM is not in a trusted domain. You also mention running as adminstrator. Does this mean you are running your script FROM a Vista desktop? What is the OS on the remote machine? Vista, UAC and PowerShell add yet another hurdle.
_____________________________
Jeffery Hicks Windows PowerShell MVP SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com
|
|
| |
|
|
|
 |
RE: Powershell WMI Permissions issue - 9/19/2007 2:42:30 AM
|
|
 |
|
| |
ebgreen
Posts: 4411
Score: 29
Joined: 7/12/2005
Status: offline
|
The remote and local machine are both XP. I am 90% certain it is a permissions issue in component permissions I just can't figure out what needs to change.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Powershell WMI Permissions issue - 9/19/2007 5:35:23 AM
|
|
 |
|
| |
SAPIENScripter
Posts: 261
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
|
This does seem odd. If both machines are in the domain, then gwmi win32_process -computer "COMPUTER" -credential "DOMAIN\USER" assuming domain\user is an administrator on the remote computer, then this should work. I just tested it between two laptops that are in workgroups, not even domains. I specified the local administrator account on the remote computer and it worked. Wait one...check that. I ran gwmi win32_process -computer "COMPUTER" -credential "DOMAIN\USER" | select name and it worked. I just tried it without piping results to Select and I get: format-default : Exception retrieving members: "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" I'll keep digging.
_____________________________
Jeffery Hicks Windows PowerShell MVP SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com
|
|
| |
|
|
|
 |
RE: Powershell WMI Permissions issue - 9/19/2007 6:11:15 AM
|
|
 |
|
| |
SAPIENScripter
Posts: 261
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
|
In looking at my event log on the remote computer, I can see the authentication for the passed credentials. But I also see failed authentication attempts using the credential of the current logged on user on my computer which of course will fail since the machines are in workgroups. I'm assuming the same thing is happening here. There is some secondary .NET process that PowerShell is calling that doesn't pass the alternate credential. I'm assuming when you get the error, you are using an account that doesn't have admin rights on the remote machine. So PowerShell/.NET is starting a new thread that doesn't inherit the alternate credentials. It inherits the security context of the parent thread, ie PowerShell which is why this all works when you try this from a PowerShell session running under admin credentials. Do you need to see every single process property? PowerShell doesn't seem to object when you pipe GWMI to Select. There's something about the formatting process where PowerShell/.NET is trying to access something else on the remote system but with invalid credentials.
_____________________________
Jeffery Hicks Windows PowerShell MVP SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com
|
|
| |
|
|
|
 |
RE: Powershell WMI Permissions issue - 9/19/2007 6:16:51 AM
|
|
 |
|
| |
ebgreen
Posts: 4411
Score: 29
Joined: 7/12/2005
Status: offline
|
Thanks for looking into this for me. I will try using the Select trick. I have a function that will start a new process with a specified user's context so for the time beign I can just run powershell with the admin account when I need to access the remote machine. I just wish it worked the way that I expected it to.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|