不知道什么原因,在有些系統上打開PowerShell命令行窗口后,光標無法顯示。這種情況在Windows Server 2008/2012、Windows 8/9/10上都出現過,估計是由於某些系統軟件/組件的兼容性問題導致的。
遇到這種情況,通過修改PowerShell命令行窗口的背景顏色可以使光標正常顯示,但關閉PowerShell窗口后重新打開,問題依然存在。
最終的解決辦法是:通過在PowerShell profile中添加設置來確保光標能夠正常顯示。
創建PowerShell profile
new-item -path $profile -itemtype file -force
打開PowerShell profile
notepad $profile
執行上述命令后,會打開一個新的notepad窗口,在notepad輸入:
[console]::cursorsize=25
保存並關閉notepad
關閉並重新打開PowerShell窗口,光標就可以正常顯示了,一勞永逸。