' is not recognized as the name of a cmdlet answer)中所描述的。(特别是当用户名错误时),作业以成功结束,即使错误记录在输出中也是如此。在https://ss64.com/ps/syntax-operators.html中没有提到它。将子表达式保存到$SQLOutput的另一个问题是,我们只能在$(Invoke-Sqlcmd)完成之后才能看到输出
嗨,我已经构造了一个运行良好的脚本,除了一件事,有时返回的字符串太长了,它不适合在powershell控制台中,当我稍后将文本发送到一个richtextbox时,我得到了所有的.在最后而不是整根绳子$sqlcmd = $sqlconnection.CreateCommand()
$sqlcmd.CommandText= "SELECT Info from SCCM.dbo.log WHERE Username =