使用powershell和psexec

时间:2015-11-02 16:57:31

标签: powershell psexec

我正在尝试以下脚本巫婆我想要做以下事情:

  1. 获取AD组中包含的计算机
  2. 为每个成员
  3. 运行3个start javaw -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard="javafx" -Dcom.sun.javafx.touch=true -jar myApp.jar 命令
    psexec

    但它不起作用......我得到以下输出:

    [CmdletBinding()]
    
    $adgroup   = "GROUP"
    $property  = "Name"
    $aduser    = "DOMAIN\USER"
    $aduserpw  = "PASSWORD"
    $commands  = @("klist -li 0x3e7 purge", "gpupdate /force", "wuauclt /detectnow /updatenow")
    $workdir   = "c:\windows\system32"
    $computers = Get-ADGroupMember $adgroup | Select-Object -Property $property |
                 Sort-Object
    
    Set-Alias psexec "D:\SysInternalsSuite\PsExec.exe"
    
    $computers | ForEach-Object {
        foreach ($c in $commands) {
             $client = $_ | Format-Table -HideTableHeaders | Out-String 
             & psexec /acceptEula \\$client /u $aduser /p $aduserpw -w $workdir $c
        }
    }
    

0 个答案:

没有答案