Unable to use Get-Service -ComputerName on the remote computer

I have a Windows 2003 window installation with a virtual box, and I cannot work with it.

I try this on my windows 7 computer

Get-Service –ComputerName myserver

I'm coming back

Get-Service : Cannot open Service Control Manager on computer 'myserver'. This operation might require other privileges.
At Script1.ps1:2 char:4
+ gsv <<<<  -cn myserver
    + CategoryInfo          : NotSpecified: (:) [Get-Service], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand

During the search, I found that I should try and use Enable-PSRemoting.

I did this, and now when I try to use it, I get

WinRM is already configured to receive requests on this computer. WinRM is already configured for remote management on this computer.

But I still get the same error. Is it because I use a virtual machine? I am setting up a virtual OS on my domain, and I can even use my AD account credentials for login.

I can get other information.

So I can’t connect to it using powershell.

+5
4

PowerShell V2 .

:

PowerShell v2 -ComputerName, .

Get-Process
Get-Service
Set-Service

Clear-EventLog
Get-Counter
Get-EventLog
Show-EventLog
Limit-EventLog
New-EventLog
Remove-EventLog
Write-EventLog

Restart-Computer
Stop-Computer

Get-HotFix

, , , . DCOM, , NET.exe PSExec.exe.

, ( -cred), .

PowerShell:

PowerShell , . Enable-PSRemoting. , ( ):

Set-Item WSMan:\localhost\Client\TrustedHosts *

New-PSSession Cmdlet ( -ComputerName -credentials) . Invoke-Command ( -session -scriptblock) cmdlet . . Enter-PSSession PowerShell .

: Laymans PowerShell 2.0


:

$sess = New-PSSession -ComputerName myServer-Credential (Get-Credential)
Invoke-Command -Session $sess -ScriptBlock {get-service}
...
Remove-PSSession -Session $sess
+5

, :

'usser', , powershell (v2) A B.

:

  • enable-psremoting Targetserver B admin
  • Set-PSSessionConfiguration -Name Microsoft.PowerShell -ShowSecurityDescriptorUI Targetserver B admin
  • "usser"

:

  1. sc sdshow scmanager Targetserver B admin
  2. SDDL
  3. sc sdset scmanager (fe:) "D: (A;; CC;;; AU) (A;; CCLCRPRC;;; IU) (A;; CCLCRPRC;;; SU) (A;; CCLCRPWPRC;;, SY) (A;; KA;;; BA) S: (AU; FA; KA;;; WD) (AU; OIIOFA; GA;;; WD)", (A;; CCLCRPWPRC;;; SY) this = (A;; KA;;; SID)
  4. SID , , SID "usser" -user
  5. , :

    D: (A;; CC;;; AU) (A;;;;; CCLCRPRC ) (;;;;; CCLCRPRC SU) (A;; CCLCRPWPRC;;; SY) (A;; ..;;; S-1-5-21-4233383628-1788409597-1873130553-1161) (A;; KA;;; BA) S: (; ; ..;;; WD) (; OIIOFA; ..;;; WD)

, , .

+2

.

, Get-Service -ComputerName MyServer , .

, . , . .

msgoodies: PS

+1

, , , PowerShell, Windows 7. , WMI PSv2, Win7.

v3 WMI 3.0, . , WMI . , WMI 3.0.

0
source

All Articles