Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Get-Service from Remote Server

Posted on 2013-12-23
1
Medium Priority
?
2,455 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
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…
Loops Section Overview

610 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