> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell/de/remote-desktop-manager-powershell/powercli-advanced-troubleshooting.md).

# Erweiterte PowerCLI-Fehlerbehebung

Remote Desktop Manager ruft die Cmdlets von PowerCLI auf und stellt die Ergebnisse in seiner Benutzeroberfläche dar.

Hier sind Schritte, die dabei helfen, Probleme zu isolieren, wenn die Integration nicht wie erwartet funktioniert.

### Skript A: Liste der virtuellen Maschinen abrufen

GETVMS.PS1

```powershell
Param(
    [Parameter(Mandatory=$true)]
    [string]$viServer,
    [Parameter(Mandatory=$true)]
    [string]$userName,
    [Parameter(Mandatory=$true)]
    [string]$password
) #end param

$VMHost = Connect-VIServer $($viServer) -User $userName -Password $password
if ($VMHost -eq $null ) { throw "Connection to server failed!";}
try
{
    Get-View -ViewType VirtualMachine |  select -Property Name, {$_.Moref.Value};
}
catch
{
    write-host $ErrorMessage
}
Disconnect-VIServer $VMHost -Force -Confirm:$false
```

### Anwendungsbeispiel

`.\GetVMs.ps1 [SERVER_NAME] [USER_NAME] [PASSWORD]`

Name $\_.Moref.Value ---- -------------- MACHINE1 18 MACHINE2 19

### Skript B -:Start der vmrc

CONNECTVMRCFROMPOWERCLI.PS1

```powershell
Param(
    [Parameter(Mandatory=$true)]
    [string]$viServer,
    [Parameter(Mandatory=$true)]
    [string]$userName,
    [Parameter(Mandatory=$true)]
    [string]$password,
    [Parameter(Mandatory=$true)]
    [string]$morefId = ""
) #end param

$VMHost = Connect-VIServer $($viServer) -User $userName -Password $password

if ($VMHost -eq $null ) { throw "Connection to server failed!";}
$si = Get-View ServiceInstance
$sm = Get-View $si.Content.SessionManager
$ticket = $sm.AcquireCloneTicket()
try
{
    Start-Process -FilePath "C:\Program Files (x86)\VMware\VMware Remote Console\vmrc.exe" -ArgumentList "vmrc://clone:$($ticket)@$($viServer)/?moid=$($morefId)"
}
catch
{
    write-host $ErrorMessage
}
#must wait to allow for the process to be started BEFORE we disconnect from the server
Start-Sleep -s 10
Disconnect-VIServer $VMHost -Force -Confirm:$false
```

### Anwendungsbeispiel

Sie müssen den MoRef.Value senden, der mit Skript A ermittelt wurde; in unserem Beispiel starten Sie MACHINE2, die die ID 19 hat.

```
.\ConnectVMRCFromPowerCLI.ps1 [SERVER_NAME] [USER_NAME] [PASSWORD] 19
```

Die VMRC sollte erscheinen und Ihnen die Interaktion damit ermöglichen.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell/de/remote-desktop-manager-powershell/powercli-advanced-troubleshooting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
