Active directory 当用户名有连字符时运行psexec.exe

Active directory 当用户名有连字符时运行psexec.exe,active-directory,psexec,Active Directory,Psexec,我必须通过psexec调用一个脚本,这涉及到使用一个包含连字符的用户名。不幸的是,该命令不起作用,并且不会抛出任何可理解的错误消息。它只是告诉我应该如何使用psexec,即各种参数以及它们代表什么 我的命令是这样的- psexec.exe \\hostname -u domain\user-name-acct -p passwd -i 2 <script> psexec.exe\\hostname-u domain\user name acct-p passwd-i 2 我几乎可

我必须通过psexec调用一个脚本,这涉及到使用一个包含连字符的用户名。不幸的是,该命令不起作用,并且不会抛出任何可理解的错误消息。它只是告诉我应该如何使用psexec,即各种参数以及它们代表什么

我的命令是这样的-

psexec.exe \\hostname -u domain\user-name-acct -p passwd -i 2 <script>
psexec.exe\\hostname-u domain\user name acct-p passwd-i 2
我几乎可以肯定连字符是罪魁祸首,因为我可以使用没有连字符的用户名调用同一个脚本。该帐户在VM上具有管理员权限。在我要求他们创建/编辑用户名以不使用连字符之前,我只想确保没有办法运行此类命令

更新-命令结果

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

PsExec executes a program on a remote system, where remotely executed console
applications execute interactively.

