|
Компьютерный форум OSzone.net » Программирование, базы данных и автоматизация действий » Скриптовые языки администрирования Windows » PowerShell - Помогите пожалуйста переустановить службу удаленно |
|
|
PowerShell - Помогите пожалуйста переустановить службу удаленно
|
Старожил Сообщения: 318 |
Добрый день.
Мне требуется удалённо с помощью PowerShell Переустановить службу на удаленном компьютере с XP. Конкретно: остановить службу, удалить службу, проинсталлировать новую службу, запустить службу. На cmd не предлагать, умеем ![]() Пробовал остановить\запустить службу таким боком: $b = get-wmiobject win32_service -computername 192.168.1.102 -Filter "Name = 'themes'" $b.startservice() PS C:\Users\Admin> $b.startservice() __GENUS : 2 __CLASS : __PARAMETERS __SUPERCLASS : __DYNASTY : __PARAMETERS __RELPATH : __PROPERTY_COUNT : 1 __DERIVATION : {} __SERVER : __NAMESPACE : __PATH : ReturnValue : 14 PS C:\Users\Admin> $serviceController = (new-Object System.ServiceProcess.ServiceController("themes","192.168.1.102")) PS C:\Users\Admin> $serviceController.Start() Exception calling "Start" with "0" argument(s): "Cannot start service Themes on computer '192.168.1.102'." At line:1 char:25 + $serviceController.Start <<<< () + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException |
|
Отправлено: 21:19, 28-08-2010 |
Пользователь Сообщения: 140
|
Профиль | Отправить PM | Цитировать Ingolder,
попробуйте так, хотя результат я не гарантирую - POSH я не знаю... $Computer = "имя_ПК" $serviceName = "имя_службы" $query = "Select * from Win32_Service where name = '$serviceName'" $rtn = Get-WmiObject -Query $query -ComputerName $computer $rtn.stopService() $rtn.Delete() |
Отправлено: 22:45, 28-08-2010 | #2 |
Для отключения данного рекламного блока вам необходимо зарегистрироваться или войти с учетной записью социальной сети. Если же вы забыли свой пароль на форуме, то воспользуйтесь данной ссылкой для восстановления пароля. |
Старожил Сообщения: 318
|
Профиль | Отправить PM | Цитировать deepred, , пробовал так и сяк:
PS C:\Users\Admin> Get-WmiObject -Query "Select * from Win32_Service where name = 'Themes'" -ComputerName 192.168.1.102 Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) At line:1 char:14 + Get-WmiObject <<<< -Query "Select * from Win32_Service where name = 'Themes'" -ComputerName 192.168.1.102 + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand PS C:\Users\Admin> $Computer = "192.168.1.102" PS C:\Users\Admin> $serviceName = "Themes" PS C:\Users\Admin> $query = "Select * from Win32_Service where name = '$serviceName'" PS C:\Users\Admin> $rtn = Get-WmiObject -Query $query -ComputerName $computer Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) At line:1 char:21 + $rtn = Get-WmiObject <<<< -Query $query -ComputerName $computer + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand |
Отправлено: 00:30, 29-08-2010 | #3 |
Пользователь Сообщения: 140
|
Профиль | Отправить PM | Цитировать |
Отправлено: 00:38, 29-08-2010 | #4 |
Googler Сообщения: 3665
|
Профиль | Отправить PM | Цитировать Ingolder, советую для начала решить/отладить задачу локально:
"Stop-Service" - остановить сервис; "New-Service" - создать сервис; ...по удалению сервиса там же: Цитата:
7 способов выполнить команду на удалённом компьютере Запуск процесса на удалённом компьютере – PowerShell Remoting Windows PowerShell: Краткий обзор удаленного управления в версии 2.0 |
||
Отправлено: 08:59, 29-08-2010 | #5 |
Старожил Сообщения: 318
|
Профиль | Отправить PM | Цитировать По первым ссылкам что вы дали, в примерах ничего толкового нет. Как работает psexec.exe и sc.exe я знаю, меня интересует повершелльное решение.
Invoke-command и enter-pssession тоже не помогает: PS C:\Users\Admin> $script = {get-wmiobject win32_service -filter "name='Themes'"} PS C:\Users\Admin> Invoke-Command -ComputerName 192.168.1.102 -ScriptBlock $script [192.168.1.102] Connecting to remote server failed with the following error message : The WinRM client cannot process t he request. Default authentication may be used with an IP address under the following conditions: the transport is HTTP S or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure Tru stedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting H elp topic. + CategoryInfo : OpenError: (:) [], PSRemotingTransportException + FullyQualifiedErrorId : PSSessionStateBroken PS C:\Users\Admin> PS C:\Users\Admin> Enter-PSSession 192.168.1.102 Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HT TPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure T rustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to se t TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:16 + Enter-PSSession <<<< 192.168.1.102 + CategoryInfo : InvalidArgument: (192.168.1.102:String) [Enter-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : CreateRemoteRunspaceFailed Остальные статьи пока что читаю.. но cmd, вбскрипт и прочее - не интересует. |
Последний раз редактировалось Ingolder, 29-08-2010 в 15:52. Отправлено: 13:42, 29-08-2010 | #6 |
Googler Сообщения: 3665
|
Профиль | Отправить PM | Цитировать Ingolder, с локальной реализацией проблемы есть?
Цитата Ingolder:
|
|
Отправлено: 14:04, 29-08-2010 | #7 |
Старожил Сообщения: 318
|
Профиль | Отправить PM | Цитировать Локально - всё работает (на семёрке). Проблема в удалёнке.
WinRM не катит, потому что на удалённом компе ХР, WinRM нету на ОС ниже висты. Powershell Remoting и прочие методы я вам уже показывал что выдаёт. Прочитал все ваши статьи, спасибо, но решения не вижу. |
Отправлено: 15:31, 29-08-2010 | #8 |
Пользователь Сообщения: 140
|
Профиль | Отправить PM | Цитировать Ingolder,
Не ждите готового решения - за Вас никто ничего не настроит... Цитата Ingolder:
Цитата Ingolder:
Цитата amel27:
|
|||
Отправлено: 15:52, 29-08-2010 | #9 |
Googler Сообщения: 3665
|
Профиль | Отправить PM | Цитировать Цитата Ingolder:
Цитата:
Цитата:
|
|||
Отправлено: 16:46, 29-08-2010 | #10 |
|
![]() |
Участник сейчас на форуме |
![]() |
Участник вне форума |
![]() |
Автор темы |
![]() |
Сообщение прикреплено |
| |||||
Название темы | Автор | Информация о форуме | Ответов | Последнее сообщение | |
Люди, Помогите!!! Не могу переустановить Windows | Marion | Лечение систем от вредоносных программ | 1 | 28-08-2010 11:59 | |
Службы - [решено] как переустановить службу Netlogon? | cyberdemon | Microsoft Windows 2000/XP | 4 | 08-04-2010 13:20 | |
FreeBSD - [решено] Помогите переустановить драйвер | Flainth | Общий по FreeBSD | 3 | 10-02-2010 23:29 | |
помогите переустановить винду!!!! | rekrut | Хочу все знать | 11 | 03-10-2007 16:55 | |
помогите переустановить Windows XP | transer | Microsoft Windows 2000/XP | 1 | 15-11-2005 07:39 |
|