My powershell script is printing a '1' before my expected output. Why?

瘦欲@ 提交于 2019-12-01 05:13:45
$SqlAdapter.Fill($DataSet) | Out-Null

Read here about DbDataAdapter.Fill and its return value:

Type: System.Int32 The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows.

Here is an alternative that casts to void without using the pipeline. The pipeline should be avoided for performance reasons.

[void] $SqlAdapter.Fill($DataSet);

You should be able to narrow it down to the actual line by injecting some lines that just print out some text. Once you find the actual line, you can pipe it through the "out-null" commandlet in order to suppress the output.

http://technet.microsoft.com/en-us/library/dd315279.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!