This is how my input string ($inputStr) looks like:
{
"CloudId" : "67f8f457-1c4a-4622-a743-638318af04e3",
"ComputerName" : "Computer1",
"DeploymentErrorInfo" : {
"IsConditionallyTerminating" : null,
"MomAlertSeverity" : null,
"DisplayableErrorCode" : null,
"IsSuccess" : null,
"DetailedCode" : null,
"IsMomAlert" : null,
"DetailedSource" : null,
"CloudProblem" : null,
"IsTerminating" : null,
"DetailedErrorCode" : null,
"ExceptionDetails" : null,
"Code" : null,
"ShowDetailedError" : null,
"RecommendedActionCLI" : null,
"ErrorCodeString" : null,
"IsDeploymentBlocker" : null,
"ErrorType" : null,
"RecommendedAction" : null,
"Problem" : null,
"MessageParameters" : null
},
"GrantedToList" : [],
"ID" : "00000000-0000-0000-0000-000000000000",
"LocalAdminUserName" : "administrator",
"Name" : "Computer1",
"NewVirtualNetworkAdapterInput" : [],
"OperatingSystemInstance" : {
"Architecture" : null,
"Edition" : null,
"Description" : null,
"Version" : null,
"Name" : null,
"OSType" : null,
"ProductType" : null
},
"Owner" : {
"UserName" : null,
"RoleID" : null,
"RoleName" : null
},
"StampId" : "23e6799c-33d4-45ea-8e4f-49ec7d5f26e0",
"StartVM" : true,
"VMNetworkAssignments" : [],
"VMTemplateId" : "fdc73f71-1c6d-4e8f-9d02-21c7f4756c2d"
}
I am converting this to an object using ConvertFrom-Json command.
$paramObject = ConvertFrom-Json -InputObject $inputStr
I want it to print 'VM Computer1 is ready' but it does not work and it actually prints the whole string:
Write-Host "VM $paramObject.Name is ready" # prints the entire thing
Write-Host 'VM $paramObject.Name is ready' # prints command
Write-Host $paramObject.Name # prints VM Name so I know I am able to get the VM Name.
Aucun commentaire:
Enregistrer un commentaire