Make Powershell use a config file to reference server specific settings.

One of the useful things in my multi server environments is to keep server specific definitions out of my code. Alot of my powershell solutions are now pre-loading a config file to get some basic settings before performing it’s tasks.


#config contents
$output = @{};
$output.site = "http://sharepoint.local/site_instance/";
#save it
$output | ConvertTo-Json | Out-File -filepath config.json
#load it
$output = (Get-Content config.json) -join "`n" | ConvertFrom-Json
#print it
$output | ConvertTo-Json;

only file that differs is config.json. which can be a hard-link to one of my multiple server files config.dev.json, config.staging.json, config.prod.json.

I use similar technique to manage my linux servers.