PowerShell: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
<source lang="powershell"> | <source lang="powershell"> | ||
Get-Service WinRM | |||
Restart-Service WinRM | |||
Enable-PSRemoting -Force | Enable-PSRemoting -Force | ||
Set-Item WSMan:\localhost\Client\TrustedHosts * | Set-Item WSMan:\localhost\Client\TrustedHosts * | ||
winrm s winrm/config/client '@{TrustedHosts="10.19.83.10,10.19.83.14"}' | winrm s winrm/config/client '@{TrustedHosts="10.19.83.10,10.19.83.14"}' | ||
winrm quickconfig | |||
Test-WsMan 10.19.83.10 | Test-WsMan 10.19.83.10 | ||
Invoke-Command -ComputerName 10.19.83.10 -ScriptBlock { Get-ChildItem C:\ } -Credential academia | Invoke-Command -ComputerName 10.19.83.10 -ScriptBlock { Get-ChildItem C:\ } -Credential academia |
Revision as of 08:22, 21 November 2020
Get-Service WinRM
Restart-Service WinRM
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Client\TrustedHosts *
winrm s winrm/config/client '@{TrustedHosts="10.19.83.10,10.19.83.14"}'
winrm quickconfig
Test-WsMan 10.19.83.10
Invoke-Command -ComputerName 10.19.83.10 -ScriptBlock { Get-ChildItem C:\ } -Credential academia
Enter-PSSession -ComputerName 10.19.83.10 -Credential academia
Knowledge
Get-Service WinRM
Restart-Service WinRM
Enable-PSRemoting -Force
Get-Item WSMan:\localhost\Client\TrustedHosts
Set-Item WSMan:\localhost\Client\TrustedHosts *
Set-Item WSMan:\localhost\Client\TrustedHosts -Force -Value 10.19.83.10
$s = New-PSSession -ComputerName "10.19.83.10" -Credential(Get-Credential)
Invoke-Command -Session $s -ScriptBlock { Get-ChildItem C:\ }
Invoke-Command -Session $s -ScriptBlock { Get-Service }