简体   繁体   English

如何在PowerShell中运行远程Windows服务时拒绝Windows凭据密码提示?

[英]How to deny Windows Credential Password Prompt everytime when operate remote windows service in powershell?

Below is my code: 以下是我的代码:

$s = Get-WmiObject -computer 10.10.zz.zz Win32_Service -Filter "Name='XXX'" -credential (Get-Credential XXXXXX\fanwx)
$s.stopservice()
copy-item D:\.....\aaa.exe -destination \\10.10.zz.zz\c$\vvv\
copy-item D:\.....\aaa.pdb -destination \\10.10.zz.zz\c$\vvv\

$s.startservice() $ s.startservice()

everytime executed, will be prompted enter the password of the remote server. 每次执行时,都会提示输入远程服务器的密码。 Is there a way allowed me only enter once in powershell OR read the credential in Credential Manager? 有没有办法允许我只在powershell中输入一次或在Credential Manager中读取凭证?

Thanks. 谢谢。

Just start by 刚开始

$cred = Get-Credential "XXXXXX\fanwx"

and after : 之后 :

$s = Get-WmiObject -computer 10.10.zz.zz Win32_Service -Filter "Name='XXX'" -credential $cred

You can put the password on the disk : 您可以将密码放在磁盘上:

PS > $cred.Password | ConvertFrom-SecureString | Set-Content c:\temp\password.txt

And retreive it with : 并通过以下方式进行检索:

$password = Get-Content c:\temp\password.txt | ConvertTo-SecureString
$cred = New-Object System.Management.Automation.PsCredential "UserName",$password

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有命令提示符窗口 8.1 的 WiFi 密码 - WiFi Password with Command Prompt windows 8.1 Windows安装程序安全性/凭据问题 - Windows installer security/credential question 在Credential Manager中访问Windows凭据 - Access Windows Credentials in Credential Manager 使用Windows身份验证远程SQL Server时如何模拟Windows用户? - How to Impersonate Windows user when using Windows Authentication to remote SQL Server? 如何在不输入密码的情况下将更改推送到远程存储库? - How do I push changes to my remote repository without entering my password everytime? nUnit中的代码工作正常,但Windows Service中的代码获得HTTP状态403:调用远程Web服务时被禁止 - Code within nUnit works fine but within Windows Service gets HTTP status 403: Forbidden when calling a remote Web Service 如果使用工作组,如何在远程计算机上授予Windows服务访问权限? - How can I give a windows service access on a remote machine in case of Workgroup? 启动时如何为Windows服务实现临时管理员权限窗口 - How to achieve temporary admin rights windows for a windows service when starting up 存储Windows服务的用户名和密码的最佳方法是什么? - What is the best way to store a user name and password for a Windows Service? IIS管理员可以更改Windows服务帐户的密码吗 - Can IIS admin change password of Windows Service account
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM