小编Ris*_*rks的帖子

Powershell 调用-SQLCmd 和 SQLPS

Windows 7 工作站 POSH 3.0 SS 2012 SP1

摘要:
Developer 1 无法运行 Invoke-SQLCmd
Developer 2 具有类似 SS Client 工具安装可以运行 Invoke-SQLCmd
Developer 1 无法运行 Import-Module SQLPS

当我尝试从笔记本电脑运行查询时,如下所示:

Invoke-sqlcmd -ServerInstance <ServerName> -Query "Select top 10 * from <SomeTable>;"
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Invoke-sqlcmd : The 'Invoke-sqlcmd' command was found in the module 'SQLPS', 
but the module could not be loaded. For more information, run 'Import-Module 
SQLPS'. 
Run Code Online (Sandbox Code Playgroud)

另一位开发人员可以成功运行该命令,并且我们都有本地

由于明显的原因,我无法在我的计算机上运行导入模块 sqlps - ExecutionPolicy 受到限制。

我不确定为什么其他开发人员的机器允许查询,而我的机器不允许。这是 SQL 客户端安装问题吗?

powershell import-module executionpolicy sqlps

5
推荐指数
2
解决办法
4万
查看次数

将字符串附加到数组的每个项目

我有一个数组,当我尝试向其添加字符串时,该数组将转换为单个字符串。

我在数组中有以下数据:

$Str  
451 CAR,-3 ,7 ,10 ,0 ,3 , 20 ,Over: 41  
452 DEN «,40.5,0,7,0,14, 21 ,  Cover: 4  
Run Code Online (Sandbox Code Playgroud)

我想在这种情况下像这样添加游戏的一周:

$Str = "Week"+$Week+$Str 
Run Code Online (Sandbox Code Playgroud)

我得到一个字符串:

Week16101,NYG,42.5 ,3 ,10 ,3 ,3 , 19 ,Over 43 102,PHI,-  1,14,7,0,3, 24 ,  Cover 4 103,
Run Code Online (Sandbox Code Playgroud)

当然,我希望追加发生在每一行上。

arrays powershell append

4
推荐指数
3
解决办法
9755
查看次数