{"id":2533,"date":"2017-06-24T16:37:58","date_gmt":"2017-06-24T07:37:58","guid":{"rendered":"http:\/\/1bed.allright.life\/?p=2533"},"modified":"2020-04-18T20:33:45","modified_gmt":"2020-04-18T11:33:45","slug":"post-2533","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2533","title":{"rendered":"PowerShell \u3067\u30d5\u30a1\u30a4\u30eb\u9078\u629e\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u5229\u7528\u3059\u308b"},"content":{"rendered":"<p>\u610f\u5916\u3068\u4f7f\u3044\u52dd\u624b\u304c\u826f\u3055\u305d\u3046\u306a\u306e\u304c\u3053\u306e\u65b9\u6cd5\u3060\u3068\u601d\u3046\u3002<\/p>\n<h2>\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u30921\u3064\u9078\u629e\u9078\u629e\u3055\u305b\u308b<\/h2>\n<pre><code class=\"language-powershell\">[void][System.Reflection.Assembly]::LoadWithPartialName(&quot;System.windows.forms&quot;)\n\n$dialog = New-Object System.Windows.Forms.OpenFileDialog\n$dialog.Filter = &quot;\u753b\u50cf\u30d5\u30a1\u30a4\u30eb(*.PNG;*.JPG;*.GIF)|*.PNG;*.JPG;*.JPEG;*.GIF&quot;\n$dialog.InitialDirectory = &quot;C:\\&quot;\n$dialog.Title = &quot;\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044&quot;\n# \u8907\u6570\u9078\u629e\u3092\u8a31\u53ef\u3057\u305f\u3044\u6642\u306f Multiselect \u3092\u8a2d\u5b9a\u3059\u308b\n$dialog.Multiselect = $true\n\n# \u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u8868\u793a\nif($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK){\n    # \u8907\u6570\u9078\u629e\u3092\u8a31\u53ef\u3057\u3066\u3044\u308b\u6642\u306f $dialog.FileNames \u3092\u5229\u7528\u3059\u308b\n    Write-Output ($dialog.FileName + &quot; \u304c\u9078\u629e\u3055\u308c\u307e\u3057\u305f\u3002&quot;)\n}<\/code><\/pre>\n<h2>CSV \u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3059\u308b<\/h2>\n<p>\u3053\u3046\u3044\u3046\u30d1\u30bf\u30fc\u30f3\u3042\u308b\u304b\u306a\uff1f\u3068\u601d\u3046\u3002<br \/>\n\u666e\u6bb5\u306f\u30bf\u30b9\u30af\u30b9\u30b1\u30b8\u30e5\u30fc\u30e9\u30fc\u3067\u30ad\u30c3\u30af\u3057\u3066\u3044\u308b\u3051\u3069\u3001\u5931\u6557\u3057\u305f\u3089\u624b\u52d5\u3067\u52d5\u304b\u3059\u3068\u304b\u3002<\/p>\n<pre><code class=\"language-powershell\">Param(\n  [Parameter()]\n  [String] $FilePath\n)\n\n# $FilePath \u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u3001\u53c8\u306f\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u306a\u3044\nif([string]::IsNullOrEmpty($FilePath) -Or (Test-Path -LiteralPath $FilePath -PathType Leaf) -eq $false) {\n    [void][System.Reflection.Assembly]::LoadWithPartialName(&quot;System.windows.forms&quot;)    \n    $dialog = New-Object System.Windows.Forms.OpenFileDialog\n    $dialog.Filter = &quot;CSV \u30d5\u30a1\u30a4\u30eb(*.CSV)|*.CSV&quot;\n    $dialog.InitialDirectory = &quot;C:\\&quot;\n    $dialog.Title = &quot;\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044&quot;\n\n    # \u30ad\u30e3\u30f3\u30bb\u30eb\u3092\u62bc\u3055\u308c\u305f\u6642\u306f\u51e6\u7406\u3092\u6b62\u3081\u308b\n    if($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::NG){\n        exit 1\n    }\n\n    # \u9078\u629e\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3092 $FilePath \u306b\u8a2d\u5b9a\n    $FilePath = $dialog.FileName\n}\n\n# \u3053\u3053\u304b\u3089\u4e0b\u3067 $FilePath \u3092\u3044\u3044\u611f\u3058\u3067\u51e6\u7406\u3059\u308b\nWrite-Output $FilePath<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u610f\u5916\u3068\u4f7f\u3044\u52dd\u624b\u304c\u826f\u3055\u305d\u3046\u306a\u306e\u304c\u3053\u306e\u65b9\u6cd5\u3060\u3068\u601d\u3046\u3002 \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u30921\u3064\u9078\u629e\u9078\u629e\u3055\u305b\u308b [void][System.Reflection.Assembly]::LoadWithPartialName(&quot;System [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[62],"class_list":["post-2533","post","type-post","status-publish","format-standard","hentry","category-program","tag-powershell"],"_links":{"self":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2533"}],"version-history":[{"count":6,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2533\/revisions"}],"predecessor-version":[{"id":3123,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2533\/revisions\/3123"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}