39 Star 222 Fork 51

chuanjiao10 / kasini3000

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
bkj_install_k记饭店_win被控机.ps1 2.27 KB
一键复制 编辑 原始数据 按行查看 历史
#建议保存编码为:bom头 + utf8
# 启用winrm,安装插件。非必要安装ps6,或ps7。
#Requires -RunAsAdministrator
$Private:msg =
@'
信息:此脚本只能在被控机上运行。
win7 # 需要安装.net v4.8。需要安装powershell5.1。需要运行【启用winrm】脚本。
win10 # 不需要任何安装,需要运行【启用winrm】脚本。
win11 # 不需要任何安装,需要运行【启用winrm】脚本。
win2008r2 # 需要安装.net v4.8。需要安装powershell5.1。需要运行【启用winrm】脚本。
win2012r2 # 需要安装.net v4.8。需要安装powershell5.1。不需要任何设定。
win2016,# 不需要任何安装,不需要任何设定。
win2019。# 不需要任何安装,不需要任何设定。
win2022。# 不需要任何安装,不需要任何设定。
winxp,win2003, # 安装.net3.5,powershell 2.0后,应该也可以,通过winrm远程执行命令。
'@
if ($env:LANG -eq 'zh_CN.UTF-8')
{
Write-Error $Private:msg
}
else
{
Write-Error 'note:Information: This script can only be run on NODE'
}
if (($PSVersionTable.PSVersion.Major -lt 5) -and ($PSVersionTable.PSVersion.Minor -lt 1))
{
Write-Error '错误:powershell版本太低。必须是powershell5.1'
Exit 11
}
if ( ($IsWindows -eq $True) -or ($PSVersionTable.psversion.major -lt 6) ) #win
{
$win7 = powershell.exe -command { (Get-WmiObject -Class Win32_OperatingSystem).Caption -like "*7*" }
$win2008 = powershell.exe -command { (Get-WmiObject -Class Win32_OperatingSystem).Caption -like "*2008*" }
if ( $win7 -or $win2008 )
{
Write-Warning '卡死你3000被控机,支持win7,支持win2008。'
}
#把网卡设置成专用
Get-NetConnectionProfile -InterfaceAlias '以太网' | Set-NetConnectionProfile -NetworkCategory Private
Get-NetConnectionProfile -InterfaceAlias 'Ethernet' | Set-NetConnectionProfile -NetworkCategory Private
Get-NetConnectionProfile -InterfaceAlias 'WLAN' | Set-NetConnectionProfile -NetworkCategory Private
#win被控机,启用winrm。
Enable-PSRemoting -SkipNetworkProfileCheck -Force
Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP-NoScope" -RemoteAddress Any
Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP" -RemoteAddress Any
sc.exe config "winrm" start= auto #为了兼容win7,win2008
Restart-Service WinRM #并重启服务
}
exit 0
PowerShell
1
https://gitee.com/chuanjiao10/kasini3000.git
git@gitee.com:chuanjiao10/kasini3000.git
chuanjiao10
kasini3000
kasini3000
master

搜索帮助