【问题标题】:quser /SERVER:$computerName | Out-File c:\abc.txtquser /SERVER:$computerName |输出文件 c:\abc.txt
【发布时间】:2017-07-09 15:13:18
【问题描述】:

我正在使用上面的命令来获取当前登录用户的列表。 当我运行包含此命令的 powershell 脚本时它运行良好,但是当我从任务调度程序运行相同的脚本时,它会给出以下错误:

"The term 'quser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.",
            "stack_trace": "   at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
   at System.Management.Automation.CommandFactory._CreateCommand(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
   at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
   at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)". 

【问题讨论】:

  • 任务在哪个用户帐户下运行? quser.exe 应该驻留在路径中的 c:\windows\system32 中。

标签: powershell taskscheduler


【解决方案1】:

QUser.exe 位于 C:\Windows\System32。所以,如果你进入目录并运行它,它就会工作。

这里是所有屏幕截图的完整参考。

QUser

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2018-05-05
    • 2019-11-28
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多