I would like to use powershell to read and write to a database as part of a larger project. The connection string is already in the appsettings.json file in the project.
I searched around and found $json = Get-Content 'appsettings.json' | Out-String | ConvertFrom-Json
I keep getting an error:
ConvertFrom-Json : Invalid object passed in, ':' or '}' expected. (252): {
But the file has no issue when it is being read in by the C# application.
Is there a way to read the system configuration files in the same fashion as a C# application?
Something like:
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
Configuration = builder.Build();
Thanks in advance.