Windows PowerShell 驅動器可以使許多任務變得更簡單。 例如,Windows 註冊表中的某些最重要的項的路徑長度非常長,難以訪問且難以記住這些路徑。 關鍵的配置信息位於 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion。 若要查看和更改 CurrentVersion 註冊表項中的項,你可以創建一個其根在該項中的 Windows PowerShell 驅動器,方法是鍵入:
New-PSDrive -Name cvkey -PSProvider Registry -Root HKLM\Software\Microsoft\Windows\CurrentVersion
# 輸出結果如下
'''
Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
cvkey Registry HKLM\Software\Microsoft\Windows\...
'''
# 然後,你可以像對任何其他驅動器一樣,將位置更改爲 cvkey: 驅動器:
cd cvkey:
或者:
Set-Location cvkey: –PassThru
New-PsDrive cmdlet 僅將新的驅動器添加到當前 Windows PowerShell 會話中。 如果關閉 Windows PowerShell 窗口,則會丟失新的驅動器。 若要保存 Windows PowerShell 驅動器,請使用 Export-Console cmdlet 導出當前 Windows PowerShell 會話,然後使用 PowerShell.exe PSConsoleFile 參數來將其導入。 或者,將新的驅動器添加到 Windows PowerShell 配置文件中。
更多資訊您也可以關注