none
Powershell Scripts Error while executing SQLPS error RRS feed

  • Question

  • please find the error coming while executing powershell scripts,,

    Invoke-Sqlcmd -ServerInstance "Servername" -Username "username" -Password "password" -Query "CREATE DATABASE database name"

    Invoke-Sqlcmd : The 'Invoke-Sqlcmd' command was found in the module 'SQLPS', but the module could not be loaded. For more

    information, run 'Import-Module SQLPS'.

    At line:1 char:1

    + Invoke-Sqlcmd -ServerInstance "WLE1731D" -Username "sa" -Password "Th ...

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

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

        + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

     

    Invoke-Sqlcmd : The 'Invoke-Sqlcmd' command was found in the module 'SQLPS', but the module could not be loaded. For more

    information, run 'Import-Module SQLPS'.

    At line:4 char:1

    + Invoke-Sqlcmd -ServerInstance "WLE1731D" -Username "sa" -Password "Th ...

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

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

        + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

     
    • Moved by Bill_Stewart Thursday, January 25, 2018 10:47 PM Off-topic
    Thursday, November 23, 2017 7:24 AM

All replies

  • You are using the wrong version of SQLPS.

    Find-Module SQLServer | Install-Module

    Import-Module SqlServer


    \_(ツ)_/

    Thursday, November 23, 2017 11:54 AM