VB.NET-PS管道-响应错误
我正在vb.net应用程序中执行PS命令,PS命令需要回答“是”或“否”才能继续 下面是我的命令管道代码:VB.NET-PS管道-响应错误,vb.net,powershell,pipeline,Vb.net,Powershell,Pipeline,我正在vb.net应用程序中执行PS命令,PS命令需要回答“是”或“否”才能继续 下面是我的命令管道代码: Command.AddCommand("Set-MailboxAutoReplyConfiguration").AddParameter("Identity", username).AddParameter("AutoReplyState", "Scheduled").AddParameter("StartTime", Format(FWDStart, "yyyy-MM-dd HH:mm:
Command.AddCommand("Set-MailboxAutoReplyConfiguration").AddParameter("Identity", username).AddParameter("AutoReplyState", "Scheduled").AddParameter("StartTime", Format(FWDStart, "yyyy-MM-dd HH:mm:ss")).AddParameter("EndTime", Format(FWDEnd, "yyyy-MM-dd HH:mm:ss")).AddParameter("InternalMessage", message)
这就是我尝试对异常的响应:
Try
results = pipeline.Invoke()
Catch ex As Exception
Dim messageresponse As Integer = MessageBox.Show(ex.Message, "User Information", MessageBoxButtons.YesNo, MessageBoxIcon.Error)
If messageresponse = DialogResult.Yes Then
pipeline.AddScript("Yes")
ElseIf messageresponse = DialogResult.No Then
pipeline.AddCommand("No")
End If
Try
pipeline.Invoke()
Catch ex2 As Exception
MessageBox.Show(ex.Message, "User Information", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Try
对于messageresponse
IF
语句,我确实尝试了pipeline.AddCommand
/.AddScript
/.AddParamater
,但这不起作用
异常错误包含以下消息:“提示用户的命令失败,因为主机程序或命令类型不支持用户交互。”
我尝试了第一条评论中提供的.AddParameter(“Confirm”,false)解决方案,但没有成功
该错误是由在exchange中设置ForwardingSMTPAddress引起的,因为这是通过管理门户在办公室外设置时设置的。我们现在想通过应用程序进行设置,这将在ForwardingAddress字段中进行设置。MS文档()显示-Confirm
参数可用于使用-Confirm:$false>绕过确认提示。我认为您应该能够做到以下几点:
Command.AddCommand("Set-MailboxAutoReplyConfiguration").AddParameter("Identity", username).AddParameter("AutoReplyState", "Scheduled").AddParameter("StartTime", Format(FWDStart, "yyyy-MM-dd HH:mm:ss")).AddParameter("EndTime", Format(FWDEnd, "yyyy-MM-dd HH:mm:ss")).AddParameter("InternalMessage", message).AddParameter("Confirm", false)