ワークフローと 2 つの単純な関数を含む Windows PowerShell 3.0 スクリプトがあります。ワークフローがなければ、Log
関数内で関数を使用できますが、ワークフローでは使用DoSomething
できません。スクリプトは次のとおりです。
function DoSomething()
{
# This is NOT logged
Log("This will fail...")
}
function global:Log([string]$Message)
{
Add-Content -Path "C:\my.log" -Value $Message
}
workflow New-CustomWorkflow
{
try
{
# This is logged
Log("Starting with the workflow")
DoSomething
}
catch
{
# This is logged
Log($_)
}
}
New-CustomWorkflow
の内容はmy.log
次のようになります。
ワークフロー
System.Management.Automation.RemoteException: 'Log' という用語は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。名前のスペルを確認するか、パスが含まれている場合は、パスが正しいことを確認してから再試行してください。Microsoft.PowerShell.Activities.PSActivity.OnResumeBookmark (NativeActivityContext コンテキスト、ブックマーク ブックマーク、オブジェクト値) で System.Activities.Runtime.BookmarkCallbackWrapper.Invoke (NativeActivityContext コンテキスト、ブックマーク ブックマーク、オブジェクト値) で System.Activities.Runtime.BookmarkWorkItem.Execute で(ActivityExecutor エグゼキュータ、BookmarkManager ブックマーク マネージャ)
これは可能ですか?私は何を間違っていますか?