Solved

Get-Service from Remote Server

Posted on 2013-12-23
1
1,966 Views
Last Modified: 2014-01-08
Hi everyone,

I have written a script that displays the event log data between midnight and 03:00 works fine but when I also try and use get-service I see the following error :

Get-service : Cannot open Service Control Manager on computer 'server01.domain.com'. This operation might require other privileges.
At C:\_PSScripts\Event Logs\EventLogCheck.ps1:15 char:5
+     Get-service -computername $Server -displayname easyjet* | Format-table Statu ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-Service], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand

Here is the script :

$HostName = Get-Content 'C:\_PSScripts\Event Logs\Docklands\DocklandsServers.txt'

$Credentials = get-credential

foreach ($server in $hostname)

{

    $server | %{Get-WinEvent -ComputerName $_ -FilterHashtable @{LogName='System'; starttime=([datetime]::Today); endtime=([datetime]::Today.AddHours(3))} -Credential $Credentials} | select MachineName, ID, ProviderName, TimeCreated, Message | format-table * -autosize | out-default

   Get-service -computername $Server -displayname windows* | Format-table Status, Name -autosize | out-default
}
0
Comment
Question by:CaussyR
1 Comment
 
LVL 19

Accepted Solution

by:
Raheman M. Abdul earned 500 total points
ID: 39736474
First try No. 3 from the following possible solutions and
Secondly, see that the servername is correct in the text file and there are no extra characters:

1. Restart the services on both machines
2. Try to run on both the remote and local machines:
Enable-PSRemoting

3. Are you entering DomainName\UserName when the script is asking for Credentials?

4. Update to Powershell version 3.0 on both client and server and it should work.

Updating to WMI 3.0 will install PS ver. 3.0 as well.
Refer: http://www.microsoft.com/en-gb/download/details.aspx?id=34595
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question