【发布时间】:2022-07-22 02:58:04
【问题描述】:
这是我正在使用的非常基本的图片。它不会将设备显示为“合规”或“不合规”,而是显示“错误”或“待定”。我注意到日志中用作转义字符的反斜杠。路径会不会有问题?请指教。
$filePath = "C:\ProgramData\Autodesk\_PennoniCompliance"
$currentFileName = Get-ChildItem -Path $filePath -Name companyCompliance*.txt
$hash = @{
FileName = $currentFileName
}
Write-Output $hash
return $hash | ConvertTo-Json -Compress
我的 JSON 文件具有与 hashTable 'FileName' 中的匹配键
{
"Rules":[
{
"SettingName":"FileName",
"Operator":"IsEquals",
"DataType":"String",
"Operand":"PennoniCompliance_2021-0921.txt",
"MoreInfoUrl":"https://call4cloud.nl/2021/11/the-last-days-of-custom-compliance/#part1",
"RemediationStrings":[
{
"Language":"en_US",
"Title":"Must update text file suffix.",
"Description": "Must update the suffix containing the date (PennoniCompliance_yyyy-mmdd.txt) of the PennoniCompliance text file."
}
]
}
]
}
现在我正在寻找“合规”或“不合规”的状态,但看到的是“错误”或“待定”。我已经从一个示例中部署了一个自定义合规性策略,它运行良好,因此它与此代码有关。我还查看了失败时的 intuneManagementExtension 日志。
{"PolicyId":"0cb83122-b322-45f5-9ab1-8e75c28ce7f5","UserId":"5fc325b8-6b7b-4b95-9e66-df64471366e0","PolicyHash":null,"Result":3,"ResultDetails":null,"InternalVersion":2,"ErrorCode":0,"ResultType":3,"PreRemediationDetectScriptOutput":"{\"FileName\":{\"value\":\"PennoniCompliance_2021-0921.txt\",\"PSPath\":\"Microsoft.PowerShell.Core\\\\FileSystem::C:\\\\ProgramData\\\\Autodesk\\\\_PennoniCompliance\\\\PennoniCompliance_2021-0921.txt\",\"PSParentPath\":\"Microsoft.PowerShell.Core\\\\FileSystem::C:\\\\ProgramData\\\\Autodesk\\\\_PennoniCompliance\",\"PSChildName\":\"PennoniCompliance_2021-0921.txt\",\"PSDrive\":{\"CurrentLocation\":\"WINDOWS\\\\system32\",\"Name\":\"C\",\"Provider\":\"Microsoft.PowerShell.Core\\\\FileSystem\",\"Root\":\"C:\\\\\",\"Description\":\"Windows\",\"MaximumSize\":null,\"Credential\":\"System.Management.Automation.PSCredential\",\"DisplayRoot\":null},\"PSProvider\":{\"ImplementingType\":\"Microsoft.PowerShell.Commands.FileSystemProvider\",\"HelpFile\":\"System.Management.Automation.dll-Help.xml\",\"Name\":\"FileSystem\",\"PSSnapIn\":\"Microsoft.PowerShell.Core\",\"ModuleName\":\"Microsoft.PowerShell.Core\",\"Module\":null,\"Description\":\"\",\"Capabilities\":52,\"Home\":\"C:\\\\WINDOWS\\\\system32\\\\config\\\\systemprofile\",\"Drives\":\"C\"},\"PSIsContainer\":false}}","PreRemediationDetectScriptError":null,"RemediationScriptErrorDetails":null,"PostRemediationDetectScriptOutput":null,"PostRemediationDetectScriptError":null,"RemediationStatus":4,"Info":{"RemediationExitCode":null,"FirstDetectExitCode":0,"LastDetectExitCode":null,"ErrorDetails":null},"TargetType":1,"RunAsAccount":1,"AssignmentFilterIds":null,"BiosMetadata":null}
我只是不知道该怎么做。看起来反斜杠正在转义绝对路径,我不确定。我所知道的是,任何帮助将不胜感激。
【问题讨论】:
标签: powershell endpoint intune