我正在运行PowerShell脚本,该脚本将停止远程计算机上的服务。当我在PowerShell ISE中运行它时,它运行良好。但是,当我尝试从本地计算机上托管的Jenkins运行它时,出现了错误。
$SQL_agent="SQLSERVERAGENT"
$SQL_server="MSSQLSERVER"
$SQL_Agent_Service = Get-Service -Name $SQL_agent -ComputerName 192.168.48.44
$SQL_Server_Service = Get-Service -Name $SQL_server -ComputerName 192.168.48.44
Stop-Service -InputObject $SQL_Agent_Service
log("[SQLSERVERAGENT] shutdown complete.");
Stop-Service -InputObject $SQL_Server_Service
log("[MSSQLSERVER] shutdown complete.");
从jenkins运行该错误时(我的本地计算机上正在运行jenkins),
<pre>
D:\Eclipse_Repository\self_repo\jmallick\remote_db_backup.ps1:42 char:22
+ ... ent_Service = Get-Service -Name $SQL_agent -ComputerName 192.168.48.44
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (SQLSERVERAGENT:String) [Get-Ser
vice], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.
Commands.GetServiceCommand
Get-Service : Cannot find any service with service name 'MSSQLSERVER'.At
D:\Eclipse_Repository\self_repo\jmallick\remote_db_backup.ps1:43 char:23
+ ... er_Service = Get-Service -Name $SQL_server -ComputerName 192.168.48.44
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (MSSQLSERVER:String) [Get-Servic
e], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.
Commands.GetServiceCommand
</pre>
对此有何想法?
答案 0 :(得分:0)
Jenkins的运行帐户似乎与MSSQLSERVER
不在同一帐户上
更改jenkins
或MSSQLSERVER
服务的帐户