小编TNT*_*TNT的帖子

在 Windows 10 中以不同用户身份从 Powershell 运行时无法输入 cmd- 或 Powershell-window

当我执行以下代码时:

$creds = Get-Credential -UserName other -Message none
# answering the creds dialogue with correct password here
Start-Process C:\Windows\system32\cmd.exe -Credential $creds
Run Code Online (Sandbox Code Playgroud)

一个cmd窗口打开(看起来完全正常,我可以更改设置...)但我无法在窗口中输入任何内容。无论是普通用户还是管理员帐户,powershell 本身都以普通用户或管理员身份运行。除非 Powershell 作为系统运行(通过 Sysinternal 的psexec):然后我收到以下错误:

Start-Process : This command cannot be run due to the error: Access denied
At line:1 char:1
+ Start-Process C:\Windows\system32\cmd.exe -Credential $creds
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
Run Code Online (Sandbox Code Playgroud)

我将它与cmd.exeandpowershell而不是整个 cmd-path结合起来,并添加了-NoNewWindow参数,但没有任何区别(尽管打开了一个新窗口-NoNewWindow)。当运行“正常”程序时,notepad一切都按预期工作 - 当我运行时,例如runas …

powershell windows-10

5
推荐指数
1
解决办法
6656
查看次数

使用 Powershell PrintManagement cmdlet 检索打印机驱动程序版本?

GUI 中的版本号看起来像 10.0.17134.1 和 3.0.8.0,但 -cmdlet 中的等效版本号(?)Get-PrinterDriver看起来至少很神秘:

Get-PrinterDriver | Select-Object Name, MajorVersion, DriverVersion
Run Code Online (Sandbox Code Playgroud)

给我这样的输出:

Name                   MajorVersion    DriverVersion
----                   ------------    -------------
Microsoft XPS Docu...             4 2814750890000385
Samsung Universal ...             3  844424930656256
Run Code Online (Sandbox Code Playgroud)

那么我真的需要使用 WMI/CIM cmdlet 来获取真实的版本号吗?

printer powershell wmi

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

powershell ×2

printer ×1

windows-10 ×1

wmi ×1