所以我试图从这里使用这个powershell负载:Getting the current hash key in a ForEach-Object loop in powershell
$myHash.keys | ForEach-Object {
Write-Host $_["Entry 1"]
}
一切正常,但我想将值作为另一个字符串的一部分输出,即:
$results.notvalid | ForEach-Object {
write-warning 'Incorrect status code returned from $_["url"],
code: $_["statuscode"]'
}
所以我希望输出为:
从 www.xxxx.com 返回的状态码不正确,代码:404
但相反我得到
Incorrect status code returned from $_["url"], code: $_["statuscode"]
我错过了什么?
顺便说一句,如果我这样做的话,这可行
$results.notvalid | ForEach-Object {
write-warning $_["url"]
}
然后我得到
www.xxxx.com