任何人都可以幫助我,爲什麼我的工件沒有傳遞到我的腳本文件?調用 - 表達式不起作用
caller.ps1
:
$FilePath = "C:\Users\test\Desktop\hashtest\generate-artifact-report.ps1"
$outputPath = "C:\Users\test\Desktop\hashtest\test.html";
$buildNumber=19;
$versionNumber ="2.3.7";
$artifacts = @()
$artifacts += @{Name="Test"; ExeLink="https://google.com"; MsiLink="https://google.com";}
$artifacts += @{Name="Test Stagning"; ExeLink="https://google.com"; MsiLink="https://google.com";}
$artifacts += @{Name="Test Stagning"; ExeLink="https://google.com"; MsiLink="https://google.com";}
$temp = [string]::Format("{0} {1} {2} {3} {4}", $GenerateArtifcateReportScript, $outputPath, $buildNumber, $versionNumber, $artifacts)
Invoke-Expression($temp)
generate-artifact-report.ps1
:
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True, Position =0)]
[string]$outputPath,
[Parameter(Mandatory=$True, Position =1)]
[string]$buildNumber,
[Parameter(Mandatory=$True, Position =2)]
[string]$versionNumber,
[Parameter(Mandatory=$True, Position =3)]
[System.Object[]]$artifacts
)
$Style = "
<style>
.brandCol { width:250px; font-weight:bold; padding:10px; }
.fileCol { width:250px; text-align:center; }
</style>
"
$BrandTable = "
<h1>WorkSmart Artifact Download Links</h1>
<div style='font-size:20px; padding:10px;'>
<strong>Build Number :</strong> $buildNumber<br />
<strong>Version :</strong> $versionNumber<br />
</div>
<table>
<tbody>
<tr>
<td class='brandCol'>Brands</td>
<td class='brandCol fileCol'>MSI</td>
<td class='brandCol fileCol'>EXE (With Prerequisite)</td>
</tr>";
foreach ($artifact in $artifacts) {
$name = $artifact.Name;
$exeLink = $artifact.ExeLink;
$msiLink = $artifact.MsiLink;
$BrandTable = $BrandTable + "
<tr>
<td class='brandCol'>$name</td>
<td class='fileCol'><a href='$msiLink'>Download</a></td>
<td class='fileCol'><a href='$exeLink'>Download</a></td>
</tr>";
}
$BrandTable = $BrandTable + "</tbody>
</table>
";
#Save the HTML Web Page
ConvertTo-Html -Head $Style -PreContent $BrandTable | Out-File $outputPath