|
| Powershell Execute process |
 |
Tue, 15 Apr 2008 23:10:08 -070 |
I want to execute a command at remote DMZ server with below line. But
it is not authenticating the password and giving access denied error
even though password is correct & able to access remote share with
same password.
$ProcessClass = get-wmiobject -query "SELECT * FROM Meta_Class WHERE
__Class = 'Win32_Process'" -namespace "root\cimv2" -credential
$(Get-
Credential) -computername $computer
$results = $ProcessClass.Create( $commandline )
::::::::::Error :::::::::
Exception retrieving member "Create": "Access is denied.
(Exception
from HRESUL
T: 0x80070005 (E_ACCESSDENIED))"
At C:\ExeCmd.ps1:72 char:11
+ $results = <<<< $ProcessClass.Create($commandline)
|
| Post Reply
|
| RE: Powershell Execute process |
 |
Wed, 16 Apr 2008 00:37:00 -070 |
This has come up before if I remember correctly. You need to do the
get-credential as a seperate prior step
$cred = get-credential
get-wmiobject ........... -credentials $cred ..........
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk
"Amit Tank" wrote:
> I want to execute a command at remote DMZ server with below line. But
> it is not authenticating the password and giving access denied error
> even though password is correct & able to access remote share with
> same password.
>
> $ProcessClass = get-wmiobject -query "SELECT * FROM Meta_Class
WHERE
> __Class = 'Win32_Process'" -namespace "root\cimv2"
-credential $(Get-
> Credential) -computername $computer
> $results = $ProcessClass.Create( $commandline )
>
> ::::::::::Error :::::::::
> Exception retrieving member "Create": "Access is denied.
(Exception
> from HRESUL
> T: 0x80070005 (E_ACCESSDENIED))"
> At C:\ExeCmd.ps1:72 char:11
> + $results = <<<< $ProcessClass.Create($commandline)
>
> Any idea how to pass the credential safely?
|
| Post Reply
|
| Re: Powershell Execute process |
 |
Wed, 16 Apr 2008 00:51:19 -070 |
I tried that and checked again but same error.
It takes credential correctly when we give below
$ProcessClass = get-wmiobject -class "Win32_Process" -namespace
"root
\cimv2" -credential $(Get-Credential) -computername $computer
But this code doesn't allow to run create( ) method to execute command
at remote machine like below.
$results = $ProcessClass.Create( $commandline )
On Apr 16, 3:37 am, RichS [MVP] <RichS...@discussions.microsoft.com>
wrote:
> This has come up before if I remember correctly. You need to do the
> get-credential as a seperate prior step
>
> $cred = get-credential
> get-wmiobject ........... -credentials $cred ..........
>
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
>
>
> "Amit Tank" wrote:
> > I want to execute a command at remote DMZ server with below line. But
> > it is not authenticating the password and giving access denied error
> > even though password is correct & able to access remote share
with
> > same password.
>
> > $ProcessClass = get-wmiobject -query "SELECT * FROM Meta_Class
WHERE
> > __Class = 'Win32_Process'" -namespace "root\cimv2"
-credential $(Get-
> > Credential) -computername $computer
> > $results = $ProcessClass.Create( $commandline )
>
> > ::::::::::Error :::::::::
> > Exception retrieving member "Create": "Access is
denied. (Exception
> > from HRESUL
> > T: 0x80070005 (E_ACCESSDENIED))"
> > At C:\ExeCmd.ps1:72 char:11
> > + $results = <<<< $ProcessClass.Create($commandline)
>
> > Any idea how to pass the credential safely?- Hide quoted text -
>
> - Show quoted text -
|
| Post Reply
|
| Re: Powershell Execute process |
 |
