在我的 PowerShell 脚本中 - 一个函数的输出是另一个函数的输入。
例如:除非函数 ParseXml($x) 运行,否则函数 CreateReport($x) 无法运行。如果用户在运行第一个函数之前直接运行第二个函数怎么办。
如何检查第一个函数是否已经运行以继续第二个函数,即首先运行第一个函数(生成 txt 文件)然后运行第二个函数?如果第一个 func 已经运行,则不要重新运行它。
例如:假设我有一个 TestFunc.ps1 文件,它有如下两个函数
$X = "C:\XmlPath\file1.xml"
Function ParseXml($X)
{
#Read xml and output contents in a txt file
}
#This function should execute only after the function Parsexml($X) and if Pasrsexml() has run before and generated the output, it shouldnot be allowed to re-run here
Function CreateReport($T)
{
#from the txtfile Create csv
}