So to map the network share \\VBoxSvr\Win11 and assign it the drive letter v: we can use the following command: New-PSDrive -Name V -PSProvider FileSystem -Root \\VBoxSvr\Win11 -Persist New-PSDrive network mapping To make it available outside PowerShell (in Explorer) The network location that you want to map Set to FileSystem for network shares and folders There are a couple of required parameters to create a network connection: Parameter This way the network drive will be available in Explorer and other tools and not only in PowerShell. To map a network drive with PowerShell, we are going to create a persistent network connection. Adding a new network drive with New-PSDrive They will remain available when you close the PowerShell session or even reboot your computer. Persistent drives are assigned a drive letter and therefore can also be used in Explorer. They are great to use when you need to interact with a remote folder or a long folder path on your local computer. They won’t be visible in Windows Explorer and will be gone when you close the PowerShell session. Temporary drives can only be used in the current PowerShell session. Temporary vs Persistent drivesīefore we are going to take a look at how to create the network drives, I first want to explain the difference between temporary and persistent drives. In this article, we are going to take a closer look at all the possibilities of the New-PSDrive cmdlet with some useful examples for you to use. Drives created with the cmdlet can be temporary for only the current PowerShell sessions or persistent so they can be used in explorer. With the New-PSDrive cmdlet, we cannot only map network drives but also create drive mappings to local folders or registry keys on our computer. Although we can use Net Use in PowerShell, there is a more powerful alternative, the New-PSDrive cmdlet. We all know the Net Use command that we can use to map network drives from the command line.
0 Comments
Leave a Reply. |