我有一个PowerShell脚本,我有以下代码
$Rabbit_Path = "C:\Program Files\RabbitMQ Server\rabbitmq_server-3.6.6"
$RabbitMQ_service=Get-WmiObject -Class Win32_Service -Filter "Name='RabbitMQ'" | Select-Object;
if($RabbitMQ_service.status -eq "OK" -and $RabbitMQ_service.state -ne "Stopped")
{
& $Rabbit_Path\sbin\rabbitmq-service.bat stop
& $Rabbit_Path\sbin\rabbitmq-service.bat remove
}
& $Rabbit_Path\sbin\rabbitmq-service.bat install
& $Rabbit_Path\sbin\rabbitmq-service.bat start
这在第一个实例中运行正常,但是当我执行相同的操作时,我会收到一个异常,例如无法启动服务,所以有人可以帮助我