#Get-ipv4.ps1 <# .Synopsis Get physical adapters network ipv4 .Description Display all physical adapters from the ipconfig. .Parameter Computername The name of the computer to check. .Example c:\get-ipv4.sp1 -computer SERVER01 #> [cmdletbinding()] Param ( [Parameter(Mandatory=$True,HelpMessage="Enter a computername to query")] [alias('hostname')] [string]$Computername ) Write-Verbose "Getting physical network adapters ipv4 from $computername" -Verbose Invoke-Command -ComputerName $computername -ScriptBlock {Write-Verbose "本机ipv4地址 $computername" -Verbose $ipconfig = ipconfig $ipconfig -match 'ipv4* ' Write-Verbose "ipv4查询成功,15秒退出" -Verbose sleep -s 15}
演示效果
PS C:\> .\ipv4.ps1 cp202007 详细信息: Getting physical network adapters ipv4 from cp202007 详细信息: 本机ipv4地址 IPv4 Address. . . . . . . . . . . : 172.30.33.66 详细信息: 查询成功,15秒退出