Advertisement
Guest User

Inventory cross reference

a guest
Oct 7th, 2015
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $sn = get-content c:\users\matt\desktop\Test\sn.txt
  2. $name = get-content c:\users\matt\desktop\Test\name.txt
  3. $tipweb = get-content c:\users\matt\desktop\Test\tipweb.txt
  4. $ipadlookupname = get-content c:\users\matt\desktop\Test\ipadlookupname.txt
  5. $mdmname = get-content c:\users\matt\desktop\Test\mdmname.txt
  6. $historicalname = get-content c:\users\matt\desktop\Test\historicalname.txt
  7.  
  8. $total = $sn.length;
  9. $total2 = $total - 1;
  10.  
  11. $entry = New-Object 'object[,]' $sn.length,6
  12.  
  13.  
  14.  
  15. $a = New-Object -comobject Excel.Application
  16. $a.visible = $True
  17.  
  18. $b = $a.Workbooks.Add()
  19. $c = $b.Worksheets.Item(1)
  20.  
  21.  
  22. $c.Cells.Item(1,1) = "Serial number"
  23. $c.Cells.Item(1,1).ColumnWidth = "15"
  24. $c.Cells.Item(1,2) = "Name Tipweb"
  25. $c.Cells.Item(1,2).ColumnWidth = "5"
  26. $c.Cells.Item(1,3) = "Tipweb #"
  27. $c.Cells.Item(1,3).ColumnWidth = "13.5"
  28. $c.Cells.Item(1,4) = "iPadlookup name"
  29. $c.Cells.Item(1,4).ColumnWidth = "14.7"
  30. $c.Cells.Item(1,5) = "mdm name"
  31. $c.Cells.Item(1,5).ColumnWidth = "13.5"
  32. $c.Cells.Item(1,6) = "historical name"
  33. $c.Cells.Item(1,6).ColumnWidth = "13.5"
  34. $d = $c.UsedRange
  35. $d.Interior.ColorIndex = 19
  36. $d.Font.ColorIndex = 11
  37. $d.Font.Bold = $True
  38. $d.EntireColumn.AutoFit($True)
  39.  
  40. $num = 2;
  41.  
  42. for ($int = 0; $int -lt $total; $int+=1) {
  43.     #Entry[int, (0-5 for serial,name,tipweb, ipadlookup, mdm, historical)
  44.    
  45.     $entry[$int,0] = $sn[$int]
  46.     $entry[$int,1] = $name[$int]
  47.     $entry[$int,2] = $tipweb[$int]
  48.    
  49.     $ipadline = get-content c:\users\matt\desktop\Test\ipadlookupsn.txt | select-string -Pattern $sn[$int] | select-object LineNumber
  50.     $entry[$int,3] = $ipadlookupname[($ipadline.linenumber-1)]
  51.    
  52.     $mdmline = get-content c:\users\matt\desktop\Test\mdmsn.txt | select-string -Pattern $sn[$int] | select-object LineNumber
  53.     $entry[$int,4] = $mdmname[($mdmline.linenumber-1)]
  54.    
  55.     $snline = get-content c:\users\matt\desktop\Test\historicalsn.txt | select-string -Pattern $sn[$int] | select-object LineNumber
  56.     $entry[$int,5] = $historicalname[($snline.linenumber-1)]
  57.    
  58.     $c.Cells.Item($num, 1) = $entry[$int,0]
  59.     $c.Cells.Item($num, 2) = $entry[$int,1]
  60.     $c.Cells.Item($num, 3) = $entry[$int,2]
  61.     $c.Cells.Item($num, 4) = $entry[$int,3]
  62.     $c.Cells.Item($num, 5) = $entry[$int,4]
  63.     $c.Cells.Item($num, 6) = $entry[$int,5]
  64.    
  65.     $num = $num + 1
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement