xlogI125’s blog

パソコン作業を効率化したい

PowerShell練習 パスに角括弧[]を含む作業フォルダー 2

メモ

powershell.exe から powershell.exe -ExecutionPolicy RemoteSigned を実行したのち、以下の内容を試す。

バージョン: PowerShell 5.1, Windows 11

作業フォルダー

C:\()\[]\

このフォルダへの移動

Set-Location -LiteralPath 'C:\()\[]\'

ファイル名にシングルクォートを含む場合

パス

C:\()\[]\'.ps1

Call operator &

& 'C:\()\[[]]\''.ps1'
& "C:\()\[[]]\'.ps1"


パス

C:\()\[]\[]'.ps1

Call operator &

& 'C:\()\[[]]\[[]]''.ps1'
& "C:\()\[[]]\[[]]'.ps1"


パス

C:\()\[]\[]''.ps1

Call operator &

& 'C:\()\[[]]\[[]]''''.ps1'
& "C:\()\[[]]\[[]]''.ps1"

ファイル名にバッククォートを含む場合

パス

C:\()\[]\`.ps1

Call operator &

& 'C:\()\[[]]\````.ps1'
& "C:\()\[[]]\````````.ps1"


パス

C:\()\[]\[]`.ps1

Call operator &

& 'C:\()\[[]]\[[]]````.ps1'
& "C:\()\[[]]\[[]]````````.ps1"


パス

C:\()\[]\[]``.ps1

Call operator &

& 'C:\()\[[]]\[[]]````````.ps1'
& "C:\()\[[]]\[[]]````````````````.ps1"

過去記事

dy100ms.hatenadiary.jp