PowerShell: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<source lang="powershell"> | <source lang="powershell"> | ||
Enable-PSRemoting -Force | Enable-PSRemoting -Force | ||
Set-Item | Set-Item WSMan:\localhost\Client\TrustedHosts * | ||
winrm s winrm/config/client '@{TrustedHosts="10.19.83.10"}' | winrm s winrm/config/client '@{TrustedHosts="10.19.83.10"}' | ||
Restart-Service WinRM | Restart-Service WinRM | ||
Line 9: | Line 9: | ||
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 | ||
Enter-PSSession -ComputerName 10.19.83.10 -Credential academia | Enter-PSSession -ComputerName 10.19.83.10 -Credential academia | ||
</source> | |||
==Knowledge== | |||
<source lang="powershell"> | |||
Get-Service WinRM | |||
Restart-Service WinRM | |||
Enable-PSRemoting -Force | |||
Get-Item WSMan:\localhost\Client\TrustedHosts | |||
Set-Item WSMan:\localhost\Client\TrustedHosts * | |||
</source> | </source> | ||
==References== | ==References== | ||
{| | |||
| valign="top" | | |||
* [https://hodgkins.io/automating-with-jenkins-and-powershell-on-windows-part-1 Automating with Jenkins & PowerShell on Windows - Part 1] | * [https://hodgkins.io/automating-with-jenkins-and-powershell-on-windows-part-1 Automating with Jenkins & PowerShell on Windows - Part 1] | ||
* [https://hodgkins.io/automating-with-jenkins-and-powershell-on-windows-part-2 Automating with Jenkins & PowerShell on Windows - Part 2] | * [https://hodgkins.io/automating-with-jenkins-and-powershell-on-windows-part-2 Automating with Jenkins & PowerShell on Windows - Part 2] | ||
* [https://docs.microsoft.com/en-us/previous-versions/technet-magazine/ff700227(v=msdn.10) Enable & Use Remote Commands in Windows PowerShell] | * [https://docs.microsoft.com/en-us/previous-versions/technet-magazine/ff700227(v=msdn.10) Enable & Use Remote Commands in Windows PowerShell] | ||
* [https://stackoverflow.com/questions/21548566/ Add more than one Machine to the Trusted Hosts] | |||
* [https://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/ PowerShell Commands on Remote Computers] | * [https://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/ PowerShell Commands on Remote Computers] | ||
* [https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-7.1 Installing PowerShell on macOS] | * [https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-7.1 Installing PowerShell on macOS] | ||
Line 21: | Line 33: | ||
* [https://plugins.jenkins.io/powershell/ Jenkins PowerShell Plugin] | * [https://plugins.jenkins.io/powershell/ Jenkins PowerShell Plugin] | ||
* [https://docs.microsoft.com/en-us/powershell/ PowerShell] | * [https://docs.microsoft.com/en-us/powershell/ PowerShell] | ||
| valign="top" | | |||
|} |
Revision as of 07:17, 21 November 2020
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Client\TrustedHosts *
winrm s winrm/config/client '@{TrustedHosts="10.19.83.10"}'
Restart-Service WinRM
Get-Service WinRM
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 *