- スクリプト名: $MyInvocation.MyCommand.Name
- スクリプトパス: $MyInvocation.MyCommand.Path
- スクリプトフォルダ: Split-Path $MyInvocation.MyCommand.Path -Parent
下記のような内容のPowerShell スクリプトをデスクトップの作成し実行してみてください。
$ScriptName = $MyInvocation.MyCommand.Name
$ScriptPath = $MyInvocation.MyCommand.Path
$ScriptFolder = Split-Path $MyInvocation.MyCommand.Path -Parent
Write-Output $ScriptName | Out-File -Append $ScriptFolder\test.txt
Write-Output $ScriptPath | Out-File -Append $ScriptFolder\test.txt
Write-Output $ScriptFolder | Out-File -Append $ScriptFolder\test.txt
デスクトップに test.txt ファイルが作成されます。

以上。
コメント