我有一个Powershell脚本,MSSQLStartStopServices.ps1用于停止一些SQL Server服务.使用第三方供应商软件调用此脚本.有问题的参数是Fully qualified instance name和Start|Stop
例如
MSSQLStartStopServices.ps1 HOSTNAME\INSTANCENAME Start
Run Code Online (Sandbox Code Playgroud)
对于默认实例,软件将(本地)传递为INSTANCENAME.
MSSQLStartStopServices.ps1 HOSTNAME\(local) Start
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,我从Powershell得到一个错误:
术语"本地"不会被识别为cmdlet,函数,脚本文件或可操作程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.
当我尝试将实例名称放在引号中时,它在Powershell窗口中正常工作:
MSSQLStartStopServices.ps1 "HOSTNAME\(local)" Start
Run Code Online (Sandbox Code Playgroud)
但是第三方软件首先从命令行调用Powershell,如下所示:
powershell .\MSSQLStartStopServices.ps1 "HOSTNAME\(local)" Start
Run Code Online (Sandbox Code Playgroud)
这会导致相同的错误,就好像引号不存在一样.
我该如何解决这个问题?
和数字一样?
例如,
$string = "Hello"
$string =+ " there"
Run Code Online (Sandbox Code Playgroud)
在Perl中你可以做到
my $string = "hello"
$string .= " there"
Run Code Online (Sandbox Code Playgroud)
这似乎有点冗长
$string = $string + " there"
Run Code Online (Sandbox Code Playgroud)
要么
$string = "$string there"
Run Code Online (Sandbox Code Playgroud) 我想测试Output.ScriptPubKey.Addresses数组是否为null,然后将其分配给参数列表.如果它为null,那么我想将参数值设置为0,否则使用数组中的项目数.
我在下面写的内容感觉笨拙和冗长,有更优雅的方式吗?
int addressCount;
if (Output.ScriptPubKey.Addresses == null) { addressCount = 0; } else {
addressCount = Output.ScriptPubKey.Addresses.Length;
}
var op = new DynamicParameters();
op.Add("@AddressCount", addressCount);
Run Code Online (Sandbox Code Playgroud)
代码曾经是:
op.Add("@AddressCount", Output.ScriptPubKey.Addresses.Length);
Run Code Online (Sandbox Code Playgroud)
但有时Addresses阵列是空的.
我正在从SQL Server检索图像,以使用此方法在我的ASP.NET 4.0应用程序中的新页面上显示(我的一篇帖子):
如何在GridView中基于SelectedValue显示图像?
然后我使用这种方法在新窗口中显示图像:(我的一个帖子):
我要做的是获取图像的高度和宽度,以便创建新窗口,其高度和宽度与存储的图像相同.我想有两种方法可以做到这一点:
我已经在数据库中拥有超过150个图像,这使得选项1变得困难,因为我必须返回我的数据库并计算已经在数据库中的图像的高度和宽度.因此,我更愿意使用选项2,或者可能还有其他选择?我该怎么做呢?
谢谢你的期待.