跨平台PowerShell如何远程管理Linux/Mac/Windows?

简介: 跨平台PowerShell如何远程管理Linux/Mac/Windows?首先,在要管理的机器上安装跨平台PowerShell:https://github.


跨平台PowerShell如何远程管理Linux/Mac/Windows?


首先,在要管理的机器上安装跨平台PowerShell:https://github.com/PowerShell/PowerShell/releases

如何安装呢?看Instructions:

Platform Downloads How to Install
Windows 10 / Server 2016 .msi Instructions
Windows 8.1 / Server 2012 R2 .msi Instructions
Ubuntu 16.04 .deb Instructions
Ubuntu 14.04 .deb Instructions
CentOS 7 .rpm Instructions
OS X 10.11 .pkg Instructions
Docker   Instructions

然后,安装OMI和PSRP:

OMI:https://github.com/Microsoft/omi

PSRP:https://github.com/PowerShell/psl-omi-provider

Platform Releases Link
Linux Debian psrp-1.0.0-0.universal.x64.deb
Linux RPM psrp-1.0.0-0.universal.x64.rpm

最后,在windows端运行下列命令来管理Linux/Mac/Windows机器:

$User = "root"
$PWord = convertto-securestring "密码" -asplaintext -force
$cred = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord
$mySession = New-PSSession  -ComputerName 机器名 -Credential $cred -Authentication basic -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipRevocationCheck -SkipCNCheck)
Invoke-Command -Session $mySession {Get-Host} 

如果你想把本地的脚本在被管理的机器上运行:

$script1='get-host';
$path1='/root/test.ps1';
Invoke-Command -Session $mySession {echo $args[0]>$args[1];. $args[1]} -Args $script1,$path1

读取本地的文件,然后在被管理的机器上运行:

$script1 = Get-Content "d:\test.txt"
$path1='/root/test.ps1';
Invoke-Command -Session $mySession {echo $args[0]>$args[1];. $args[1]} -Args $script1,$path1


目录
相关文章
|
8天前
|
安全 Linux 生物认证
Nexpose 8.25.0 for Linux & Windows - 漏洞扫描
Nexpose 8.25.0 for Linux & Windows - 漏洞扫描
45 0
Nexpose 8.25.0 for Linux & Windows - 漏洞扫描
|
25天前
|
安全 Linux iOS开发
Binary Ninja 5.1.8104 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
Binary Ninja 5.1.8104 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
209 53
Binary Ninja 5.1.8104 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
|
11天前
|
安全 Linux 生物认证
Nexpose 8.24.0 for Linux & Windows - 漏洞扫描
Nexpose 8.24.0 for Linux & Windows - 漏洞扫描
63 1
Nexpose 8.24.0 for Linux & Windows - 漏洞扫描
|
11天前
|
SQL 安全 Linux
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
69 1
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
|
13天前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
128 1
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
|
25天前
|
Linux API iOS开发
Binary Ninja 4.2.6455 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
Binary Ninja 4.2.6455 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
127 14
Binary Ninja 4.2.6455 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
|
9天前
|
Linux 虚拟化 iOS开发
VMware Remote Console 13.0.1 for macOS, Linux, Windows - vSphere 虚拟机控制台的桌面客户端
VMware Remote Console 13.0.1 for macOS, Linux, Windows - vSphere 虚拟机控制台的桌面客户端
92 0
VMware Remote Console 13.0.1 for macOS, Linux, Windows - vSphere 虚拟机控制台的桌面客户端
|
2月前
|
JSON 安全 Linux
Nexpose 8.22.0 for Linux & Windows - 漏洞扫描
Nexpose 8.22.0 for Linux & Windows - 漏洞扫描
92 1
Nexpose 8.22.0 for Linux & Windows - 漏洞扫描
|
23天前
|
Linux iOS开发 计算机视觉
GIMP 3.0.6 (Linux, macOS, Windows) 发布 - 免费开源图像编辑器
GIMP 3.0.6 (Linux, macOS, Windows) 发布 - 免费开源图像编辑器
110 0
|
2月前
|
数据管理 Linux iOS开发
Splunk Enterprise 9.4.5 (macOS, Linux, Windows) - 机器数据管理和分析
Splunk Enterprise 9.4.5 (macOS, Linux, Windows) - 机器数据管理和分析
82 0
下一篇
开通oss服务