Solved

Get-Service from Remote Server

Posted on 2013-12-23
1
1,855 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 18

Accepted Solution

by:
Raheman M. Abdul earned 500 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This article will help you understand what HashTables are and how to use them in PowerShell.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now