我试图拉$IOC
从阵列中的项目,然后对每个项目替换$ API下面的字符串的$ IMPORT,并将结果回显到控制台,然后为$IOC
阵列中的每个项目执行此操作。我该怎么办变量替换在下面的字符串
#put IOC's into array
$IOC= ‘c:\Users\powershell_array.txt'
#api curl script with variable to be replaced
$API = @"
curl --insecure 'https://192.168.1.1:3000/hx/api/v2/indicators/Custom/Powershell_AD/conditions/execution' -X 'POST' --data-binary "
{
\"tests\":[
{
\"token\":\"processEvent/ActiveDirectory\",
\"type\":\"text\",
\"operator\":\"contains\",
\"preservecase\":false,
\"value\":\"$IMPORT\"
}
]
}" -H 'X-FeApi-Token: IAOaiq1s2' -H 'Accept: application/json' -H 'Content-Type: application/json'"
"@
ForEach ($i in Get-Content $IOC) {$API -replace $IMPORT, $i} echo $API
我没有得到一个错误,但它只是打印数组的内容,然后当然回声的$API
一次没有更换。
两个真正帮助,不幸的是我不能给点还没有,但它是非常赞赏。! –