如何使用 Powershell 列出在服务器中使用服务帐户运行的所有服务 [英] How to list all the services running with a service account in a server using Powershell

查看:34
本文介绍了如何使用 Powershell 列出在服务器中使用服务帐户运行的所有服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to update the password of all the services running under one account on multiple servers using powershell. i tried Get-process, Get-WMIObject cmdlets, but these two commands don't have serviceaccount usage. is there a way to update password of all the services running with an account by passing service account,password as parameters to the script.

推荐答案

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

To get list of services using a particular account you can do:

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

要更改这些密码,您可以:

To change the password for these, you can do:

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 列出在服务器中使用服务帐户运行的所有服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