小编Zul*_*ala的帖子

如何使用任务计划程序在静默/隐藏模式下运行Powershell脚本?

我正在尝试使用任务计划程序运行powershell脚本,它会弹出powershell cmd窗口。有没有办法在运行脚本时禁用此功能?我在Powershell v5.0上

我尝试了-WindowStyle隐藏,但仍然弹出powershell cmd窗口。

欢迎任何指导。

谢谢。

windows powershell windows-10 powershell-5.0

3
推荐指数
1
解决办法
3293
查看次数

Powershell SQL Server数据库连接和连接超时问题

我有一个Powershell脚本连接到运行SQL查询的SQL Server 2012数据库,并将结果集放入数据表中,以将格式化的电子邮件发送给相关方。以下是问题所在的代码段:

$CBA = New-Object System.Data.DataSet "CBAData"
$sqlConn = New-Object System.Data.SqlClient.SqlConnection("Data Source=DataSource;Initial Catalog=DataCatalog;Integrated Security = False;Connection Timeout=800;User ID = user; Password =pwd;")
$adapter = New-Object System.Data.SqlClient.SqlDataAdapter($CBAData, $sqlConn)
$adapter.Fill($CBA)
Run Code Online (Sandbox Code Playgroud)

我在运行脚本时遇到以下错误:

Exception calling "Fill" with "1" argument(s): "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding."
Run Code Online (Sandbox Code Playgroud)

我尝试将SqlConnection字符串的超时从最初设置的360逐渐增加到现在的800,但仍然存在相同的问题。有人对这到底是什么问题有见解吗?以及我该如何覆盖呢?

先感谢您。

sql-server powershell sql-server-2012 powershell-4.0

1
推荐指数
2
解决办法
5917
查看次数