$IOC
의 배열에서 항목을 가져 오려고 시도한 다음 각 항목에 대해 $ API here-string의 $ IMPORT를 바꾸고 결과를 콘솔에 표시합니다. 그런 다음 $IOC
배열의 각 항목에 대해 이렇게합니다.here-string에서 변수 대체를 수행하려면 어떻게해야합니까?
#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
한 시간.
둘 다 정말 도움이되었습니다. 불행히도 아직 점수를 줄 수는 없지만 많은 도움을 얻었습니다. !!! –