2016-06-20 61 views
1

我想在Microsoft Management Studio中執行powershell腳本。 但我得到一個錯誤。看看下面的詳細信息:ms sql powershell

EXEC master..xp_cmdshell '%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted -command "C:\tmp_es\test.ps1"' 

C:\tmp_es\test.ps1 : The term 'C:\tmp_es\test.ps1' 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. 
+0

這可能是因爲SQL進程沒有訪問'C:\ tmp_es'嘗試改變在'tmp_es'權限閱讀所有用戶。 –

+0

我認爲你是對的。但是現在我必須知道SQL管理工作室服務器的名稱是什麼。你可能知道嗎? –

+0

您是在Management Studio的同一臺機器上運行Sql Server還是在遠程服務器上運行? – vonPryz

回答

1

更改-Command-File

EXEC master..xp_cmdshell '%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted -File "C:\tmp_es\test.ps1"' 
+0

這不起作用。我認爲它確實沒有該文件夾的SQL管理工作室的權限。 –