该PowerShell脚本从系统收集网络信息,用于监控和故障排除。它获取网络适配器详细信息、IP配置、DNS配置和路由表。
# 获取网络适配器信息
$networkAdapters = Get-NetAdapter | Select-Object -Property Name, InterfaceDescription, MacAddress, LinkSpeed, Status
# 获取IP配置
$ipConfig = Get-NetIPAddress | Where-Object { $_.InterfaceAlias -ne "Loopback Pseudo-Interface 1" } | Select-Object -Property InterfaceAlias, IPAddress, PrefixLength, AddressFamily
# 获取DNS配置
$dnsConfig = Get-DnsClientServerAddress | Where-Object { $_.InterfaceAlias -ne "Loopback Pseudo-Interface 1" } | Select-Object -Property InterfaceAlias, ServerAddresses
# 获取路由表
$routeTable = Get-NetRoute | Where-Object { $_.DestinationPrefix -ne "0.0.0.0/0" } | Select-Object -Property DestinationPrefix, NextHop, RouteMetric
# 显示网络适配器信息
Write-Host "Network Adapters:"
$networkAdapters | Format-Table -AutoSize
# 显示IP配置
Write-Host "`nIP Configuration:"
$ipConfig | Format-Table -AutoSize
# 显示DNS配置
Write-Host "`nDNS Configuration:"
$dnsConfig | Format-Table -AutoSize
# 显示路由表
Write-Host "`nRouting Table:"
$routeTable | Format-Table -AutoSize脚本输出包含收集到的网络信息的格式化表格。
本文档全面概述了脚本的目的、前提条件、使用说明、脚本内容描述、预期输出和用户的其他注意事项。可以根据特定的组织要求或偏好进行调整。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。