Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. Add-Type @'
  2. public class CPObject
  3. {
  4. public int id;
  5. public string name;
  6. public string displayname;
  7. public string classname;
  8. public string ip;
  9. public string netmask;
  10. public string ManagementServer;
  11. }
  12. '@
  13.  
  14. Function NameToIP {
  15.  
  16. Param([int]$id=0, [string]$name="")
  17.  
  18. $CPObject = $CPNetworkObjects | Where-Object { $_.id -eq $id -and $_.name -eq $name }
  19.  
  20. If($CPObject.count -eq 1){
  21. $CPObject.ip
  22. } else {
  23. ""
  24. }
  25. }
  26.  
  27. $NameToIP = @{}
  28.  
  29. Foreach ($Object in $Array) { $NameToIP["$($Object.id)_$($Object.Name)"] = $Object.ip }
  30.  
  31. Function NameToIP {
  32.  
  33. Param([int]$id=0, [string]$name="")
  34.  
  35. $NameToIP["$id_$name"]
  36.  
  37. }
  38.  
  39. PS>(1..15000) |%{
  40. >>> $res+=new-object pscustomobject -property @{"id"=$_;name=(get-random)}
  41. >>> }
  42.  
  43. PS> measure-command -expression {$res |?{$_.id -eq 14999 -and $_.name -eq 513658722}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement