I need to create machinekey's for web servers and SSRS servers. A pretty common task when putting together farms.
The original code I used was from here.
https://support.microsoft.com/en-ca/kb/312906/en-us
I'm guessing just about everyone has stumbled on this bit of C# code.
I figured I'd turn it into a PowerShell script as it would fit within my environment and documentation better rather than pre-compiled code. And remove the requirement of needing to compile the code to begin with. This isn't exactly high performance computing after all.
Anyways, I stumbled on to this page:
http://jeffgraves.me/2012/06/05/read-write-net-machine-key-with-powershell/
Which pretty much has the meat of what I need to achieve my goal.
In reviewing the script I thought maybe I could change it up a bit. So I tried taking the for loop in the GenKey function and turn it into the following:
$result += $buff | ForEach-Object { [String]::Format('{0:x2}', $_ ) }
This looks great but the output of $result is slightly different. I get two characters, a space, two characters, a space and so on.
The question I have is does anyone know why it is putting in these spaces and potentially how to make this otherwise work?
One thing I did was the following:
$result.replace(' ','')
But that is just cheating IMO.
Desired output is something like this:
4002e8ba0450b45d2a9bd05f13a0526c329068655838991668e90e543bc86326966be13783155c276a130e4a37649dece26ba1428e0f7575b0b53620945bef05
Output I am getting is:
26 0f c9 a3 67 cf c2 b1 91 a1 c7 97 51 71 da e4 e9 d3 a7 79 a0 05 5b 23 70 7f 49 bb e4 8e 86 64 cb 27 42 c8 ca ac f7 9e b0 26 37 42 9b 4f 71 cf ff 82 45 24 8f e4 06 0c 64 31 f4 42 46 e5 92 af
- Edited by FluffySniper 12 hours 20 minutes ago Added information.