?
Solved

Get-Service from Remote Server

Posted on 2013-12-23
1
Medium Priority
?
2,313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 19

Accepted Solution

by:
Raheman M. Abdul earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

762 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