我知道您不能在工作流程中使用Read-Host。但我需要通過Read-Host提示用戶,然後在工作流程中使用該輸入數據。我們需要在遠程機器上執行MSG.EXE(因爲NetSend去拜拜了)將參數傳遞給Workflow(PowerShell)
我有這段代碼。它運行時沒有錯誤,但它不發送任何消息。如何將我的參數傳遞到工作流程,以便它可以工作?
$Computers = @("mg2014","cclab2","MG11751","mg10462","mg11768","mg11786","mg11741","mg13244","mg13434","mg14464", "mg10257")
workflow Test-WFConnection {
param(
[Parameter (Mandatory = $true)]
[object[]]$message
)
foreach -parallel ($computer in $computers) {
if (Test-Connection -ComputerName $computer -Count 1 -ErrorAction SilentlyContinue) {msg /SERVER:$computer * $msg}
}
}
$msg = Read-host "Enter your message here"
Test-WFConnection -message $msg
的問題是,$味精永遠不會被髮送到任何機器。
我能問你爲什麼使用工作流,而不是隻使用'Test-Connection'的'-AsJob'參數? –