我试图从 中的数组中提取项目$IOC
,然后对于每个项目替换 $API here-string 中的 $IMPORT 并将结果回显到控制台,然后对数组中的每个项目执行此操作$IOC
。
#put IOC\'s into array\n$IOC= \xe2\x80\x98c:\\Users\\powershell_array.txt\'\n#api curl script with variable to be replaced\n$API = @"\ncurl --insecure \'https://192.168.1.1:3000/hx/api/v2/indicators/Custom/Powershell_AD/conditions/execution\' -X \'POST\' --data-binary "\n{ \n \\"tests\\":[ \n { \n \\"token\\":\\"processEvent/ActiveDirectory\\",\n \\"type\\":\\"text\\",\n \\"operator\\":\\"contains\\",\n \\"preservecase\\":false,\n \\"value\\":\\"$IMPORT\\"\n }\n ]\n}" -H \'X-FeApi-Token: IAOaiq1s2\' -H \'Accept: application/json\' -H \'Content-Type: application/json\'"\n"@\n\nForEach ($i in Get-Content $IOC) {$API -replace $IMPORT, $i} echo $API\n
Run Code Online (Sandbox Code Playgroud)\n\n我没有收到错误,但它只是打印数组的内容,然后当然会回显$API
一次而不进行替换。
powershell ×1