文件ip.txt一个IP地址列表
function CreateObj
{
param([string]$IP,[string]$class,[int]$number)
$Obj=New-Object PSObject
$Obj | Add-Member -Name IP -MemberType NoteProperty -Value $IP
$Obj | Add-Member -Name CLASS -MemberType NoteProperty -Value $Class
$Obj | Add-Member -Name NUMBER -MemberType NoteProperty -Value $number
return $Obj
}
$allip = get-content ip.txt
$tab=@()
foreach ($item in $allip)
{
$class = $item.substring(0,$item.lastindexof("."))
$number = [int]($item.substring($item.lastindexof(".")+1))
$tab += createobj $item $Class $number
}
$tab | sort |get-unique # <-- this fail problem of type i think ?$tab \排序\get-唯一#<-这个失败..。类型问题?谢谢
发布于 2014-09-17 13:05:09
应该使用排序对象cmdlet:$tab | sort IP -unique的-unique参数。
https://stackoverflow.com/questions/25891298
复制相似问题