这不是 powershell 问题,而是系统配置问题。 您可以通过要求 powershell 解析计算机名称来验证这一点,如下所示: $machine ="machinename"[System.Net.Dns]::GetHostEntry($machine) Run Code Online (Sandbox Code Playgroud) 如果出现错误,则意味着您正在使用无法解析的计算机名称(即:Windows 无法将“计算机名称”...
可以选择手动启动,不自动启动和开机启动PowerShell 通过 WMI 获取系统信息PowerShell 通过 WMI 获取系统信...
[Net.DNS]::EndGetHostEntry([IAsyncResult]$getHostEntry)).HostName } # 返回对象-哈希表 New-Object PSObject -Property @{ IPAddress = "$a.$b.$c.$d"; HostName = $hostName; Ports = $openPorts } | Select-Object IPAddress, HostName, Ports } } } } } } End { # 其他脚本运行结束代码...
write-progress -activity ResolveHost -status"$ip"-percentcomplete (($d/($EndAddress.Split(".")[3])) * 100) -Id 1 $getHostEntry= [Net.DNS]::BeginGetHostEntry($pingStatus.Address,$null,$null) } if($ScanPort) { if($AllPort) { $Ports= @(1..65534) } if($StartPort-ne$null-and$End...
$getHostEntry =[Net.DNS]::BeginGetHostEntry($pingStatus.Address, $null, $null) } if($ScanPort){ # 定义一个开放的端口数组, 存储开放的端口 $openPorts =@() for($i =1; $i -le $ports.Count;$i++){ $port = $Ports[($i-1)]
GetHostEntry Method static System.Net.IPHostEntry GetHostEntry(string hostNameOrAddress), static System.Net.IPHostEntry GetHostEntry(ipaddress address) GetHostEntryAsync Method static System.Threading.Tasks.Task[System.Net.IPHostEntry] GetHostEntryAsync(ipaddress address), static System.Threading.Tasks.Task[Syste...
#Datum,Hostname und Message Nummer$global:result=Get-Content $path|ForEach-Object{if($_-match'(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}:\d{2}).*\(((?:\d{1,3}\.){3}\d{1,3})\) disconnected\.?\s+(\d+) message\[s\]'){try{#$dns=[System.Net.Dns]::GetHostEntry($mat...
$getHostEntry = [Net.DNS]::BeginGetHostEntry($pingStatus.Address, $null, $null) }if($ScanPort) {if($AllPort) { $Ports = @(1..65534) }if($StartPort-ne$null-and$EndPort-ne$null){ $Ports = @($StartPort..$EndPort) } $openPorts = @()for($i = 1; $i-le$Ports.Count;$i++) ...
$obj | where-object{$_.port -notlike "po*"}| select IP, Mac, @{n='DNS';e={[System.Net.Dns]::gethostentry($_.IP).hostname}}, Port | tee -Variable result 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 结果如下 这样子我就成功地获取我需要的信息。
$obj|where-object{$_.port-notlike"po*"}| select IP, Mac, @{n='DNS';e={[System.Net.Dns]::gethostentry($_.IP).hostname}}, Port | tee -Variable result 结果如下 这样子我就成功地获取我需要的信息。 本文转自 beanxyz 51CTO博客,原文链接:http://blog.51cto.com/beanxyz/1830133,如需转载...