PowerShell逃脫字元問題 - Windows

Olivia avatar
By Olivia
at 2020-10-27T19:53

Table of Contents

作業系統: Windows 10

Service Pack: 20H2

發生問題頻率: 100%

是否有做Windows Update: 有

問題內容:

據我所知Powershell中要表示
字元` = '``' = "````"
字元' = '''' = "`'"
字元[ = '`[' = "``["
字元] = '`]' = "``]"

依此類推...

# D:\`[test`]'`
test-path 'D:\```[test```]''``'
test-path "D:\``````[test``````]`'````"

# E:\`[test`]'``
test-path 'E:\```[test```]''````'
test-path "E:\``````[test``````]`'````````"

以上皆如預期回傳 True

# D:\`[test`]'`
test-path 'D:\```[test```]''`'
test-path "D:\``````[test``````]`'``"

# E:\`[test`]'``
test-path 'E:\```[test```]''```'
test-path "E:\``````[test``````]`'``````"

上面這些怎麼也全都回傳 True?
單引號內右側少了1個`
雙引號內右側少了2個`

想了一下...
看起來'`'或"``"右側沒有跟其他特殊字元相鄰時等同'``'或"````"
所以test-path中 '`' = '``' = "````" = "``````" = "````````"
怎麼會有這麼奇怪的行為? 還是我哪裡誤會了?

--
Tags: Windows

All Comments

Andrew avatar
By Andrew
at 2020-10-28T03:25
遇到引號建議使用 Test-Path -LiteralPath

outlook收到出現國外陌生郵件

Hedda avatar
By Hedda
at 2020-10-26T11:07
最近outlook 帳號 出現問題 9月微軟帳號有異常登入問題 10月開始outlook信箱收到國外陌生郵件 不只一封...重點收件者不是我 信還進的來 擔心帳戶問題也不想一直收到陌生信 請問這個問題可以問微軟嘛 他們說帳戶要寫信問 但是微軟有客服信箱嘛 陌生郵件截圖如下 https://i.imgur ...

PCman使用wss安全連線的問題

Andy avatar
By Andy
at 2020-10-25T16:11
作業系統:windows 10 1809 17763.1490 Service Pack:1809 發生問題頻率:不定時 是否有做Windows Update:有 問題內容: 前陣子終於下定決心把1231 v3的PC從windows7換成windows10 這半年多來在win7使用pcman lit ...

Windows 10 1809版本更新問題

Dorothy avatar
By Dorothy
at 2020-10-25T15:13
作業系統:Windows 10 Service Pack:1809(17663.737) 發生問題頻率:無 是否有做Windows Update:無 問題內容: 目前版本是1809 未來會換Ryzen 5 3600 因此想要更新Windwos版本 但是目前是否無法指定更新到1909 因為我跑內建更 ...

如何複製資料夾中所有影片的時間長度

Andy avatar
By Andy
at 2020-10-24T16:53
最近被吩咐整理影片資料 要將影片的檔名還有長度整理成excel 在網路上查到可以用dir指令列出資料夾中影片的檔名 也有成功列出來複製到excel上 不過時間長度這個卻不知道怎麼抓出來 一條一條手key真的會瘋掉 求鄉民解惑 系統是win7 檔案都是mp4 - ...

Surface Duo特價開始

Tristan Cohan avatar
By Tristan Cohan
at 2020-10-24T02:06
https://www.windowscentral.com/node/81317 Best Buy 合約機$1099起 空機$1199起 https://www.windowscentral.com/node/81308 微軟商店 空機$1199起 特價到10/29(美國時間)為止 -- 建議如果有 ...