look at this.... although this only reads, I'm sure there is a registry method to write to the registry as well. I would take a backup of the registry before I'd go poking my fingers around in there as well as make sure I'd do this in a sandbox area too.
upon further digging...here is a script fragment...
$protocolproperty=Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement -class ClientNetworkProtocolProperty `
-filter "PropertyName='Default Port'"
this came from the same site I mentioned above but different article...