出于專有原因洗掉源
錯誤
Out-String:找不到接受引數“System.Object[]”的位置引數。在行:176 字符:28
-
content = $summaries | Out-String `
uj5u.com熱心網友回復:
注意:這不是一個完整的答案,但它解決了您的直接問題 - 損壞的[pscustomobject]文字語法 - 并提供了一些背景資訊。
Format-Table與所有Format-*cmdlet 一樣,僅用于生成顯示輸出,而不是編程處理。
要生成資料(物件),請使用,它對引數Select-Object使用與 相同的語法,特別是包括您的呼叫使用的計算屬性。-PropertyFormat-TableFormat-Table
Select-Object輸出[pscustomobject]每個具有指定屬性的實體。
因此,您可能正在尋找這個:
# Note The ` at the end of the line continues the Select-Object call
# on the next line, and the following lines are an array of
# property names / calculated properties that are passed
# to the positionally implied -Property parameter
$payload = $summaries | Select-Object `
start,
end,
@{ Label = 'issued_amount'; Expression = { '{0:C0}' -f $_.issued_amount }; Align = 'right' },
@{ Label = 'maturing_amount'; Expression = { '{0:C0}' -f $_.maturing_amount }; Align = 'right' },
@{ Label = 'inflation_compensation'; Expression = { '{0:C0}' -f $_.inflation_compensation }; Align = 'right' },
@{ Label = 'secondary_purchased'; Expression = { '{0:C0}' -f $_.secondary_purchased_amount }; Align = 'right' },
@{ Label = 'secondary_sold'; Expression = { '{0:C0}' -f $_.secondary_sold_amount }; Align = 'right' },
@{ Label = 'change'; Expression = { '{0:$#,##0}' -f $_.change }; Align = 'right' }
$payload現在是[pscustomobject]具有指定屬性的實體陣列。
但是,您似乎無法將這樣的陣列直接傳遞給Send-DiscordMessage,除非通過-Text引數,這需要您通過以下方式創建格式化的字串表示Out-String:
Send-DiscordMessage -Uri $hookUrl -Text ($payload | Out-String)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/513264.html
標籤:电源外壳不和谐
下一篇:在引數中強制使用完整的域名
