一品网
  • 首页

PowerShell获取IPv4地址


Function myfun()
{
    $cmd="ipconfig | findstr "+'"'+"IPv4"+'"'
    $ipaddr = iex $cmd
    if($ipaddr -isnot [Array])
    {
        $ip=$ipaddr.Split(":")[1]
        return $ip.Trim()
    }
    else
    {
        foreach ($item in $ipaddr)
        {
            $ipline=[string]$item
            $ip=$ipline.Split(":")[1].Trim()
            if($ip.StartsWith("172.21")){
                return $ip      
            }
            
        }
    }
}

myfun
powershell

相关


linux版powershell中,tab补全,linux外部命令参数名,的模块介绍

Windows Terminal (Preview)治好了cmd,powershell的癌症

走进winrm ---powershell远程连接的4个安全级别,详解

linux版powershell安装教程(.net core版)

powershell读写磁盘变量(对象序列化)

powershell玩转SQL SERVER所有版本

Powershell编程基础-003-脚本的绝对路径及所在的目录

powershell中使用Get-FileHash计算文件的hash值

Windows Powershell – “Running scripts is disabled on this system”

powershell 自定义快捷键F7搜索弹窗展示历史记录

powershell 自定义tab键下拉菜单智能提示

如何去除PowerShell 更新提示

标签

一品网 冀ICP备14022925号-6