{"id":83786,"date":"2020-06-03T07:42:18","date_gmt":"2020-06-03T05:42:18","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/vozvrat-znacheniya-iz-powershell-invoke-command-agentu-sql-server"},"modified":"2020-06-03T07:42:18","modified_gmt":"2020-06-03T05:42:18","slug":"vozvrat-znacheniya-iz-powershell-invoke-command-agentu-sql-server","status":"publish","type":"post","link":"https:\/\/prohoster.info\/et\/blog\/administrirovanie\/vozvrat-znacheniya-iz-powershell-invoke-command-agentu-sql-server","title":{"rendered":"V\u00e4\u00e4rtuse tagastamine Powershell'i invoke-command'i kaudu SQL-Serveri agentidele","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 MS-SQL \u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 powershell \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0443 \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u043f\u0430\u043c\u044f\u0442\u043a\u0443, \u0430 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"powershell\">$exitcode = $args[0]\nWrite-Host 'Out to host.'\nWrite-Output 'Out to output.'\nWrite-Host ('ExitCode: ' + $exitcode)\nWrite-Output $exitcode\n$host.SetShouldExit($exitcode)<\/code><\/pre>\n<p>\n\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u044f \u0431\u0443\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c CMD-\u0444\u0430\u0439\u043b\u043e\u043c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0435\u0433\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043d\u0443:<\/p>\n<pre><code class=\"dos\">@Echo OFF\nPowerShell .TestOutput1.ps1 1\nECHO ERRORLEVEL=%ERRORLEVEL%<\/code><\/pre>\n<p>\n\u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"plaintext\">Out to host.\nOut to output.\nExitCode: 1\n1\nERRORLEVEL=1<\/code><\/pre>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\n\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u043e\u0442 \u0436\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0447\u0435\u0440\u0435\u0437 WSMAN (\u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e):<\/p>\n<pre><code class=\"powershell\">Invoke-Command -ComputerName . -ScriptBlock { &amp;'D:sqlagentTestOutput1.ps1' $args[0] } -ArgumentList $args[0]<\/code><\/pre>\n<p>\n\u0418 \u0432\u043e\u0442 \u0432\u0430\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"plaintext\">Out to host.\nOut to output.\nExitCode: 2\n2\nERRORLEVEL=0<\/code><\/pre>\n<p>\n\u0427\u0443\u0434\u0435\u0441\u043d\u043e, Errorlevel \u043a\u0443\u0434\u0430-\u0442\u043e \u043f\u0440\u043e\u043f\u0430\u043b, \u043d\u043e \u043d\u0430\u043c \u0432\u0435\u0434\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u043a\u0440\u0438\u043f\u0442\u0430! \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"powershell\">$res=Invoke-Command -ComputerName . -ScriptBlock { &amp;'D:sqlagentTestOutput1.ps1' $args[0] } -ArgumentList $args[0]<\/code><\/pre>\n<p>\n\u0422\u0443\u0442 \u0435\u0449\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435. \u0412\u0435\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0432 Output \u043a\u0443\u0434\u0430-\u0442\u043e \u0438\u0441\u0447\u0435\u0437:<\/p>\n<pre><code class=\"plaintext\">Out to host.\nExitCode: 2\nERRORLEVEL=0<\/code><\/pre>\n<p>\n\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043b\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Powershell \u0412\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u0442\u0435 Write-Output \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u0435\u0433\u043e \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 (\u0430 \u044d\u0442\u043e \u043d\u0435\u044f\u0432\u043d\u043e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u0430\u043d\u0430\u043b Output), \u0442\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e! \u042d\u0442\u043e \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b powershell \u2014 \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 Output, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432, \u0438 \u0432\u0441\u0435, \u0447\u0442\u043e \u0432 \u043d\u0435\u0433\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442, \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 Return \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u044d\u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0432\u044b\u0437\u0432\u0430\u0432\u0448\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0414\u043b\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre><code class=\"powershell\">Function Write-Log {\n  Param( [Parameter(Mandatory=$false, ValueFromPipeline=$true)] [String[]] $OutString = &quot;`r`n&quot; )\n  Write-Output (&quot;Function: &quot;+$OutString)\n  Return &quot;ReturnValue&quot;\n}\nWrite-Output (&quot;Main: &quot;+&quot;ParameterValue&quot;)\n$res = Write-Log &quot;ParameterValue&quot;\n$res.GetType()\n$res.Length\n$res | Foreach-Object { Write-Host (&quot;Main: &quot;+$_) }\n<\/code><\/pre>\n<p>\n\u0418 \u0432\u043e\u0442 \u0435\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"plaintext\">Main: ParameterValue\n\nIsPublic IsSerial Name                                     BaseType\n-------- -------- ----                                     --------\nTrue     True     Object[]                                 System.Array\n2\nMain: Function: ParameterValue\nMain: ReturnValue<\/code><\/pre>\n<p>\n\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f (\u0442\u0435\u043b\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430) \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 Output, \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438\u0437 CMD, \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0432 \u0432\u044b\u0432\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b, <\/p>\n<pre><code class=\"dos\">PowerShell .TestOutput1.ps1 1 &gt; TestOutput1.txt\n<\/code><\/pre>\n<p>\n\u0442\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c <\/p>\n<pre><code class=\"plaintext\">ERRORLEVEL=1<\/code><\/pre>\n<p>\n\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 <\/p>\n<pre><code class=\"plaintext\">Out to host.\nOut to output.\nExitCode: 1\n1\n<\/code><\/pre>\n<p>\n\u0435\u0441\u043b\u0438 \u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0438\u0437 powershell <\/p>\n<pre><code class=\"powershell\">PS D:sqlagent&gt; .TestOutput1.ps1 1 &gt; TestOutput1.txt<\/code><\/pre>\n<p>\u0442\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 <\/p>\n<pre><code class=\"plaintext\">Out to host.\nExitCode: 1<\/code><\/pre>\n<p>\n\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 <\/p>\n<pre><code class=\"plaintext\">Out to output.\n1<\/code><\/pre>\n<p>\n\u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e CMD \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 powershell, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 (Host \u0438 Output) \u0438 \u043e\u0442\u0434\u0430\u0435\u0442 \u0438\u0445 CMD, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u0444\u0430\u0439\u043b \u0432\u0441\u0435, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0437 powershell \u044d\u0442\u0438 \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0438 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043b\u0438\u044f\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 Output.<\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u0435, \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c .NET \u0432\u043d\u0443\u0442\u0440\u0438 powershell \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 (\u043e\u0434\u043d\u043e\u0439 \u041e\u0421), \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043a\u043e\u0434\u0430 \u0447\u0435\u0440\u0435\u0437 WSMAN \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 XML-\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u0432\u043d\u043e\u0441\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u0432 \u043d\u0430\u0448\u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"powershell\">$res=Invoke-Command -ComputerName . -ScriptBlock { &amp;'D:sqlagentTestOutput1.ps1' $args[0] } -ArgumentList $args[0]\n$res.GetType()\n$host.SetShouldExit($res)\n<\/code><\/pre>\n<p>\n\u0418 \u0432\u043e\u0442 \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435:<\/p>\n<pre><code class=\"plaintext\">Out to host.\n\nExitCode: 3\n\nIsPublic IsSerial Name                                     BaseType\n-------- -------- ----                                     --------\nTrue     True     Object[]                                 System.Array\n\u041d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 &quot;exitCode&quot;, \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c: &quot;System.Object[]&quot;, \u0434\u043b\u044f &quot;SetShouldExit&quot; \u0432 \u0442\u0438\u043f &quot;System.Int32&quot;: &quot;\u041d\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &quot;System.Object[]&quot; \u0442\u0438\u043f\u0430 &quot;System.Object[]&quot; \u0432 \u0442\u0438\u043f &quot;System\n.Int32&quot;.&quot;\nD:sqlagentTestOutput3.ps1:3 \u0437\u043d\u0430\u043a:1\n+ $host.SetShouldExit($res)\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~\n    + CategoryInfo          : NotSpecified: (:) [], MethodException\n    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument\n\nERRORLEVEL=0<\/code><\/pre>\n<p>\n\u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442! \u041e\u043d \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 Invoke-Command \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u043e\u0432 \u043d\u0430 \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 (Host \u0438 Output), \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u043d\u0430\u0434\u0435\u0436\u0434\u0443 \u043d\u0430 \u0443\u0441\u043f\u0435\u0445. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 Output \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e:<\/p>\n<pre><code class=\"powershell\">$exitcode = $args[0]\nWrite-Host 'Out to host.'\n#Write-Output 'Out to output.'\nWrite-Host ('ExitCode: ' + $exitcode)\nWrite-Output $exitcode\n$host.SetShouldExit($exitcode)\n<\/code><\/pre>\n<p>\n\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"powershell\">$res=Invoke-Command -ComputerName . -ScriptBlock { &amp;'D:sqlagentTestOutput1.ps1' $args[0] } -ArgumentList $args[0]\n$host.SetShouldExit($res)\n<\/code><\/pre>\n<p>\n\u0438\u2026 \u0414\u0410, \u043f\u043e\u0445\u043e\u0436\u0435, \u044d\u0442\u043e \u043f\u043e\u0431\u0435\u0434\u0430!<\/p>\n<pre><code class=\"plaintext\">Out to host.\nExitCode: 4\n\nIsPublic IsSerial Name                                     BaseType\n-------- -------- ----                                     --------\nTrue     True     Int32                                    System.ValueType\n\n\nERRORLEVEL=4<\/code><\/pre>\n<p>\n\u041f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e. \u041c\u044b \u0432\u044b\u0437\u0432\u0430\u043b\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e powershell, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u044b\u0437\u0432\u0430\u043b powershell \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b \u0442\u0430\u043c \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442. \u0414\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 (Host \u0438 Output) \u0441 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0431\u044b\u043b\u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0442\u043e\u043a Output \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0432 \u043d\u0435\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u043b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u043a \u0442\u0438\u043f\u0443 Int32 \u0438 \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u0434\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e powershell-\u0430.<\/p>\n<p>\u0418 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430 <a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/server\/dts-dronten\"   title=\"\u0441\u0435\u0440\u0432\u0435\u0440\u0435\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"2590\">\u0441\u0435\u0440\u0432\u0435\u0440\u0435<\/a> SQL \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0448\u0430\u0433\u0430 \u0441 \u0442\u0438\u043f\u043e\u043c \u00ab\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 (cmdexec)\u00bb \u0441 \u0442\u0430\u043a\u0438\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c:<\/p>\n<pre><code class=\"dos\">PowerShell -NonInteractive -NoProfile &quot;$res=Invoke-Command -ComputerName BACKUPSERVER -ConfigurationName SQLAgent -ScriptBlock {&amp;'D:sqlagentTestOutput1.ps1' 6}; $host.SetShouldExit($res)&quot;<\/code><\/pre>\n<p>\n\u0423\u0420\u0410! \u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u043e\u0441\u044c \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0442\u0435\u043a\u0441\u0442 \u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0435:<\/p>\n<pre><code class=\"plaintext\">\u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f: DOMAINagentuser. Out to host. ExitCode: 6.  \u041a\u043e\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 6.  \u0428\u0430\u0433 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439.\n<\/code><\/pre>\n<p>\n<b>\u0412\u044b\u0432\u043e\u0434\u044b:<\/b><\/p>\n<ul>\n<li>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Write-Output \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u0435\u0437 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c.<\/li>\n<li>\u0412 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u043d\u0435 \u0434\u043b\u044f \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0430 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0412\u0430\u0448\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u0445 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 WINRM, \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0440\u0443\u0447\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043e\u043a \u0447\u0435\u0440\u0435\u0437 Try\/Catch, \u0438 \u0434\u043e\u0431\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043b\u044e\u0431\u043e\u043c \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u0432 \u043f\u043e\u0442\u043e\u043a Output \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 Errorlevel \u2014 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c.<\/li>\n<\/ul>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/504890\/\">habr.com<\/a> <\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 MS-SQL \u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 powershell \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0443 \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u043f\u0430\u043c\u044f\u0442\u043a\u0443, \u0430 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0418\u0442\u0430\u043a, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e: $exitcode = $args[0] Write-Host &#8216;Out to host.&#8217; Write-Output &#8216;Out to [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-83786","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 MS-SQL \u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 powershell \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0443 \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u043f\u0430\u043c\u044f\u0442\u043a\u0443, \u0430 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0418\u0442\u0430\u043a, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e: $exitcode = $args[0] Write-Host &#039;Out to host.&#039; Write-Output &#039;Out to\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/et\/blog\/administrirovanie\/vozvrat-znacheniya-iz-powershell-invoke-command-agentu-sql-server\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"et_EE\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 powershell invoke-command \u0430\u0433\u0435\u043d\u0442\u0443 SQL-Server | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 MS-SQL \u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 powershell \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0443 \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u043f\u0430\u043c\u044f\u0442\u043a\u0443, \u0430 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0418\u0442\u0430\u043a, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e: $exitcode = $args[0] Write-Host &#039;Out to host.&#039; Write-Output &#039;Out to\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/et\/blog\/administrirovanie\/vozvrat-znacheniya-iz-powershell-invoke-command-agentu-sql-server\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-06-03T05:42:18+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-06-03T05:42:18+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47V\u00e4\u00e4rtuse tagastamine powershell invoke-command kaudu SQL-Serveri agendile | ProHoster","description":"\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 MS-SQL \u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 powershell \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0443 \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u043f\u0430\u043c\u044f\u0442\u043a\u0443, \u0430 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0418\u0442\u0430\u043a, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e: $exitcode = $args[0] Write-Host 'Out to host.' Write-Output 'Out to","canonical_url":"https:\/\/prohoster.info\/et\/blog\/administrirovanie\/vozvrat-znacheniya-iz-powershell-invoke-command-agentu-sql-server","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"et_EE","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 powershell invoke-command \u0430\u0433\u0435\u043d\u0442\u0443 SQL-Server | ProHoster","og:description":"\u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043f\u0438\u044f\u043c\u0438 \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 MS-SQL \u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 powershell \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0438\u0448\u0443 \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u043f\u0430\u043c\u044f\u0442\u043a\u0443, \u0430 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u0435\u0449\u0435 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0418\u0442\u0430\u043a, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e: $exitcode = $args[0] Write-Host 'Out to host.' Write-Output 'Out to","og:url":"https:\/\/prohoster.info\/et\/blog\/administrirovanie\/vozvrat-znacheniya-iz-powershell-invoke-command-agentu-sql-server","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-06-03T05:42:18+00:00","article:modified_time":"2020-06-03T05:42:18+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"83786","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 15:11:01","updated":"2026-02-09 21:38:02"},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/posts\/83786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/comments?post=83786"}],"version-history":[{"count":1,"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/posts\/83786\/revisions"}],"predecessor-version":[{"id":159872,"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/posts\/83786\/revisions\/159872"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/media?parent=83786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/categories?post=83786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/et\/wp-json\/wp\/v2\/tags?post=83786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}