Powershell的新手,我猜这是存在的,但我找不到。我正在寻找一个powershell命令,该命令将向我显示用于运行Windows服务的帐户?我首先要检查它是否正在运行,然后确保使用正确的AD帐户来运行它。到目前为止,我有以下内容...
$serviceName = '<my service name>'
If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
If ((Get-Service $serviceName).Status -eq 'Running') {
$status = "$serviceName found and is running."
} Else {
$status = "$serviceName found, but it is not running."
}
#Here is where I should check Log On As name
} Else {
$status = "$serviceName not found."
}
write-host "Status: $status`n"
pause
Run Code Online (Sandbox Code Playgroud)
我的大部分搜索都将我带到Get-WmiObject,但没有找到我想要的东西。在此先感谢您的帮助。
powershell ×1