r/PowerShell • u/sundry_outlook • Apr 21 '26
PSDrive
Hi..
I have created a new PSDrive having name `S:`.
new-psdrive -name S -psprovider filesystem -root c:\users\username\dir
one running command `get-content` works fine, but `vim` is opening a blank file.
get-content S:\test.txt # works fine
vim S:\test.txt # opens a blank file
8
Upvotes
6
u/purplemonkeymad Apr 21 '26
A PSdrive is a powershell construct, so programs can't see them. I think you probably actually wanted to use new-smbmapping instead.
2
u/Neyxos Apr 21 '26
try with -Persist or -Scope
https://learn.microsoft.com/fr-fr/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-7.6#-persist
2
u/jimb2 Apr 21 '26
You can create a wrapper function for vim that checks for a PSDrive in the command parameter and replaces it if found.
I have a little NPP function in my profile that does this with notepad++
PSDdrives are in PowerShell, not in the OS.
3
u/Electrical-Lab-9593 Apr 21 '26
You can use the subst command for this its a bit old school but works like a mapped drive without needing SMB.
1
u/Over_Dingo Apr 21 '26
New-PSDrive -Scope:Global