简体   繁体   English

我需要哪些管理单元来运行sql server powershell?

[英]Which snapins do I need to run sql server powershell?

what snapins or initializations do I need to run a sql server powershell script (using invoke-sqlcmd), as a batch file or windows scheduled task?? 我需要作为批处理文件或Windows计划任务来运行sql server powershell脚本(使用invoke-sqlcmd)的哪些管理单元或初始化程序?

I have tried the following: 我尝试了以下方法:

# mysqlscript.ps1
. "D:\Posh\init-sql.ps1"
invoke-sqlcmd .....

where init-sql.ps1 is the provider initialization as described by Microsoft (see Adding the SQL Server Snap-ins to Windows PowerShell ). 其中,init-sql.ps1是Microsoft所描述的提供程序初始化(请参阅将SQL Server管理单元添加到Windows PowerShell中 )。

Then, I tried the following: 然后,我尝试了以下方法:

powershell.exe -noe "D:\Posh\mysqlscript.ps1"

What happens is just the opening of the powershell command prompt. 发生的只是打开powershell命令提示符。 I'm pretty sure that the invoke-sqlcmd is not executed. 我很确定不会执行invoke-sqlcmd。

Thanks Emi 谢谢Emi

If all you want to do is use invoke-sqlcmd you could use a very simple function in its place: 如果您只想使用invoke-sqlcmd,则可以使用一个非常简单的函数代替它:

Copy the function invoke-sqlcmd2 into your script: 将函数invoke-sqlcmd2复制到脚本中:

http://poshcode.org/2279 http://poshcode.org/2279

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SSIS父级不需要密码,但子级软件包却需要密码-如何使它在SQL Server代理中运行? - SSIS parent doesn't need password but child packages do - how do I get this to run in SQL server Agent? 如果已经安装了SQL Server,是否需要安装SQL Express? - Do I need to install SQL Express if SQL Server is already installed? SQL Server:我是否需要在批次之间使用GO语句? - SQL Server: Do I need to use GO statements between batches? SQL Server如何运行动态语句 - SQL Server how do I run a dynamic statement 我是否需要对所需的结果集使用可怕的sql server循环/游标? - Do I need to use the dreaded sql server loop/ cursor for the result set I need? SSDT,如果我需要将相同的数据库部署到SQL Server 2008和2012,我是否需要不同的dacpac? - SSDT, do I need different dacpacs if I need to deploy the same db to SQL Server 2008 and 2012? SQL Server和WAMP Server是否冲突? 我需要使用其他端口吗? - Do SQL Server and WAMP Server clash? Do I need to use different ports? SQL Server 2008:我有1000张表,我需要知道哪些表有数据 - SQL Server 2008: I have 1000 tables, I need to know which tables have data 我需要SQL Server 2008的SQL查询 - i need sql query for sql server 2008 我们真的需要在SQL Server 2008 R2中运行真空吸尘器吗? - Do we really need to run the Vacuuming in SQL Server 2008 R2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM