this discussionに基づいてマクロ置換を実装しようとしています。基本的には動作しますが、ExpandStringは、いくつかのlimitatoinsを持っているようだ:
main.ps1:
$foo = 'foo'
$text = [IO.File]::ReadAllText('in.config')
$ExecutionContext.InvokeCommand.ExpandString($text) | out-file 'out.config'
はin.config(OK):
$foo
はin.config(エラー:「が発生しました終了トークン文字列を処理しながら、ラインの "):
"
in.config(エラー: "文字列の末尾に「行方不明")。:
'
ドキュメントの状態:
Return Value: The expanded string with all the variable and expression substitutions done.
'式の置換は'(これは私の場合である可能性がある)とは何ですか?
回避策はありますか?
これは実際にPS2のバグで、修正されました: - / – Jaykul