I am trying to map a drive using New-PSDrive.
I am using the code below. It errors saying “New-PSDrive : The network resource type is not correct”
I think the error is caused by $Script breaking onto a new line mid way through the path. New-PSDrive does not seem to look to the next line. I have tried re-ordering the parameters with no affect.
The code works if I resolve $Script, copy the line into the console and delete the line breaks. Has anyone seen this before / can help? The file path does not include any special characters that should trigger a line break.
$FolderToMap = [LONG NAME INCLUDING SPACES] $Script="New-PSDrive -Persist -Name A -Root `"$FolderToMap`" -PSProvider FileSystem -scope Global" Invoke-Expression $Script