私のPowerShellスクリプトでは、ある関数の出力は別の関数の入力です。
例:関数CreateReport($ x)は、関数ParseXml($ x)が実行されない限り実行できません。ユーザーが1番目の関数を実行する前に2番目の関数を直接実行した場合はどうなりますか。
1番目の関数がすでに実行されているかどうかを確認して2番目の関数を続行するにはどうすればよいですか?つまり、最初に1番目の関数を実行して(txtファイルを生成)、次に2番目の関数を実行しますか?最初のfuncがすでに実行されている場合は、再実行しないでください。
例:次の2つの関数を持つ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
}