Home Dashboard Directory Help
Search

NEWER New-PSDrive loses OLDER 'net use' command. by S.K. _


Status: 

Active


2
0
Sign in
to vote
Type: Bug
ID: 775552
Opened: 1/1/2013 10:31:32 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

see here.

How to Map Network Drives Using PowerShell
http://www.howtogeek.com/132354/how-to-map-network-drives-using-powershell/

>>> net use M: \\touchsmart\Share /Persistent:Yes

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


LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONNGG!!!!!!!!!!!!!!!!!!

** I'm not saying a joke, I have to emphasize, because I want you to seriously resolve. **


If a $PSDefaultParameterValues's bug are fixed, he can win with using 'profile.ps1'.

>>> New-PSDrive K –Root \\touchsmart\share


--------------------------- 'profile.ps1' ---------------------------

$PSDefaultParameterValues['New-PSDrive:PSProvider'] = "FileSystem"

<#
*** following code does not work now ***
*** see here https://connect.microsoft.com/PowerShell/feedback/details/775020/psboundparameters-psdefaultparametervalues-cmdlet-bug ***
#>

$PSDefaultParameterValues['New-PSDrive:Persist'] = {
if("Root" -in $args[0].BoundParameters
    -and $PSBoundParameters["Root"].StartsWith('//')
    -and $PSBoundParameters["PSProvider"] -eq "FileSystem"
) { $true }

}

---------------------------------------------------------------------

Do you say 'You can use a custom function' ?
Please remenber we do not like a custom function which is not valid for others.
Details
Sign in to post a comment.
Sign in to post a workaround.