Run POwershell script in Store Proc

  • hi Friends,

    I was wondering if anyone of you have come across situation to run a powershell Script with parameter Store Proc. I'm able to run a powershell Script using below command but i need to run powershell with input parameter.

    Working Fine:

    EXEC xp_cmdshell 'powershell -Command D:\Temp\Get-Service.ps1'

    Failing and Need Help:

    EXEC xp_cmdshell 'powershell -Command "MyServerName" | "D:\Temp\StopSDOpsService.ps1"'

  • Really sorry for the churn. I found the double quotes to be the culprit in my command.

    Failing Command

    EXEC xp_cmdshell 'powershell -Command "MyServerName" | D:\Temp\StopSDOpsService.ps1'

    Working Fine:

    EXEC xp_cmdshell 'powershell -Command D:\Temp\StopSDOpsService.ps1 MyServerName'

Viewing 2 posts - 1 through 1 (of 1 total)

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