我试图使用powershell脚本来更改服务的登录凭据。根据 (示例8),我使用以下代码:
$credential = Get-Credential
Set-Service -Name serviceName -Credential $credential
当我运行脚本时,系统会提示我输入用户名和密码,但随后会出现以下错误:
Set-Service : A parameter cannot be found that matches parameter name 'Credential'.
At line:2 char:28
+ Set-Service -Name servic
我想以普通用户的身份在Windows7上运行PowerShell脚本。无论何时尝试,我都会得到以下错误:
File C:\Users\danv\Documents\WindowsPowerShell\profile.ps1 cannot be loaded because the
execution of scripts is disabled on this system. Please see "get-help about_signing" for
more details.
At line:1 char:2
+ . <<<< 'C:\U
我想通过powershell脚本将hosts文件复制到c:\windows\system32\drivers\etc,但是当我这样做时,我得到了以下错误。如何在不显示密码的情况下以管理员身份运行此命令? 我收到的错误: copy : Access to the path 'C:\Windows\System32\drivers\etc\hosts' is denied.
At line:1 char:1
+ copy z:\hosts C:\Windows\System32\drivers\etc
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
你知道吗,如果你是一个系统的管理用户,你可以右键单击一个批处理脚本,然后以管理员的身份运行它,而不需要输入管理员密码?
我想知道如何使用PowerShell脚本来做到这一点。我不希望必须输入我的密码;我只想模仿右键单击Run As Administrator方法。
到目前为止,我读到的所有内容都要求您提供管理员密码。