39 Star 222 Fork 51

chuanjiao10 / kasini3000

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
linux_distribution_check.ps1 4.44 KB
一键复制 编辑 原始数据 按行查看 历史
chuanjiao10 提交于 2024-04-18 21:07 . 更新:putty到0.81
#建议保存编码为:bom头 + utf8
[scriptblock]$private:判断linux发行版 =
{
#---------------主---------------
if (Select-String -Pattern 'AlmaLinux release 9' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'AlmaLinux 9'
}
if (Select-String -Pattern 'Rocky Linux release 9' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Rocky Linux 9'
}
if (Select-String -Pattern 'Oracle Linux Server 9' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Oracle Linux 9'
}
if (Select-String -Pattern 'Red Hat Enterprise Linux 9' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'RHEL9'
}
if (Select-String -Pattern 'centos-8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'centos8'
}
if (Select-String -Pattern 'centos-7' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'centos7'
}
if (Select-String -Pattern 'AlmaLinux release 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'AlmaLinux 8'
}
if (Select-String -Pattern 'Rocky Linux release 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Rocky Linux 8'
}
if (Select-String -Pattern 'Focal Fossa' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu2004'
}
if (Select-String -Pattern 'Jammy Jellyfish' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu2204'
}
if (Select-String -Pattern 'bullseye' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian11'
}
if (Select-String -Pattern 'bookworm' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian12'
}
if (Select-String -Pattern 'Karoo' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Amazon Linux 2'
}
if (Select-String -Pattern 'Oracle Linux Server 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Oracle Linux 8'
}
#---------------未来---------------
if (Select-String -Pattern 'trixie' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian13'
}
if (Select-String -Pattern 'forky' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian14'
}
if (Select-String -Pattern 'Noble Numbat' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu2404'
}
#---------------国主---------------
if (Select-String -Pattern 'Tercel' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'kylin v10'
}
if (Select-String -Pattern 'UOS Server Enterprise-C' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return '统信UOS服务器版'
}
if (Select-String -Pattern 'Anolis OS 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return '龙蜥8'
}
if (Select-String -Pattern 'openEuler 20.03' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'openEuler20.03'
}
if (Select-String -Pattern 'openEuler 22.03' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'openEuler22.03'
}
if (Select-String -Pattern 'Hunting Beagle' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Alibaba Cloud Linux 2'
}
if (Select-String -Pattern 'Soaring Falcon' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Alibaba Cloud Linux 3'
}
#---------------旧---------------
if (Select-String -Pattern 'Bionic Beaver' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu1804'
}
if (Select-String -Pattern 'buster' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian10'
}
#---------------老旧---------------
if (Select-String -Pattern 'stretch' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian9'
}
if (Select-String -Pattern 'Xenial Xerus' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu1604'
}
#---------------非主流---------------
if (Select-String -Pattern 'Alpine' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Alpine'
}
if (Select-String -Pattern 'CBL-Mariner' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'MS-CBL-Mariner2'
}
if (Select-String -Pattern 'azure' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Azure-Linux'
}
if (Select-String -Pattern 'OpenCloudOS 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'TencentOpenCloudOS8'
}
if (Select-String -Pattern 'OpenCloudOS 9' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'TencentOpenCloudOS9'
}
#---------------temp---------------
#if (Select-String -Pattern 'forky' -Path '/etc/*-release' -SimpleMatch -Quiet)
#{
#return 'debian14'
#}
# if (Select-String -Pattern 'jessie' -Path '/etc/*-release' -SimpleMatch -Quiet)
# {
# return 'debian8'
# }
return '未知'
}
return $private:判断linux发行版
PowerShell
1
https://gitee.com/chuanjiao10/kasini3000.git
git@gitee.com:chuanjiao10/kasini3000.git
chuanjiao10
kasini3000
kasini3000
master

搜索帮助