{"id":1252,"date":"2010-11-02T13:37:32","date_gmt":"2010-11-02T04:37:32","guid":{"rendered":"http:\/\/livedevil.net\/?p=1252"},"modified":"2010-11-02T13:37:32","modified_gmt":"2010-11-02T04:37:32","slug":"powershell-invoke-batchcommand","status":"publish","type":"post","link":"https:\/\/talsu.net\/?p=1252","title":{"rendered":"Powershell &#8211; Invoke-BatchCommand"},"content":{"rendered":"<p>\uc77c\ubc18 cmd \uc5d0\uc11c \uc798 \uc218\ud589\ub418\ub358 \uba85\ub839\uc774 Powershell \uc5d0\uc11c \ub611\uac19\uc774 \uc785\ub825 \ud588\uc744 \ub54c \uc624\ub958\uac00 \ub098\ub294 \uacbd\uc6b0\uac00 \uc788\ub2e4. \ub300\ubd80\ubd84 \ud2b9\uc218\ubb38\uc790\uac00 \uc788\uc744\ub54c Powershell\uc774 \ud2b9\uc218 \ubb38\uc790\ub97c \ud2b9\uc815 \uc5f0\uc0b0\uc790\ub85c \uc778\uc2dd\ud558\uba74\uc11c \uc758\ub3c4\ud558\uc9c0 \uc54a\uc740 \ub3d9\uc791\uc774 \uc77c\uc5b4\ub098\ub294 \uacbd\uc6b0 \uc774\ub2e4.<br \/>\n\uc608\ub97c \ub4e4\uc5b4 svn Dump file\uc744 load\ud558\ub294 \uacbd\uc6b0 \ub2e4\uc74c\uacfc \uac19\uc740 \uba85\ub839\uc744 \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n<pre class=\"lang:default nums:false decode:true\">\nsvnadmin load C:svntest < .test.Dump\n<\/pre>\n<p>cmd \uc5d0\uc11c\ub294 \uc798 \uc2e4\ud589\ub418\uc9c0\ub9cc Powershell \uc5d0\uc11c\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 Error\uac00 \ub0a0 \uac83\uc774\ub2e4.<\/p>\n<blockquote><p><span style=\"color: #ff0000;\">'<' \uc5f0\uc0b0\uc790\ub294 \ub098\uc911\uc5d0 \uc0ac\uc6a9\ud558\ub3c4\ub85d \uc608\uc57d\ub418\uc5b4 \uc788\uc2b5\ub2c8\ub2e4.\n\uc704\uce58 \uc904:1 \ubb38\uc790:21\n+ svnadmin load test < <<<<  .test.Dump\n    + CategoryInfo          : ParserError: (<:OperatorToken) [], ParentContainsErrorRecordException\n    + FullyQualifiedErrorId : RedirectionNotSupported\n<\/span><\/p><\/blockquote>\n<p>\ubb38\uc81c\ub97c \ud574\uacb0 \ud558\uae30 \uc704\ud574\uc11c\ub294 Error \ub97c \ubc1c\uc0dd\uc2dc\ud0a8 \uc5f0\uc0b0\uc790\ub97c Powershell\uc774 \uc62c\ubc14\ub974\uac8c \uc0ac\uc6a9 \ud560 \uc218 \uc788\ub3c4\ub85d \uc218\uc815 \ud574 \uc918\uc57c \ud558\ub294\ub370, \ubc88\uac70\ub86d\uace0 \uc815\ud655\ud788 \ud30c\uc545 \ud558\uc9c0 \ubabb\ud588\uc744\ub54c\uc5d0\ub294 \uadc0\ucc2e\uc740 \uc791\uc5c5\uc774 \ub41c\ub2e4.<\/p>\n<p>\uc774\ub7f4 \ub54c \uc0ac\uc6a9\ud560 \uba85\ub839\uc744 \uc2e4\uc81c cmd\ub85c \uc2e4\ud589 \uc2dc\ud0a4\ub294 Invoke-BatchCommand \ub77c\ub294 Function\uc744 \ub9cc\ub4e4\uc5b4 \uc4f4\ub2e4. \uacfc\uc815\uc740 function parameter\ub85c \ubc1b\uc740 \ubb38\uc790\uc5f4\uc744 \uac00\uc9c0\ub294 \uc784\uc2dc\uc758 .bat \ud30c\uc77c\uc744 \ub9cc\ub4e4\uace0 \uc774 \ud30c\uc77c\uc744 \uc2e4\ud589 \ud55c\ub4a4 \uc791\uc5c5\uc774 \uc885\ub8cc\ub418\uba74 .bat \ud30c\uc77c\uc744 \uc9c0\uc6b4\ub2e4.<\/p>\n<pre class=\"lang:ps decode:true\">\nFunction Invoke-BatchCommand\n{\n\tparam (\n\t\t[Parameter(Mandatory=$true)]\n\t\t$Command,\n\t\t$Path=$(Get-Location)\n\t\t)\n\n\t$TempFileName = \"{0}.bat\" -f [System.IO.Path]::GetRandomFileName()\n\t$TempFilePath = Join-Path $Path $TempFileName\n\n\tSet-Content -Path $TempFilePath -Value $Command -Force\n\n\tif (Test-Path $TempFilePath)\n\t{\n\t\t& $TempFilePath\n\t\tRemove-Item $TempFilePath -Force\n\t}\n}\n\n<\/pre>\n<p>\uc0ac\uc6a9\uc608<\/p>\n<pre class=\"lang:ps decode:true\">\n$executionCommand = \"svnadmin load C:svntest < .test.Dump\"\nInvoke-BatchCommand $executionCommand\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uc77c\ubc18 cmd \uc5d0\uc11c \uc798 \uc218\ud589\ub418\ub358 \uba85\ub839\uc774 Powershell \uc5d0\uc11c \ub611\uac19\uc774 \uc785\ub825 \ud588\uc744 \ub54c \uc624\ub958\uac00 \ub098\ub294 \uacbd\uc6b0\uac00 \uc788\ub2e4. \ub300\ubd80\ubd84 \ud2b9\uc218\ubb38\uc790\uac00 \uc788\uc744\ub54c Powershell\uc774 \ud2b9\uc218 \ubb38\uc790\ub97c \ud2b9\uc815 \uc5f0\uc0b0\uc790\ub85c \uc778\uc2dd\ud558\uba74\uc11c \uc758\ub3c4\ud558\uc9c0 \uc54a\uc740 \ub3d9\uc791\uc774 \uc77c\uc5b4\ub098\ub294 \uacbd\uc6b0 \uc774\ub2e4. \uc608\ub97c \ub4e4\uc5b4 svn Dump file\uc744 load\ud558\ub294 \uacbd\uc6b0 \ub2e4\uc74c\uacfc \uac19\uc740 \uba85\ub839\uc744 \uc0ac\uc6a9\ud55c\ub2e4. svnadmin load C:svntest < .test.Dump cmd \uc5d0\uc11c\ub294 \uc798 \uc2e4\ud589\ub418\uc9c0\ub9cc Powershell \uc5d0\uc11c\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 [&hellip;]\n<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[25,26],"tags":[62,63,145,481],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pXV5a-kc","_links":{"self":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1252"}],"collection":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1252"}],"version-history":[{"count":0,"href":"https:\/\/talsu.net\/index.php?rest_route=\/wp\/v2\/posts\/1252\/revisions"}],"wp:attachment":[{"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/talsu.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}