Getting the error - Add-PSSnapin. added snapin "add-pssnapin SqlServerCmdletSnapin100;" still no luck

  • Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version

    2.

    At line:1 char:13

    + add-pssnapin <<<< SqlServerCmdletSnapin100;

    + CategoryInfo : InvalidArgument: (SqlServerCmdletSnapin100:Strin

    g) [Add-PSSnapin], PSArgumentException

    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad

    dPSSnapinCommand

    Thanks.

  • Please could you add the command that you are attempting to execute along with the output.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Thanks for your response.

    My query is:

    $instanceNameList = Get-Content "C:\Powershell\serverlist.txt"

    $results = @()

    foreach($instanceName in $instanceNameList)

    {

    $results += Invoke-Sqlcmd `

    -Query "select SERVERPROPERTY('ServerName') as Server, count(*) as 'DB Count' from sys.databases" `

    -ServerInstance $instanceName

    }

    # print results

    $results | Format-Table -autosize

    Also, I have the below environment path setup in my system:

    %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules

    Error Message:

    The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    At line:6 char:34

    + $results += Invoke-Sqlcmd <<<< `

    + CategoryInfo : ObjectNotFound: (Invoke-Sqlcmd:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

    Thanks.

  • For earlier versions of PowerShell you needed to manually add snap-ins. There is the SQL Server PowerShell command line where you don't have to (memory fails me what it is called - if I remember I'll post again).

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Doh!!!

    SQLPS

    See here.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply