以下命令在命令行中运行
mvn clean install -Denunciate.skip
Run Code Online (Sandbox Code Playgroud)
但是,由于错误,PowerShell中断了
[错误]未知生命周期阶段".skip".您必须以格式指定有效的生命周期阶段或目标
我在我的剧本中一遍又一遍地遇到这种情况.我有这行代码:
$Errors = Get-DeploymentErrors $uniqueID
Run Code Online (Sandbox Code Playgroud)
运行时,会为$ Errors分配Get-DeploymentErrors的结果和$ uniqueID的值.我只想为$ Errors分配Get-DeploymentErrors的结果.
以下是Get-DeploymentErrors函数:
Function Get-DeploymentErrors($uniqueID)
{
$Errors = @()
$conn = New-Object -TypeName System.Data.SqlClient.SqlConnection
$conn.ConnectionString = 'removed connection string'
$cmd = New-Object -TypeName System.Data.SqlClient.SqlCommand
$cmd.Connection = $conn
$cmd.CommandText = "removed sql statement"
$cmd.Parameters.AddWithValue("@uniqueID", $uniqueID)
$conn.Open()
$reader = $cmd.ExecuteReader()
if($reader.HasRows)
{
While ($reader.Read())
{
$error = New-Object -TypeName PSObject
$error | Add-Member -MemberType NoteProperty -Name StepID -Value $reader["StepID"]
$error | Add-Member -MemberType NoteProperty -Name DeploymentID -Value $reader["DeploymentID"]
$error | Add-Member -MemberType NoteProperty -Name MessageID …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用从Windows 7中的bat文件运行的PowerShell命令,用两个双引号替换文件(temp1.txt)中的所有双引号:
powershell -Command "(gc c:\temp\temp1.txt) -replace '\"', '\"\"' | Out-File -encoding UTF8 c:\temp\temp2.txt"
Run Code Online (Sandbox Code Playgroud)
我一直收到错误:
'Out-File' is not recognized as an internal or external command.
Run Code Online (Sandbox Code Playgroud)
当我更改命令以用字母"b"替换字母"a"时,它可以正常工作:
powershell -Command "(gc c:\temp\temp1.txt) -replace 'a', 'b' | Out-File -encoding UTF8 c:\temp\temp2.txt"
Run Code Online (Sandbox Code Playgroud)
我需要转义双引号,因为整个powershell -Command都是双引号字符串.你怎么逃避双重报价?
我有以下网站http://www.shazam.com/charts/top-100/australia显示歌曲,我想用RegEx和PowerShell捕捉歌曲.下面的PowerShell代码是我到目前为止的代码:
$ie = New-Object -comObject InternetExplorer.Application
$ie.navigate('http://www.shazam.com/charts/top-100/australia')
Start-Sleep -Seconds 10
$null = $ie.Document.body.innerhtml -match 'data-chart-position="1"(.|\n)*data-track-title=.*content="(.*)"><a href(.|\n)*data-track-artist=\W\W>(.|\n)*<meta\scontent="(.*)"\sitemprop';$shazam01artist = $matches[5];$shazam01title = $matches[2]
Run Code Online (Sandbox Code Playgroud)
数据图表位置
数据轨道标题
数据跟踪艺术家
列出的每首歌曲都有3个值(上图)与每个歌曲相关联,我想根据不同的图表位置(数字)捕捉每首歌曲的艺术家和标题.所以正则表达式找到实际的图表位置,然后是尾随的艺术家和标题.
如果我单独为艺术家和标题(下面的代码)运行RegEx,它会找到它们,但它只找到第一个艺术家和标题.我需要根据不同的图表位置找到每首歌曲的艺术家和标题.
$null = $ie.Document.body.innerhtml -match 'data-track-artist=\W\W>(.|\n)*<meta\scontent="(.*)"\sitemprop';$shazam01artist = $matches[2]
$null = $ie.Document.body.innerhtml -match 'data-track-title=.*content="(.*)"><a href';$shazam01title = $matches[1]
$shazam01artist
$shazam01title
Run Code Online (Sandbox Code Playgroud) 我之前从未使用过Azure PowerShell,但现在我正在运行一个命令让Azure保留一个静态IP地址:
New-AzureReservedIP -ReservedIPName"137.117.11.18"-Label"people-dns-ip"-Location"US West"
然后我收到此错误:New-AzureReservedIP:未指定默认订阅.
所以,我试图找出什么是或只是设置为默认...使用命令Select-AzureSubscription我可以看到订阅名称BizSpark不存在.
不知道如何在屏幕上打印Get-AzureSubscription的值,但在我的Azure门户中说:SUBSCRIPTION NAME BizSpark
知道如何解决这个问题吗?或者这个选项仅限于BizSpark用户?
我有一个变量,有一个字符串,收到像心脏一样的奇怪字符.
除此之外,无论如何我想知道:我如何留下一个只包含字母和数字的字符串,丢弃其余部分或者不用任何东西替换它(不添加空格或任何东西)
我的第一个想法是使用正则表达式,但我想知道Powershell是否有更自然的东西可以自动执行.
我正在尝试从C#应用程序运行PowerShell脚本。我知道如何使用绝对路径:
using (PowerShell pshell = PowerShell.Create())
{
pshell.AddScript( @"C:\Path\To\Webapp\psScript.ps1" );
pshell.Invoke();
}
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么做是使用相对路径。我psScript.ps1的目录与Visual Studio项目位于同一目录中,并且我想使用相对路径(例如./psScript.ps1),这样当我将项目发布/导出到不同的计算机时,脚本的路径就不会变成无效
那么,如何在PowerShell.AddScript()方法中使用相对路径?任何帮助,将不胜感激!
我在这里看了一下,但这没有回答我的问题: PowerShell:从脚本目录运行命令
是否可以将MSI产品代码从MSI文件中提取出来,而无需使用PowerShell进行安装?我想将MSI文件的产品代码与安装在机器上的MSI代码进行比较,以了解该文件是否以前安装过。
我有这个场景,我从AssemblyInfo.cs获得了项目的汇编版本,例如2.0.0,如下所示:
[assembly: AssemblyVersion("2.0.0")]
Run Code Online (Sandbox Code Playgroud)
另外,我想检索这个AssemblyVersion并将其作为web.config中参数的一部分动态设置,例如下面,例如:
<my.config.group>
<version versionNumber="2.0.0" />
</my.config.group>
Run Code Online (Sandbox Code Playgroud)
我需要动态设置上面的版本号作为我的程序集的版本号,以避免在发生变化时手动修改它.
这是必需的,因为我们使用的第三方库如何工作.因此,无法使用替代方法获取程序集版本.我们必须坚持使用web.config.
实现这一目标的最佳解决方案是什么?我在考虑使用Powershell脚本Post-Build,但是,我在Powershell方面的经验很少,所以我想知道什么是最好的解决方案.
在Sitecore Powershell中为Sitecore 7.2 ...
是否可以在给定项目上设置"可发布"权限(使其不可发布)?
具体来说,我希望自动执行以下过程:选择项目,打开Publish > Restrictions > Change,单击项目选项卡,然后取消选中"可发布"框.
我试过找到没有运气的物品属性.我认为这可能有效,但"__Publishable"不正确:
(get-item -Path master:/sitecore/content/Path/Home/About-Us)."__Publishable"
Run Code Online (Sandbox Code Playgroud)
有没有办法让Powershell报告项目的所有属性?
powershell ×10
.net ×1
azure ×1
batch-file ×1
c# ×1
escaping ×1
function ×1
maven ×1
pipeline ×1
regex ×1
sitecore ×1
variables ×1
web-config ×1