Usage: psexec [\\computer[,computer2[,...] | @file]][-u user [-p psswd][-n s][-r servicename][-h][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,...] cmd [arguments]
     -a         Separate processors on which the application can run with
                commas where 1 is the lowest numbered CPU. For example,
                to run the application on CPU 2 and CPU 4, enter:
                "-a 2,4"
     -c         Copy the specified program to the remote system for
                execution. If you omit this option the application
                must be in the system path on the remote system.
     -d         Don't wait for process to terminate (non-interactive).
     -e         Does not load the specified account's profile.
     -f         Copy the specified program even if the file already
                exists on the remote system.
     -i         Run the program so that it interacts with the desktop of the
                specified session on the remote system. If no session is
                specified the process runs in the console session.
     -h         If the target system is Vista or higher, has the process
                run with the account's elevated token, if available.
     -l         Run process as limited user (strips the Administrators group
                and allows only privileges assigned to the Users group).
                On Windows Vista the process runs with Low Integrity.
     -n         Specifies timeout in seconds connecting to remote computers.
     -p         Specifies optional password for user name. If you omit this
                you will be prompted to enter a hidden password.
     -r         Specifies the name of the remote service to create or interact.
                with.
     -s         Run the remote process in the System account.
     -u         Specifies optional user name for login to remote
                computer.
     -v         Copy the specified file only if it has a higher version number
                or is newer on than the one on the remote system.
     -w         Set the working directory of the process (relative to
                remote computer).
     -x         Display the UI on the Winlogon secure desktop (local system
                only).
     -priority  Specifies -low, -belownormal, -abovenormal, -high or
                -realtime to run the process at a different priority. Use
                -background to run at low memory and I/O priority on Vista.
     computer   Direct PsExec to run the application on the remote
                computer or computers specified. If you omit the computer
                name PsExec runs the application on the local system,
                and if you specify a wildcard (\\*), PsExec runs the
                command on all computers in the current domain.
     @file      PsExec will execute the command on each of the computers listed
                in the file.
     cmd            Name of application to execute.
     arguments  Arguments to pass (note that file paths must be
                absolute paths on the target system).
     -accepteula This flag supresses the display of the license dialog.

You can enclose applications that have spaces in their name with
quotation marks e.g. psexec \\marklap "c:\long name app.exe".
Input is only passed to the remote system when you press the enter
key, and typing Ctrl-C terminates the remote process.

If you omit a user name the process will run in the context of your
account on the remote system, but will not have access to network
resources (because it is impersonating). Specify a valid user name
in the Domain\User syntax if the remote process requires access
to network resources or to run in a different account. Note that
the password and command is encrypted in transit to the remote system.

Error codes returned by PsExec are specific to the applications you
execute, not PsExec.
PsExec v2.11-远程执行进程
版权所有(C)2001-2014 Mark Russinovich
Sysinternals-www.Sysinternals.com
PsExec在远程系统上执行一个程序,在远程控制台上执行
应用程序以交互方式执行。
用法:psexec[\\computer[,computer2[,…]|@file][-u user[-p psswd][n s][r servicename][h][l][s |-e][x][i[session][-c[-f |-v][-w directory][-d][-][-a n,n,…]cmd arguments]
-一个独立的处理器,应用程序可以在其上运行
逗号,其中1是编号最低的CPU。例如,
要在CPU 2和CPU 4上运行应用程序,请输入:
“-a 2,4”
-c将指定的程序复制到远程系统,以便
执行。如果忽略此选项,则应用程序
必须位于远程系统上的系统路径中。
-不要等待进程终止(非交互式)。
-e不加载指定帐户的配置文件。
-f即使文件已经存在,也要复制指定的程序
存在于远程系统上。
-我运行该程序,使其与计算机的桌面交互
在远程系统上指定的会话。如果没有会话
指定进程在控制台会话中运行。
-h如果目标系统是Vista或更高版本,则进程
使用帐户的提升令牌(如果可用)运行。
-l以受限用户身份运行进程(删除Administrators组
并且只允许分配给用户组的权限)。
在Windows Vista上,进程以低完整性运行。
-n指定连接到远程计算机的超时(以秒为单位)。
-p为用户名指定可选密码。如果忽略此项
系统将提示您输入隐藏密码。
-r指定要创建或交互的远程服务的名称。
具有
-s在系统帐户中运行远程进程。
-u指定用于登录到远程服务器的可选用户名
电脑。
-v仅当指定文件的版本号较高时才复制该文件
或比远程系统上的更新。
-设置进程的工作目录(相对于
远程计算机)。
-x在Winlogon安全桌面(本地系统)上显示UI
仅限)。
-优先级指定-低、-低于正常值、-高于正常值、-高或
-实时以不同优先级运行进程。使用
-在Vista上以低内存和I/O优先级运行后台。
计算机指示PsExec在远程计算机上运行应用程序
指定了一台或多台计算机。如果忽略计算机
名称PsExec在本地系统上运行应用程序,
如果指定通配符(\\*),PsExec将运行
当前域中所有计算机上的命令。
@文件PsExec将在列出的每台计算机上执行该命令
在文件中。
要执行的应用程序的cmd名称。
要传递的参数(请注意,文件路径必须为
目标系统上的绝对路径)。
-accepteula此标志禁止显示许可证对话框。
可以将名称中有空格的应用程序用
引号,例如psexec\\marklap“c:\long name app.exe”。
输入仅在按enter键时传递到远程系统
键,然后键入Ctrl-C终止远程进程。
如果省略用户名,则进程将在
远程系统上的帐户,但将无法访问网络
资源(因为它是模拟的)。请指定有效的用户名
如果远程进程需要访问,请使用域\用户语法
连接到网络资源或在其他帐户中运行。请注意
密码和命令在传输到远程系统时进行加密。
PsExec返回的错误代码特定于您所使用的应用程序
执行,而不是PsExec。

我没有一个windows框来验证我的假设,但我相信您会用单引号或双引号将域名\用户名括起来:

psexec.exe \\hostname -u "domain\user-name-acct" -p passwd -i 2 <script>
psexec.exe\\hostname-u“域\用户名帐户”-p passwd-i 2
或者可能:

psexec.exe \\hostname -u 'domain\user-name-acct' -p passwd -i 2 <script>
psexec.exe\\hostname-u'域\用户名帐户'-p passwd-i 2
然而,我倾向于使用双引号。。 此外,如果这不能解决您的问题,可能会发布错误,即使这些错误对您来说是胡说八道,它们对其他人也可能有意义。
HTH

它们不起作用。我已经更新了问题中的错误。我刚刚启动了一个VM,并下载了psexec的v2.11,并且在用户名中使用连字符运行命令时没有任何问题,没有单引号或双引号。唯一的区别是我只启动了cmd,而没有调用脚本。您是否可能从te复制该命令xt编辑器,它正在将连字符“-”转换为ASCII 227“-”,然后尝试将其粘贴到cmd?请仔细想想