Error in powershell: operation requires an interactive window station

I am executing below command through autosys(scheduling tool) to stop a service but it is failing with below error. The command works fine when i run the command on RUN(WIN+R) or cmd after RDPing into the server. Can anyone help me here with a right command?

Command: C:\windows\System32...powershell Start-Process powershell -Verb runAs E: \ ABC \ stop_service.ps1

Содержимое stop_service.ps1 = stop-service -name 'service-abc'

Ошибка: Start-Process: Эта команда не может быть запущена из-за ошибки: Для этой операции требуется интерактивная оконная станция.

В строке: 1 символ: 1 + Start-Process powershell -Verb runAs E: \ ABC \ stop_service.ps ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: InvalidOperation: (:) [Start-Process], InvalidOp erationException + FullyQualifiedErrorId: InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

1
задан 25 March 2018 в 18:21
1 ответ

К выполнить сеанс PowerShell:

Powershell.exe -ExecutionPolicy Bypass -File stop_service.ps1

Вы можете напрямую запустить команду Stop-Service как:

Powershell.exe -ExecutionPolicy Bypass -Command {Stop-Service -Name <ServiceName> -Force}

Примечание: Для получения лучших результатов обязательно запускайте команду в контексте администратора

0
ответ дан 4 December 2019 в 04:08

Теги

Похожие вопросы