Advertisement
Guest User

Outlook GAL Values

a guest
Jul 6th, 2012
1,889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. <#
  2.  
  3.  
  4. # - Name : Get Outlook Address Book sort order values
  5. # - Author : Stephen Owen
  6. # - Date : 07/06/2012
  7. # - Function : this is a quicky which will output the hex values to be placed under $specifySearchOrder, and $AddressListbytes in my Outlook GAL Script.ps1, also available online
  8. # eventually, this function will be bundled into my Outlook GAL Script, but I've not had the time to do this yet.
  9. # - Thanks : This borrows VERY HEAVILY from SANS.Org's great Powershell Conversion functions reference page
  10.  
  11.  
  12. ~~~~~~*****NOTICE*****~~~~~~
  13. When you run this, you'll recieve HEX values, use them and over write the original values in my other script, sample exceprt below
  14.  
  15. #set "11023d05", Specifies Address list sort order !!!! PASTE YOUR VALUES BELOW IN OTHER SCRIPT
  16. $specifySearchOrder = [byte[]](YOUR VALUES GO HERE)
  17.  
  18. #set "01023d06", Specifies that Outlook should search the GAL first !!!! PASTE YOUR VALUES BELOW IN OTHER SCRIPT
  19. $AddressListbytes=[byte[]](YOUR VALUES GO HERE)
  20.  
  21. #>
  22.  
  23. function Convert-ByteArrayToHexString {
  24. ################################################################
  25. #.Synopsis
  26. # Returns a hex representation of a System.Byte[] array as
  27. # one or more strings. Hex format can be changed.
  28. #.Parameter ByteArray
  29. # System.Byte[] array of bytes to put into the file. If you
  30. # pipe this array in, you must pipe the [Ref] to the array.
  31. # Also accepts a single Byte object instead of Byte[].
  32. #.Parameter Width
  33. # Number of hex characters per line of output.
  34. #.Parameter Delimiter
  35. # How each pair of hex characters (each byte of input) will be
  36. # delimited from the next pair in the output. The default
  37. # looks like "0x41,0xFF,0xB9" but you could specify "\x" if
  38. # you want the output like "\x41\xFF\xB9" instead. You do
  39. # not have to worry about an extra comma, semicolon, colon
  40. # or tab appearing before each line of output. The default
  41. # value is ",0x".
  42. #.Parameter Prepend
  43. # An optional string you can prepend to each line of hex
  44. # output, perhaps like '$x += ' to paste into another
  45. # script, hence the single quotes.
  46. #.Parameter AddQuotes
  47. # An switch which will enclose each line in double-quotes.
  48. #.Example
  49. # [Byte[]] $x = 0x41,0x42,0x43,0x44
  50. # Convert-ByteArrayToHexString $x
  51. #
  52. # 0x41,0x42,0x43,0x44
  53. #.Example
  54. # [Byte[]] $x = 0x41,0x42,0x43,0x44
  55. # Convert-ByteArrayToHexString $x -width 2 -delimiter "\x" -addquotes
  56. #
  57. # "\x41\x42"
  58. # "\x43\x44"
  59. ################################################################
  60. [CmdletBinding()] Param (
  61. [Parameter(Mandatory = $True, ValueFromPipeline = $True)] [System.Byte[]] $ByteArray,
  62. [Parameter()] [Int] $Width = 10,
  63. [Parameter()] [String] $Delimiter = ",0x",
  64. [Parameter()] [String] $Prepend = "",
  65. [Parameter()] [Switch] $AddQuotes
  66. )
  67.  
  68. if ($Width -lt 1) { $Width = 1 }
  69. if ($ByteArray.Length -eq 0) { Return }
  70. $FirstDelimiter = $Delimiter -Replace "^[\,\\:\t]",""
  71. $From = 0
  72. $To = $Width - 1
  73. Do
  74. {
  75. $String = [System.BitConverter]::ToString($ByteArray[$From..$To])
  76. $String = $FirstDelimiter + ($String -replace "\-",$Delimiter)
  77. if ($AddQuotes) { $String = '"' + $String + '"' }
  78. if ($Prepend -ne "") { $String = $Prepend + $String }
  79. $String
  80. $From += $Width
  81. $To += $Width
  82. } While ($From -lt $ByteArray.Length)
  83. }
  84.  
  85.  
  86. $regpath="HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
  87.  
  88. $i = 1; gci $regpath | Select-Object @{name = 'Number'; expression = {$i; $null = $global:i++ }}, @{name = 'Profile Name'; expression = {$_.PSChildName;}}
  89. $choice = read-host "Select desired Outlook profile to map"
  90. $desiredprofile = (gci $regpath |select -Index ($choice - 1))
  91. $desiredprofile
  92.  
  93.  
  94. $desiredprofile | % {
  95. $outlookreg = $_.PSPath+"\9207f3e0a3b11019908b08002b2a56c2"
  96.  
  97.  
  98. $specifySearchOrder = Get-ItemProperty -Path $outlookreg -Name 11023d05 | Select -expandProperty 11023d05
  99.  
  100. $AddressListbytes = Get-ItemProperty -Path $outlookreg -Name 01023d06 | select -ExpandProperty 01023d06
  101.  
  102. }
  103.  
  104. "Paste this value as `$specifySearchOrder:`n"
  105. Convert-ByteArrayToHexString $specifySearchOrder
  106.  
  107. "`nPaste this value as `$AddressListbytes:`n"
  108. Convert-ByteArrayToHexString $AddressListbytes
  109.  
  110.  
  111. #$a | % {"0x"+[Convert]::ToString($_, 16)}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement