Home Dashboard Directory Help
Search

SqlPs UNC Path Issue by AustinH12


Status: 

Closed


9
0
Sign in
to vote
Type: Bug
ID: 737324
Opened: 4/17/2012 8:34:09 AM
Access Restriction: Public
1
Workaround(s)
view
6
User(s) can reproduce this bug

Description

After importing the the SqlPs module in PowerShell, I am no longer able to navigate to servers on my network using a UNC path. When I remove the module and restart my powershell, I am then able to once again navigate to servers on my network using a UNC path.
Details
Sign in to post a comment.
Posted by Jason SQL on 9/11/2013 at 1:24 PM
This should not have been closed.

The behavior of the SQLPS module modifies the current path only if the module is not loaded already through a previous Import-Module or an embedded command that auto loads the module. If it is already loaded then Import-Module does not load the module and the path remains the same. Completely opposite behavior that is not deterministic! This occurs even when using embedded module commands, ie Backup-SQLDatabase. The recommended workaround does not resolve that scenario or many others caused by this bug.

No professional developer relies on relative directories so the behavior SQLPS module to force a path change not only breaks UNC resolution, but is completely pointless. Please fix.
Posted by Cody Konior on 5/16/2013 at 10:51 PM
The workaround works but closing it without a proper explanation of why it can't be fixed is inappropriate. Without a proper fix, every function in every module that uses UNC paths now has the responsibility of pushing, checking, and resetting the location:

try {
    Push-Location
    if ((Get-Location) -like "SQLSERVER:*") {
        Set-Location C:
    }
} finally {
    Pop-Location
}

Or just exiting and throwing an error if started from SQLSERVER:. Just to work around this bug alone! It should be fixed properly.
Posted by Microsoft on 2/26/2013 at 10:19 AM
Hello Austin. Based on the current status of workarounds for this issue, we will be marking it as resolved. If anyone finds the workarounds do not function, please post here and we will reactivate the item. -Walter A Jokiel, Program Manager, SQL Server (wajokiel@microsoft.com)
Posted by Randy in Marin on 8/22/2012 at 5:54 PM
Thanks for the workaround. This was driving me buggy.
Posted by PrakashHeda on 5/14/2012 at 12:21 PM
Simplest way to reproduce this issue:

Get-ChildItem "\\servername\c$\" | Select-Object -first 1
Import-Module 'sqlps' -DisableNameChecking
Get-ChildItem "\\servername\c$" | Select-Object -first 1
Posted by PrakashHeda on 5/3/2012 at 11:25 AM
Surprisingly I am facing almost same kind of issue

within powershell I am ble to access UNC path

once start sqlps same path is not accesible

is this some new bug? it was working couple of days ago
Sign in to post a workaround.
Posted by PrakashHeda on 5/14/2012 at 4:36 PM
Found fix to this issue....seems location needs to be anything other than "PS SQLSERVER:\>" to access UNC folders


Get-ChildItem "\\servername\c$\" | Select-Object -first 1
Import-Module 'sqlps' -DisableNameChecking
set-location "c:\" -PassThru
Get-ChildItem "\\servername\c$" | Select-Object -first 1