Char(DesertFish)

A desert-fish want to go heaven.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
Function as below:
function Create-ProcessWithWMI ($computer = ".", $commandline = $(throw))
{
   $ProcessClass = get-wmiobject -query "SELECT * FROM Meta_Class WHERE __Class = 'Win32_Process'"`
                                        -namespace "root\cimv2" -computername $computer
   $results = $ProcessClass.Create( $commandline )
 
   if ($results.ReturnValue -eq 0) { $results.ProcessID }  # Or just return$true if you don't want the PID.
   else { $false ; throw "Failed to create process!" }
}
 
Example 1: how to add a passwordKey on remote server eqrbat3d from eqrbat2d
 
$cmd="cmd /C D:\EQTGSecurity/DEV/getPassword.exe -passwordFile D:\EQTGSecurity/DEV/encrypt.txt -keyFile D:\EQTGSecurity/DEV/key.txt -add -id jz20247.jz20247 -password jz20247"
Create-ProcessWithWMI "eqrbat3d" $cmd
 
Example 2: how to start a job on eqrbat3d from eqrbat2d(take care red part)
 
$cmd = "cmd /C powershell `"`$env:Provider='SybaseRPT';`$env:JOBSTEST='DM1';%JOBSROOT%\jobControl\runJob.ps1 -m ReplicationCheckOut.ps1 -force Y `""
 
Create-ProcessWithWMI "eqrbat3d" $cmd
 
posted on 2011-04-08 15:00  沙漠鱼  阅读(321)  评论(0编辑  收藏  举报