Start a new topic

Default PowerShell Dynamic Folder Script fails

 The default JSON works as expected.

{
	"Objects": [
		{
			"Type": "Credential",
			"Name": "Root",
			"Username": "root",
			"Password": "!ehrfew9fe9gew7rgew@",
			"ID": "000001",
			"Path": "/Credentials"
		}, {
			"Type": "Folder",
			"Name": "Connections",
			"Objects": [
				{
					"Type": "TerminalConnection",
					"TerminalConnectionType": "SSH",
					"Name": "VM01",
					"ComputerName": "vm01",
					"CredentialID": "000001"
				}
			]
		}
	]
}


However, the default PowerShell script fails despite being identical in end JSON layout.

$ErrorActionPreference = "Stop"
@{
    Objects = (
        @{
            Type = "Credential";
            Name = "Root";
            Username = "root";
            Password = "!ehrfew9fe9gew7rgew@";
            ID = "000001";
            Path = "/Credentials";
        },
        @{
            Type = "Folder";
            Name = "Connections";
            Objects = @(
                @{
                    Type = "TerminalConnection";
                    TerminalConnectionType = "SSH";
                    Name = "VM01";
                    ComputerName = "vm01";
                    CredentialID = "000001";
                };
            );
        }
    )
} |
ConvertTo-Json -Depth 100 |
Write-Host

 The error received is as follows (provided as an image and text just in case):


 

An error occurred while parsing the output of a dynamic folder's script: Unexpected character encountered while parsing value: P.Path", line 0, position 0.

 


1 Comment

Your Objects is missing the @.


Line 3: Objects = (


Should be Objects = @(

Login or Signup to post a comment