I';我正在使用Powershell与Microsoft Graph API对话。但是,我的JSON没有';我不能工作,我不知道为什么。有人能帮我吗?

I';我正在使用Powershell与Microsoft Graph API对话。但是,我的JSON没有';我不能工作,我不知道为什么。有人能帮我吗?,json,powershell,azure-ad-graph-api,Json,Powershell,Azure Ad Graph Api,我正在尝试使用Graph API向Intune添加法规遵从性策略。然而,当我尝试使用它时,它会说“提供的JSON不是有效的JSON格式”和“无效的JSON原语:True” 我使用的代码来自Microsoft Graph示例(已找到) 我认为这可能很简单,但我对Powershell没有太多经验。但我似乎找不到它 $JSON_Android = @" { "@odata.type": "#microsoft.graph.androidCompliancePolicy", "

我正在尝试使用Graph API向Intune添加法规遵从性策略。然而,当我尝试使用它时,它会说“提供的JSON不是有效的JSON格式”和“无效的JSON原语:True”

我使用的代码来自Microsoft Graph示例(已找到)

我认为这可能很简单,但我对Powershell没有太多经验。但我似乎找不到它

$JSON_Android = @"

    {
    "@odata.type": "#microsoft.graph.androidCompliancePolicy",
    "displayName": "Google_Android_Device_Compliance_Powershell",
    "passwordRequired": true,
    "passwordMinimumLength": 5,
    "passwordRequiredType": "numeric",
    "passwordMinutesOfInactivityBeforeLock": 15,
    "passwordExpirationDays": null,
    "passwordPreviousPasswordBlockCount": 5,
    "securityPreventsInstallAppsFromUnknownSource": true,
    "securityDisableUsbDebugging": false,
    "requireAppVerify": false,
    "deviceThreatProtectionEnabled": false,
    "deviceThreatProtectionRequiredSecurityLevel": "unavailable",
    "securityBlockJailbrokenDevices": true,
    "osMinimumVersion": null,
    "osMaximumVersion": null,
    "minAndroidSecurityPatchLevel": null,
    "storageRequireEncryption": true
    "securityRequireSafetyNetAttestationBasicIntegrity": false,
    "securityRequireSafetyNetAttestationCertifiedDevice": false,
    "securityRequireGooglePlayServices": false,
    "securityRequireUpToDateSecurityProviders": false,
    "securityRequireCompanyPortalAppIntegrity": true
    }

"@


####################################################

$JSON_iOS = @"

  {
  "@odata.type": "microsoft.graph.iosCompliancePolicy",
  "displayName": "Apple_iOS_Device_Compliance_Powershell",
  "passCodeBlockSimple": true,
  "passcodeExpirationDays": null,
  "passcodeMinimumLength": 5,
  "passcodeMinutesOfInactivityBeforeLock" 15,
  "passcodePreviousPasscodeBlockCount": 5,
  "passcodeMinimumCharacterSetCount": null,
  "passcodeRequiredType": "numeric",
  "passcodeRequired": true,
  "osMinimumVersion": null,
  "osMaximumVersion": null,
  "securityBlockJailbrokenDevices": true,
  "deviceThreatProtectionEnabled": false,
  "deviceThreatProtectionRequiredSecurityLevel": "unavailable",
  "managedEmailProfileRequired": false
  }

"@

####################################################

$JSON_Windows10 = @"

    {
    "@odata.type": "microsoft.graph.windows10MobileCompliancePolicy",
    "displayName": "Microsoft_Windows_Device_Compliance_Powershell"
    "passwordRequired": true,
    "passwordBlockSimple": false,
    "passwordMinimumLength": 5,
    "passwordMinimumCharacterSetCount": null,
    "passwordRequiredType": "numeric",
    "passwordRequiredToUnlockFromIdle": false,
    "passwordExpirationDays": null,
    "passwordPreviousPasswordBlockCount": 5,
    "passwordMinutesOfInactivityBeforeLock": 15,
    "requireHealthyDeviceReport": false,
    "osMinimumVersion": null,
    "osMaximumVersion": null,
    "mobileOsMinimumVersion": null,
    "mobileOsMaximumVersion": null,
    "earlyLaunchAntiMalwareDriverEnabled": false,
    "bitLockerEnabled": false,
    "secureBootEnabled": false,
    "codeIntegrityEnabled": false,
    "storageRequireEncryption": true,
    "activeFirewallRequired": false,
    "uacRequired": false,
    "validOperatingSystemBuildRanges": false
    }

"@

您的
True
False
值应分别为
True
False
;注意大小写差异。

“storageRequireEncryption”:true


在第一个JSON中,后面应该有一个逗号

问题似乎出在Android JSON上,因为这就是它停止的地方。“我正在使用Powershell与Microsoft Graph API对话。但是,我的JSON不工作,我不知道为什么。”这不是一个问题。我已经解决了这个问题和几个缩进问题。这次它给出的错误是不同的,所以这似乎至少解决了一些问题。哈哈!不久前我就有这个问题。我只记得我当时在想,这不可能是问题所在,事实确实如此。解析器!更重要的是,几乎所有其他编程语言都是区分大小写的,PowerShell甚至在函数、变量名和关键字方面都遵循Microsoft的区分大小写方式<代码>$true-eq$true-eq$true