PowerShell Remoting

Enter-PSSession -ComputerName dcorp-adminsrv

Untitled

We can execute commands using Invoke-Command

Invoke-Command -ScriptBlock {hostname} -ComputerName DCORP-ADMINSRV 

Untitled

we can also execute scripts using Invoke-Command

Invoke-Command -FilePath C:\\AD\\Tools\\PowerUp.ps1 -ComputerName DCORP-ADMINSRV

New-PSSession

Creating Sessions

$adminsrv = New-PSSession -ComputerName dcorp-adminsrv

Untitled

Now let’s enter the session we made

Enter-PSSession -Session $adminsrv

Untitled

we can also use the session with Invoke-Command

Invoke-Command -Session $adminsrv -ScriptBlock {ipconfig;hostname}

Untitled