I have been trying to loop through a list of .json config files to pull out 'name','entity_id','contact_info','sp_endpoint'. I have been trying to take the following code block, and dump it into a csv that lists each of the values in a column, and each row pertains to the file that value belongs to.
{
"sfg_ping::qa::standard_sp_connections": [
{
"name": "test",
"entity_id": "test",
"contact_info": "test@test.com",
"sp_endpoint": "test",
"sso_initialization_and_signature_policy": {
"sign_assertion_or_response": "response",
"sp_trust_model": "anchored",
"signing_certificate_id": "test",
"sp_initiated": {
"require_signed_authn_requests": true,
"primary_verification_certificate": "test"
}
}
I have been using this script to try and accomplish this, but it dumps empty values, and doesnt handle a bulk list of files.
Get-ChildItem -Path "C:\Users\user\appdev\powershell-scripts\spConnections" |
ForEach-Object {
{(Select-String -Pattern 'name' )}
{(Select-String -Pattern 'entity_id' )}
{(Select-String -Pattern 'contact_info' )}
{(Select-String -Pattern 'sp_endpoint' )}
}| Export-Csv "C:\Users\user\appdev\powershell-scripts\export.csv"
The intended output would be something like this:
| filename | name | entityid |
|:---------|:----:| --------:|
| test | test | test |
Really lost here and just looking for some direction.