surendra
surendra

Reputation: 611

while mounting the network drive with persist option getting an error

i am trying to mount the New-PSDrive using powershell using the below command

New-PSDrive –Name “K” –PSProvider FileSystem –Root “\\touchsmart\share” –Persist

but i got an error

New-PSDrive : The network resource type is not correct
At line:1 char:1
+ New-PSDrive –Name “K” –PSProvider FileSystem –Root “\\touchsmart\shar ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (K:PSDriveInfo) [New-PSDrive], 
Win32Exception
+ FullyQualifiedErrorId : 
CouldNotMapNetworkDrive,Microsoft.PowerShell.Commands.NewPSDriveCommand

without -Persist option its is working fine. how to execute persistent network drive. any help.

Upvotes: 0

Views: 2341

Answers (2)

Theo
Theo

Reputation: 61188

Not only the quotes are of type 'smart-quote', but also the minus dashes are not really minus signs.

New-PSDrive -Name "K" -PSProvider FileSystem -Root "\\touchsmart\share" -Persist

should do it.

I always keep a function handy in my Profile, so from within the Powershell ISE editor I can simply get rid of all these characters and replace them with 'normal' ones:

function Convert-SmartQuotes() {
    Param(
        [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
        [string] $Text
    )
    return $Text -creplace '[\u201C\u201D\u201E\u201F\u2033\u2036]', '"' `
                 -creplace "[\u2018\u2019\u201A\u201B\u2032\u2035]", "'" `
                 -creplace "[\u2013\u2014\u2015]", "-"
}

Upvotes: 2

Ranadip Dutta
Ranadip Dutta

Reputation: 9173

The issue is because of the double quotes that you are using. You might have copied it from some website and when it reflected in PS_ISE; it changed .

Instead of this:

New-PSDrive –Name “K” –PSProvider FileSystem –Root “\\touchsmart\share” –Persist

Do this:

New-PSDrive –Name "K" –PSProvider FileSystem –Root "\\touchsmart\share" –Persist

Hope it helps.

Upvotes: 0

Related Questions