1 Star 0 Fork 54

LeeCarty/kasini3000

forked from chuanjiao10/kasini3000 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
linux_distribution_check.ps1 3.08 KB
一键复制 编辑 原始数据 按行查看 历史
#建议保存编码为:bom头 + utf8
[scriptblock]$private:判断linux发行版 =
{
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 'jessie' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian8'
}
if (Select-String -Pattern 'stretch' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian9'
}
if (Select-String -Pattern 'buster' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian10'
}
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 'trixie' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'debian13'
}
if (Select-String -Pattern 'Trusty Tahr' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu1404'
}
if (Select-String -Pattern 'Xenial Xerus' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu1604'
}
if (Select-String -Pattern 'Bionic Beaver' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu1804'
}
if (Select-String -Pattern 'Focal Fossa' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu2004'
}
if (Select-String -Pattern 'Jeremiah Johnson' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'ubuntu2204'
}
if (Select-String -Pattern 'Alpine' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Alpine'
}
if (Select-String -Pattern 'Karoo' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Amazon Linux 2'
}
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 'Karoo' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Amazon Linux 2'
}
if (Select-String -Pattern 'Anolis OS 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Anolis OS 8'
}
if (Select-String -Pattern 'openEuler 20.03 (LTS-SP1)' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'openEuler20.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 'Rocky Linux release 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Rocky Linux 8'
}
if (Select-String -Pattern 'AlmaLinux release 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'AlmaLinux 8'
}
if (Select-String -Pattern 'Oracle Linux Server 8' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'Oracle Linux 8'
}
if (Select-String -Pattern 'openEuler' -Path '/etc/*-release' -SimpleMatch -Quiet)
{
return 'openEuler'
}
}
return $private:判断linux发行版
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PowerShell
1
https://gitee.com/leecarty/kasini3000.git
git@gitee.com:leecarty/kasini3000.git
leecarty
kasini3000
kasini3000
master

搜索帮助