1 Star 0 Fork 54

LeeCarty/kasini3000

forked from chuanjiao10/kasini3000 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
cdip.ps1 3.67 KB
Copy Edit Raw Blame History
#建议保存编码为:bom头 + utf8
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[Alias("ipaddress")][String]$被控机ip地址
)
if ( ($IsWindows -eq $True) -or ($PSVersionTable.psversion.major -lt 6) ) #win
{
& 'c:\ProgramData\kasini3000\0k_source.ps1'
}
if ($IsLinux -eq $True)
{
& '/etc/kasini3000/0k_source.ps1'
}
$global:当前被控机_ip = $null
$global:当前被控机_组 = $null
$global:当前被控机_uuid = $null
$global:当前被控机_os = $null
$global:当前被控机_esxi宿主机 = $null
& 'zd只读nodelist文件.ps1'
$当前被控机 = $global:所有被控机 | Where-Object { $_.ip -eq $被控机ip地址 }
if ($当前被控机.ip -ne $被控机ip地址)
{
if ($env:LANG -eq 'zh_CN.UTF-8')
{
Write-Error "nodelist文件中找不到这个ip地址: ${被控机ip地址} ,错误码11"
}
else
{
Write-Error "NODE IP was not found in the NODELIST file: ${被控机ip地址} ,error code 11"
}
$当前被控机.'被控机os类型' = '错误:nodelist文件中找不到这个ip地址'
$global:当前被控机_ip = @{ '被控机os类型' = '错误:nodelist文件中找不到这个ip地址' }
if ( ($IsWindows -eq $True) -or ($PSVersionTable.psversion.major -lt 6) ) #win
{
& "${global:kasini3000目录}\admin_gui\pic\bc随机报错背景图片.ps1"
}
function global:prompt
{
"`e[91m`e[44m【{0}】`e[0m{1}> " -f $global:当前被控机_ip.ip,$PWD
}
exit 11
}
[System.Net.IPAddress]$ip2 = 0
if ( [System.Net.IPAddress]::TryParse(($当前被控机.ip),[ref]$ip2) )
{
#ip地址合法
}
else
{
if ($env:LANG -eq 'zh_CN.UTF-8')
{
Write-Error "nodelist文件中找到这个ip地址: ${被控机ip地址},但ip不合法。请检查nodelist清单,ip是否重复?"
}
else
{
Write-Error "Illegal IP address found in NODELIST file: ${被控机ip地址} "
}
if ( ($IsWindows -eq $True) -or ($PSVersionTable.psversion.major -lt 6) ) #win
{
& "${global:kasini3000目录}\admin_gui\pic\bc随机报错背景图片.ps1"
}
exit 12
}
$private:已知关键字类型 = & 'linux_distribution_str.ps1'
$private:已知关键字类型 = $private:已知关键字类型 + '从linux【主控机】中,经winrm协议,控制win【被控机】,无法实现!' + '从linux【主控机】中,经wmic协议+135端口,控制win【被控机】,无法实现!'
$private:已知关键字类型 = $private:已知关键字类型 + 'win2008r2' + 'win7' + 'win8' + 'win10' + 'win2012r2' + 'win2016' + 'win2019' + '【被控机】linux发行版未知' + '【被控机】win版本未知' + '从win【主控机】中,经wmic协议+135端口,控制win【被控机】,无法实现!'
if ($当前被控机.'被控机os类型' -in $private:已知关键字类型)
{
}
else
{
& 'sx1刷新单个被控机对象的_os类型属性.ps1' -被控机ip地址 $当前被控机.ip
$当前被控机 = $global:所有被控机 | Where-Object { $_.ip -eq $被控机ip地址 }
}
$global:当前被控机_ip = $当前被控机
function global:prompt
{
"`e[37m`e[44m【{0}】`e[0m{1}> " -f $global:当前被控机_ip.ip,$PWD
}
if ($env:LANG -eq 'zh_CN.UTF-8')
{
$当前被控机 | Format-List 'ip','端口','被控机显示名','被控机os类型','用户名','被控机分组名','被控机uuid'
}
else
{
$private:a = @{Expression = { $_.'ip' };Label = 'IP' },
@{Expression = { $_.'端口' };Label = 'PORT' },
@{Expression = { $_.'被控机显示名' };Label = 'NODE NAME' },
@{Expression = { $_.'被控机os类型' };Label = 'OSTYPE' },
@{Expression = { $_.'用户名' };Label = 'USER NAME' },
@{Expression = { $_.'被控机分组名' };Label = 'NODE GROUP' },
@{Expression = { $_.'被控机uuid' };Label = 'UUID' }
$当前被控机 | Format-List $private:a
}
exit 0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PowerShell
1
https://gitee.com/leecarty/kasini3000.git
git@gitee.com:leecarty/kasini3000.git
leecarty
kasini3000
kasini3000
master

Search