Home Forums Programming Powershell SQLPS takes 30 minutes to import. How to fix it? RE: SQLPS takes 30 minutes to import. How to fix it?

  • SQLPS depends on another module called Microsoft.SqlServer.Management.PSProvider.dll.

    Importing the PSProvider module takes a very long time for me.

    Incidentally, it's the source of the warning about Analysis Services.

    I commented out the problem module in the NestedModules list to stop SQLPS importing it.

    NestedModules = @("Microsoft.SqlServer.Management.PSSnapins.dll"<#,"Microsoft.SqlServer.Management.PSProvider.dll"#>,"SqlPsPostScript.ps1")

    Now SQLPS imports quickly, but generates an error because it can't set the working location to SQLSERVER:.

    $ Import-Module SQLPS

    Set-Location : Cannot find drive. A drive with the name 'SQLSERVER' does not exist.

    At C:\Program Files (x86)\Microsoft SQL

    Server\110\Tools\PowerShell\Modules\SQLPS\SqlPsPostScript.ps1:1 char:1

    + Set-Location SQLSERVER:

    + ~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : ObjectNotFound: (SQLSERVER:String) [Set-Location], D

    riveNotFoundException

    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocat

    ionCommand

    At least Invoke-Sqlcmd is working again, so this is a better situation.

    I would still like to get the SQLSERVER: drive working quickly because I use it to navigate my central management server.

    If I really need the SQLSERVER: drive and have 30 minutes spare, to I can import the provider directly.

    Import-Module "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\SQLPS\Microsoft.SqlServer.Management.PSProvider.dll"

    Does anyone have a solution that doesn't involve hacking the SQLPS module?