Wed, 16 Apr 2008 02:34:13 -070 |
I tried other two methods also and let me explain in detail.
I want to execute a process on a server which is in DMZ & workgroup
from my domain.
It works if,
- If I keep the same password of my domain ID and user ID of that
server then it works.
- I can access the \\ServerName\C$ with my user ID of DMZ server from
domain.
- If I run these scripts against a server which is in same domain then
it works.
It doesn't work
- If passwords are different for my domain ID and user ID of remote
DMZ server and if I pass the password through PowerShell.
## 1 ##
$co = new-object management.connectionoptions
$co.Username = "ServerName\UserID"
$co.SecurePassword = (read-host -assecurestring)
$scope = new-object management.managementscope "\\ServerName\root
\cimv2",$co
$scope.Connect()
$mp = new-object management.managementpath "win32_process"
$ogo = new-object management.objectgetoptions
$proc = new-object management.managementclass $scope,$mp,$ogo
$proc.Create("notepad.exe")
## 2 ##
$comp = "ServerName"
$cre = get-credential ServerName\UserID
$win32ProcessClass = Get-WmiObject -List -Namespace 'root\cimv2' -
credential $cre -computername $comp | Where-Object { $_.Name -eq
'Win32_Process' }
$win32ProcessClass.Create("notepad.exe")
Any help is really appreciated.
Amit
On Apr 16, 3:51 am, Amit Tank <amitmt...@gmail.com> wrote:
> I tried that and checked again but same error.
>
> It takes credential correctly when we give below
> $ProcessClass = get-wmiobject -class "Win32_Process" -namespace
"root
> \cimv2" -credential $(Get-Credential) -computername $computer
>
> But this code doesn't allow to run create( ) method to execute command
> at remote machine like below.
> $results = $ProcessClass.Create( $commandline )
>
> On Apr 16, 3:37 am, RichS [MVP] <RichS...@discussions.microsoft.com>
> wrote:
>
>
>
> > This has come up before if I remember correctly. You need to do the
> > get-credential as a seperate prior step
>
> > $cred = get-credential
> > get-wmiobject ........... -credentials $cred ..........
>
> > --
> > Richard Siddaway
> > All scripts are supplied "as is" and with no warranty
> > PowerShell MVP
> > Blog:http://richardsiddaway.spaces.live.com/
> > PowerShell User Group:http://www.get-psuguk.org.uk
>
> > "Amit Tank" wrote:
> > > I want to execute a command at remote DMZ server with below line.
But
> > > it is not authenticating the password and giving access denied
error
> > > even though password is correct & able to access remote share
with
> > > same password.
>
> > > $ProcessClass = get-wmiobject -query "SELECT * FROM
Meta_Class WHERE
> > > __Class = 'Win32_Process'" -namespace
"root\cimv2" -credential $(Get-
> > > Credential) -computername $computer
> > > $results = $ProcessClass.Create( $commandline )
>
> > > ::::::::::Error :::::::::
> > > Exception retrieving member "Create": "Access is
denied. (Exception
> > > from HRESUL
> > > T: 0x80070005 (E_ACCESSDENIED))"
> > > At C:\ExeCmd.ps1:72 char:11
> > > + $results = <<<<
$ProcessClass.Create($commandline)
>
> > > Any idea how to pass the credential safely?- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
|
| Post Reply
|
| Re: Powershell Execute process |
 |
Wed, 16 Apr 2008 07:15:15 -070 |
Thanks for the information Macro. :)
Is it corrected in v2? if you come across. Or any alternate way to
execute process.
On Apr 16, 4:40 pm, "Marco Shaw [MVP]"
<marco.shaw@_NO_SPAM_gmail.com>
wrote:
> I'm sorry, what are you identifying here:
>
>
>
>
>
> > ## 1 ##
> > $co = new-object management.connectionoptions
> > $co.Username = "ServerName\UserID"
> > $co.SecurePassword = (read-host -assecurestring)
> > $scope = new-object management.managementscope
"\\ServerName\root
> > \cimv2",$co
> > $scope.Connect()
> > $mp = new-object management.managementpath "win32_process"
> > $ogo = new-object management.objectgetoptions
> > $proc = new-object management.managementclass $scope,$mp,$ogo
> > $proc.Create("notepad.exe")
>
> > ## 2 ##
> > $comp = "ServerName"
> > $cre = get-credential ServerName\UserID
> > $win32ProcessClass = Get-WmiObject -List -Namespace 'root\cimv2' -
> > credential $cre -computername $comp | Where-Object { $_.Name -eq
> > 'Win32_Process' }
> > $win32ProcessClass.Create("notepad.exe")
>
> Neither works in your last scenario?
>
> I understand there are some small cross-domain authentation issues with
> get-wmiobject in v1.
>
> Marco
>
> --
> Microsoft MVP - Windows PowerShellhttp://www.microsoft.com/mvp
>
> PowerGadgets MVPhttp://www.powergadgets.com/mvp
>
> Blog:http://marcoshaw.blogspot.com- Hide quoted text -
>
> - Show quoted text -
|
| Post Reply
|
|
|
|
|
|
|
|
|
|