Solved

Get-Service from Remote Server

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
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…

914 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

19 Experts available now in Live!

Get 1:1 Help Now