Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With PowerShell V2 you've got two approachs for remote commands.</p> <p><strong>Commands with built-in remoting :</strong> </p> <p>A small set of commands in PowerShell v2 have a <code>-ComputerName</code> parameter, which allows you to specify the target machine to access. </p> <pre><code>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 </code></pre> <p>These commands do their own remoting either because the underlying infrastructure already supports remoting or they address scenarios that are of particular importance to system management. They are built on the top of DCOM and, on the access point of view, you can use them when you can establish a session with the remote machine with commands like <code>NET.exe</code> or <code>PSExec.exe</code>.</p> <p>You are trying to use one of them and you've got a problem with credentials (<code>-cred</code> parameter), because your token credentials can't be used to establish an admin session to the remote machine.</p> <p><strong>The PowerShell remoting subsystem :</strong></p> <p>Before you can use PowerShell remoting to access a remote computer, the remoting service on that computer has to be explicitly enabled. You do so using the <code>Enable-PSRemoting</code> cmdlet. If you are working in workgroup you also need to enable the server to enter on your client computer with this command (on your client computer as administrator):</p> <pre><code>Set-Item WSMan:\localhost\Client\TrustedHosts * </code></pre> <p>Then, you will use <code>New-PSSession</code> Cmdlet (with <code>-computername</code> and <code>-credentials</code>) to create a session object. Then <code>Invoke-Command</code> (with <code>-session</code> and <code>-scriptblock</code>) cmdlet allows you to remotely invoke a scriptblock on another computer. This is the base element for most of the features in remoting. You can also use Enter-PSSession to establish an interactive (SSL like) PowerShell command line with the server.</p> <p>Useful link : <a href="http://www.ravichaganti.com/blog/?p=1305" rel="nofollow noreferrer">Layman’s guide to PowerShell 2.0 remoting</a></p> <hr> <p>Test this :</p> <pre><code>$sess = New-PSSession -ComputerName myServer-Credential (Get-Credential) Invoke-Command -Session $sess -ScriptBlock {get-service} ... Remove-PSSession -Session $sess </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload