Questions tagged [new-psdrive]

A PowerShell cmdlet for defining custom drives, which typically map to filesystem locations.

From the docs:

The New-PSDrive cmdlet creates temporary and persistent drives that are mapped to or associated with a location in a data store, such as a network drive, a directory on the local computer, or a registry key, and persistent Windows mapped network drives that are associated with a file system location on a remote computer.

Only persistent drive definitions (-Persist), which are only supported on Windows, are visible to programs outside of PowerShell.

14 questions
8
votes
1 answer

Cannot add "-persist" to New-PSDrive - getting error "network resource type is not correct"

As the title says, if I try to add -persist to the cmdlt, it returns an error: New-PSDrive : The network resource type is not correct At line:1 char:1 + New-PSDrive -Name P -Root ... +…
4
votes
1 answer

How to access a PSDrive from System.IO.File calls?

I'm writing a c# cmdlet which copies files from one location to another (similar to rsync). It even supports ToSession and FromSession. I'd like it to work with PSDrives that use the Filesystem provider but it currently throws an error from…
silicontrip
  • 567
  • 4
  • 18
2
votes
2 answers

What type of object is $: (such as `$code:`) in Powershell?

I was using tab autocompletion for a variable name in Powershell 5.1 today and noticed that one of the choices was the name of a PSDrive. The drive name is docs and I wanted to expand is called $document_name. When I typed $do, the shell did…
chris
  • 489
  • 4
  • 11
0
votes
1 answer

How to use -Path in New-PSDrive : Powershell network drives

I've been reading though a lot of different posts describing how to access a network drive in Powershell, and the majority of them suggest using New-PSDrive, and then include some formatting usually looking somewhat like New-PSDrive -Name K…
0
votes
1 answer

Check if PowerShell Drive has been set with if else statement

I'm trying to make a PowerShell script to modify the Registry values that set the default application for the .ps1 file extension. Sadly I wasn't able to get very far with the script because the PSDrive didn't have a path for HKEY_CLASSES_ROOT…
willowen100
  • 11
  • 1
  • 3
0
votes
0 answers

New-PSDrive: A parameter cannot be found that matches parameter name 'Persist'

How do I create a persistent PSDrive on Linux? PS /home/nicholas> PS /home/nicholas> Get-PSDrive Name Used (GB) Free (GB) Provider Root …
0
votes
0 answers

How I can create own driver for variables in powershell

I whant to create driver for own variables in own scope. For example $myown:name = value I tried to do that with different values for -Root: New-PSDrive -Name myown -PSProvider Variable -Root /myown/ But that driver works like variable:. compare…
groser
  • 215
  • 1
  • 8
0
votes
0 answers

Set a Mount as Admin for local users

I try to add Network mount in a Script. in the First part of the Script a VPN Network and the Server Credentials been set. Then i would like to mount automatic a few Folders on the Server to the WIndows Explorer. Because of the ExecutionPolicy od…
0
votes
0 answers

Is it possible to use Compress-Archive using a PSDrive in the -Path and -DestinationPath?

I am using a PSDrive for Compress-Archive but I come across this error: Compress-Archive : The path 'Z:\' either does not exist or is not a valid file system path. At C:\Users\user\somefolder\script.ps1:34 char:5 + Compress-Archive -Path…
japespszx
  • 23
  • 5
0
votes
1 answer

"Invalid directory on URL" while trying to use path created using New-PSDrive in Powershell

I have written a function to get authentication token. I have used New-PSDrive because PathTooLongException was thrown. Write-Host $adal, (Test-Path $adal) returns True while testing if path exists. But throws exception in LoadFrom(). Could someone…
Shridhar R Kulkarni
  • 4,794
  • 2
  • 27
  • 49
0
votes
2 answers

Create a virtual drive with PowerShell

I'm trying to create a D: drive in Windows, which points to some local directory (e.g. C:\DDrive) using PowerShell. This code runs fine: New-PSDrive -Name D -Root "C:\D_Drive\" -PSProvider "FileSystem" But in the Windows Explorer no D:-drive is…
Boris
  • 7,424
  • 21
  • 59
  • 105
0
votes
1 answer

Could not map network drive error after rebooting

I have two powershell scripts in each of which I need to write some information into a log file. The log file is stored on a network share. In the first script everything works as it should, the information is written to a file. After that, the…
-1
votes
1 answer

PowerShell mapped network drives not persisting after reboot

The command I'm running to map a network drive is: New-PSDrive -Name "M" -PsProvider "FileSystem" -Root "\\domain.com\filepath" -Persist -Scope Global -Credential $userCredentials The command maps the drive and the connection persists after closing…
-2
votes
2 answers

New-PSDrive drive mapping name

In my powershell script i am using New-PSDrive function to map remote server file path into my local computer as windows deployment operation proccess. I plan to reuse this Powershell script in the future, so i dont want any conflict between drives…
metzelder
  • 504
  • 1
  • 11
  • 32