|
|
|
|
|
by jasomill
871 days ago
|
|
PowerShell's ~ can be counterintuitive, as it's relative to the current location's path and defined by a property of the current location's PSProvider: PS C:\> Get-PSDrive C,S,HKLM | select Name,{$_.Provider.Name},{$_.Provider.Home}
Name $_.Provider.Name $_.Provider.Home
---- ---------------- ----------------
C FileSystem C:\Users\jtm
S FileSystem C:\Users\jtm
HKLM Registry
PS C:\Users\jtm> Get-PSDrive C,S,HKCU,HKLM | select Name,{$_.Provider.Name},{$_.Provider.Home}
Name $_.Provider.Name $_.Provider.Home
---- ---------------- ----------------
C FileSystem C:\Users\jtm
S FileSystem C:\Users\jtm
HKCU Registry
HKLM Registry
PS C:\Users\jtm> cd HKLM:
PS HKLM:\> cd ~
Set-Location: Home location for this provider is not set. To set the home location, call "(get-psprovider 'Registry').Home = 'path'".
PS HKLM:\> (Get-Location).Provider.Home = 'C:\Program Files\Microsoft Office'
PS HKLM:\> cd ~
PS C:\Program Files\Microsoft Office> (Get-Location).Provider.Home = 'HKLM:\SYSTEM\CurrentControlSet'
PS C:\Program Files\Microsoft Office> cd S:
PS S:\> cd ~
PS HKLM:\SYSTEM\CurrentControlSet> (Get-Location).Provider.Home = '..'
PS HKLM:\SYSTEM\CurrentControlSet> cd ~
PS HKLM:\SYSTEM> cd ~
PS HKLM:\> Get-PSDrive C,S,HKCU,HKLM | select Name,{$_.Provider.Name},{$_.Provider.Home}
Name $_.Provider.Name $_.Provider.Home
---- ---------------- ----------------
C FileSystem HKLM:\SYSTEM\CurrentControlSet
S FileSystem HKLM:\SYSTEM\CurrentControlSet
HKCU Registry ..
HKLM Registry ..
PS HKLM:\>
|
|