powershell - 如何使用 Powershell 列出在服务器中使用服务帐户运行的所有服务

标签 powershell

我想使用 powershell 更新在多台服务器上的一个帐户下运行的所有服务的密码。我尝试了 Get-process、Get-WMIObject cmdlet,但这两个命令没有 serviceaccount 用法。有没有办法通过将服务帐户,密码作为参数传递给脚本来更新使用帐户运行的所有服务的密码。

最佳答案

要使用特定帐户获取服务列表,您可以执行以下操作:

Get-WmiObject "win32_service" -Filter "StartName='domain\\user'"

要更改这些密码,您可以执行以下操作:
Get-WmiObject "win32_service" -Filter "StartName='domain\\user'" | 
%{$_.StopService();$_.Change($null,$null,$null,$null,$null,$null,$null,"blah");}

从这里:http://www.send4help.net/change-remote-windows-service-credentials-password-powershel-495

关于powershell - 如何使用 Powershell 列出在服务器中使用服务帐户运行的所有服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7338036/

相关文章:

azure - 通过 Azure powershell 仅获取企业应用程序

powershell - 在Start-Job脚本 block 中,带有凭据的Get-WmiObject失败

windows - 使用PowerShell 创建AppPool 没有设置AppPool Identity

arrays - 从 powershell 中的管道属性获取值(value)

json - 使用powershell为json添加新的键值对

powershell - “If”在foreach循环中不存在-什么?

PowerShell 调用返回数组而不是 int

powershell - 从 PowerShell 创建 Azure AD 客户端凭据 key

powershell - 如何在PowerShell中字符串的第10个字符后添加空格(' ')?

powershell - 在同一命令中搜索隐藏和可见目录