Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String Powershell字符串参数验证_String_Powershell_Formatting - Fatal编程技术网

String Powershell字符串参数验证

String Powershell字符串参数验证,string,powershell,formatting,String,Powershell,Formatting,我有一个与SQL Server相关的powershell脚本,它要求用户仅以以下格式传递字符串:machineName\instanceName。例如,MYMACHINE\MYINST。如果参数不是此格式,脚本应显示用法语法。有人能提供脚本吗。提前谢谢。您要找的。在脚本的开头放上如下内容: [CmdletBinding] Param [参数] [验证说明]{ 如果$\匹配'.+\.+'{ $true }否则{ Write Host参数的格式必须为MACHINE\INSTANCE $false }

我有一个与SQL Server相关的powershell脚本,它要求用户仅以以下格式传递字符串:machineName\instanceName。例如,MYMACHINE\MYINST。如果参数不是此格式,脚本应显示用法语法。有人能提供脚本吗。提前谢谢。

您要找的。在脚本的开头放上如下内容:

[CmdletBinding] Param [参数] [验证说明]{ 如果$\匹配'.+\.+'{ $true }否则{ Write Host参数的格式必须为MACHINE\INSTANCE $false } }] [字符串]$Instance
你好,新用户,这里不是人们为你编写脚本的地方。你需要自己尝试一下,如果你被卡住了,我会帮你的。对不起,事情太紧急了。下次我会尝试,然后问我是否失败。谢谢