Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- # - Name : Get Outlook Address Book sort order values
- # - Author : Stephen Owen
- # - Date : 07/06/2012
- # - 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
- # eventually, this function will be bundled into my Outlook GAL Script, but I've not had the time to do this yet.
- # - Thanks : This borrows VERY HEAVILY from SANS.Org's great Powershell Conversion functions reference page
- ~~~~~~*****NOTICE*****~~~~~~
- When you run this, you'll recieve HEX values, use them and over write the original values in my other script, sample exceprt below
- #set "11023d05", Specifies Address list sort order !!!! PASTE YOUR VALUES BELOW IN OTHER SCRIPT
- $specifySearchOrder = [byte[]](YOUR VALUES GO HERE)
- #set "01023d06", Specifies that Outlook should search the GAL first !!!! PASTE YOUR VALUES BELOW IN OTHER SCRIPT
- $AddressListbytes=[byte[]](YOUR VALUES GO HERE)
- #>
- function Convert-ByteArrayToHexString {
- ################################################################
- #.Synopsis
- # Returns a hex representation of a System.Byte[] array as
- # one or more strings. Hex format can be changed.
- #.Parameter ByteArray
- # System.Byte[] array of bytes to put into the file. If you
- # pipe this array in, you must pipe the [Ref] to the array.
- # Also accepts a single Byte object instead of Byte[].
- #.Parameter Width
- # Number of hex characters per line of output.
- #.Parameter Delimiter
- # How each pair of hex characters (each byte of input) will be
- # delimited from the next pair in the output. The default
- # looks like "0x41,0xFF,0xB9" but you could specify "\x" if
- # you want the output like "\x41\xFF\xB9" instead. You do
- # not have to worry about an extra comma, semicolon, colon
- # or tab appearing before each line of output. The default
- # value is ",0x".
- #.Parameter Prepend
- # An optional string you can prepend to each line of hex
- # output, perhaps like '$x += ' to paste into another
- # script, hence the single quotes.
- #.Parameter AddQuotes
- # An switch which will enclose each line in double-quotes.
- #.Example
- # [Byte[]] $x = 0x41,0x42,0x43,0x44
- # Convert-ByteArrayToHexString $x
- #
- # 0x41,0x42,0x43,0x44
- #.Example
- # [Byte[]] $x = 0x41,0x42,0x43,0x44
- # Convert-ByteArrayToHexString $x -width 2 -delimiter "\x" -addquotes
- #
- # "\x41\x42"
- # "\x43\x44"
- ################################################################
- [CmdletBinding()] Param (
- [Parameter(Mandatory = $True, ValueFromPipeline = $True)] [System.Byte[]] $ByteArray,
- [Parameter()] [Int] $Width = 10,
- [Parameter()] [String] $Delimiter = ",0x",
- [Parameter()] [String] $Prepend = "",
- [Parameter()] [Switch] $AddQuotes
- )
- if ($Width -lt 1) { $Width = 1 }
- if ($ByteArray.Length -eq 0) { Return }
- $FirstDelimiter = $Delimiter -Replace "^[\,\\:\t]",""
- $From = 0
- $To = $Width - 1
- Do
- {
- $String = [System.BitConverter]::ToString($ByteArray[$From..$To])
- $String = $FirstDelimiter + ($String -replace "\-",$Delimiter)
- if ($AddQuotes) { $String = '"' + $String + '"' }
- if ($Prepend -ne "") { $String = $Prepend + $String }
- $String
- $From += $Width
- $To += $Width
- } While ($From -lt $ByteArray.Length)
- }
- $regpath="HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
- $i = 1; gci $regpath | Select-Object @{name = 'Number'; expression = {$i; $null = $global:i++ }}, @{name = 'Profile Name'; expression = {$_.PSChildName;}}
- $choice = read-host "Select desired Outlook profile to map"
- $desiredprofile = (gci $regpath |select -Index ($choice - 1))
- $desiredprofile
- $desiredprofile | % {
- $outlookreg = $_.PSPath+"\9207f3e0a3b11019908b08002b2a56c2"
- $specifySearchOrder = Get-ItemProperty -Path $outlookreg -Name 11023d05 | Select -expandProperty 11023d05
- $AddressListbytes = Get-ItemProperty -Path $outlookreg -Name 01023d06 | select -ExpandProperty 01023d06
- }
- "Paste this value as `$specifySearchOrder:`n"
- Convert-ByteArrayToHexString $specifySearchOrder
- "`nPaste this value as `$AddressListbytes:`n"
- Convert-ByteArrayToHexString $AddressListbytes
- #$a | % {"0x"+[Convert]::ToString($_, 16)}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement