Powershell (SQL Server 2008 R2)

This topic contains 1 reply, has 2 voices, and was last updated by  postanote 4 weeks ago.

  • Author
    Posts
  • #101163

    Mitchell
    Participant

    I am trying to create a SQL Server agent job that will run powershell commands in SQL Server 2008 R2. I keep getting errors. A lot of powershell commands it does not recognize (i.e. Import-module, Get-module, Invoke-cmd, etc). This is the error message I get "The term 'get-module' is not recognized as the name of a cmdlet, function, script file, or operable program." It works fine in the powershell ISE console. Any ideas on my problem?

  • #101167

    postanote
    Participant

    These are all base cmdlets in PoSH (Host / ISE / VSCode).
    If you are not able to run them, then you are not in a PoSH environment.

    See if the below gets you to where you need to be.

    Run Windows PowerShell Steps in SQL Server Agent
    https://docs.microsoft.com/en-us/sql/powershell/run-windows-powershell-steps-in-sql-server-agent?view=sql-server-2017

    Running PowerShell in a SQL Agent Job

You must be logged in to reply to this topic.