{"id":2788,"date":"2018-10-12T02:05:48","date_gmt":"2018-10-11T17:05:48","guid":{"rendered":"https:\/\/1bed.allright.life\/?p=2788"},"modified":"2020-04-18T19:24:28","modified_gmt":"2020-04-18T10:24:28","slug":"post-2788","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2788","title":{"rendered":"PowerShell \u3067\u30d5\u30a9\u30eb\u30c0\u30fc\u3092\u4e00\u62ec\u4f5c\u6210\u3059\u308b"},"content":{"rendered":"<h2>\u7d4c\u7def<\/h2>\n<p>\u5148\u65e5\u540c\u50da\u304c\u3001\u304a\u5ba2\u69d8\u304b\u3089\u3082\u3089\u3063\u305f\u30ea\u30b9\u30c8\u3092\u5143\u306b\u3001\u7d04 5,000 \u500b\u7a0b\u306e\u30d5\u30a9\u30eb\u30c0\u30fc\u3092\u4f5c\u6210\u3059\u308b\u3068\u3044\u3046\u8a71\u3092\u3057\u3066\u3044\u305f\u306e\u3067\u3001PowerShell \u3067\u30b5\u30af\u30c3\u3068\u8a66\u3057\u3066\u307f\u305f<\/p>\n<h2>\u74b0\u5883<\/h2>\n<ul>\n<li>Windows Pro 10<\/li>\n<li>PowerShell 5.1.17134.228<\/li>\n<\/ul>\n<h2>\u7528\u610f\u3057\u305f\u30c7\u30fc\u30bf<\/h2>\n<p>\u6b21\u306e\u5185\u5bb9\u3067 list.txt \u3068\u3057\u3066\u7528\u610f\u3057\u305f<\/p>\n<pre><code class=\"language-text\">\u30eb\u30fc\u30c8\n\u30eb\u30fc\u30c8\/\u5b50\uff11\n\u30eb\u30fc\u30c8\/\u5b50\uff11\/\u5b6b\uff11\uff0d\uff11\n\u30eb\u30fc\u30c8\/\u5b50\uff11\/\u5b6b\uff11\u30fc\uff11\/\u3072\u5b6b\uff11\uff0d\uff11\uff0d\uff11\n\u30eb\u30fc\u30c8\/\u5b50\uff11\/\u5b6b\uff11\u30fc\uff11\/\u3072\u5b6b\uff11\uff0d\uff11\uff0d\uff12\n\u30eb\u30fc\u30c8\/\u5b50\uff11\/\u5b6b\uff11\uff0d\uff12\n\u30eb\u30fc\u30c8\/\u5b50\uff11\/\u5b6b\uff11\uff0d\uff12\/\u3072\u5b6b\uff11\uff0d\uff12\uff0d\uff11\n\n\u30eb\u30fc\u30c8\/\u5b50\uff12\n\u30eb\u30fc\u30c8\/\u5b50\uff12\/\u534a\u89d2 \u30b9\u30da\u30fc\u30b9\n\u30eb\u30fc\u30c8\/\u5b50\uff12\/\u5168\u89d2\u3000\u30b9\u30da\u30fc\u30b9\n\u30eb\u30fc\u30c8\/\u5b50\uff12\/\u91cd\u8907\u30c6\u30b9\u30c8\n\u30eb\u30fc\u30c8\/\u5b50\uff12\/\u91cd\u8907\u30c6\u30b9\u30c8\n\u30eb\u30fc\u30c8\/\u5b50\uff12\/hoge*\u7570\u5e38\u7cfb\u30c6\u30b9\u30c8<\/code><\/pre>\n<ul>\n<li>1-7 \u884c\u76ee\u307e\u3067\u300c\u30eb\u30fc\u30c8\/\u5b50\uff11\u300d\u306e\u90e8\u5206\u304c\u6b63\u5e38\u7cfb<\/li>\n<li>8 \u884c\u76ee\u304c\u7a7a\u884c\u30c6\u30b9\u30c8<\/li>\n<li>9 \u884c\u76ee\u4ee5\u964d\u306f\u30c7\u30fc\u30bf\u306e\u7570\u5e38\u7cfb\u30c6\u30b9\u30c8<\/li>\n<\/ul>\n<h2>\u30b3\u30fc\u30c9<\/h2>\n<pre><code class=\"language-powershell\">Get-Content list.txt | %{ &amp;({ [void](New-Item ($_.ToString()) -ItemType Directory -Force)}, { Write-Output &quot;is row empty&quot; })[[string]::IsNullOrWhiteSpace($_.ToString())] }<\/code><\/pre>\n<p>\u4f55\u3068\u306a\u304f\u7121\u7406\u3084\u308a\u30ef\u30f3\u30e9\u30a4\u30ca\u30fc\u3067\u66f8\u3044\u3066\u307f\u307e\u3057\u305f<\/p>\n<ol>\n<li>list.txt \u3092\u8aad\u307f\u8fbc\u307f<\/li>\n<li>ForEach-Object(\u30b3\u30fc\u30c9\u3067\u306f\u7701\u7565\u3057\u3066 % \u3068\u8868\u8a18)\u3067\u884c\u6570\u5206\u7e70\u308a\u8fd4\u3059\n<ul>\n<li>\u30d5\u30a9\u30eb\u30c0\u4f5c\u6210\u51e6\u7406\n<ul>\n<li>\u7a7a\u884c\u3067\u306f\u306a\u3044\u6642\u884c\u304c\u7a7a\u3058\u3083\u306a\u3044\u3068\u304d\u306b\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210<\/li>\n<li>\u7a7a\u884c\u306e\u6642\u300cis row empty\u300d\u3068\u8868\u8a18\u3059\u308b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h2>\u5b9f\u884c\u4f8b<\/h2>\n<pre><code class=\"language-powershell\">Get-Content list.txt | %{ &amp;({ [void](New-Item ($_.ToString()) -ItemType Directory -Force)}, { })[[string]::IsNullOrWhiteSpace($_.ToString())] }\n\nNew-Item : \u30d1\u30b9\u306b\u7121\u52b9\u306a\u6587\u5b57\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\n\u767a\u751f\u5834\u6240 \u884c:1 \u6587\u5b57:38\n+ ...  &amp;({ [void](New-Item ($_.ToString()) -ItemType Directory -Force)}, {  ...\n+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n    + CategoryInfo          : InvalidArgument: (C:\\Users\\hoge\\...\\\u5b50\uff12\\hoge*\u7570\u5e38\u7cfb\u30c6\u30b9\u30c8:String) [New-Item]\u3001ArgumentException\n    + FullyQualifiedErrorId : CreateDirectoryArgumentError,Microsoft.PowerShell.Commands.NewItemCommand<\/code><\/pre>\n<p>\u4e88\u5b9a\u901a\u308a\u3001\u7570\u5e38\u7cfb\u30c6\u30b9\u30c8\u306e\u6700\u7d42\u884c\u306e\u30d5\u30a1\u30a4\u30eb\u3084\u30d5\u30a9\u30eb\u30c0\u540d\u3067\u4f7f\u3048\u306a\u3044\u6587\u5b57\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u305f<\/p>\n<h2>\u8003\u5bdf<\/h2>\n<p>\u3061\u3083\u3093\u3068\u66f8\u3051\u3070 try-catch-finally \u3092\u5165\u308c\u308b\u3093\u3060\u308d\u3046\u3051\u3069\u3001\u3068\u308a\u3042\u3048\u305a\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u7b87\u6240\u306e\u884c\u3092\u4fee\u6b63\u3057\u3066\u3044\u3051\u3070\u3088\u3055\u305d\u3046<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d4c\u7def \u5148\u65e5\u540c\u50da\u304c\u3001\u304a\u5ba2\u69d8\u304b\u3089\u3082\u3089\u3063\u305f\u30ea\u30b9\u30c8\u3092\u5143\u306b\u3001\u7d04 5,000 \u500b\u7a0b\u306e\u30d5\u30a9\u30eb\u30c0\u30fc\u3092\u4f5c\u6210\u3059\u308b\u3068\u3044\u3046\u8a71\u3092\u3057\u3066\u3044\u305f\u306e\u3067\u3001PowerShell \u3067\u30b5\u30af\u30c3\u3068\u8a66\u3057\u3066\u307f\u305f \u74b0\u5883 Windows Pro 10 PowerShell 5 [&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-2788","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\/2788","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=2788"}],"version-history":[{"count":23,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2788\/revisions"}],"predecessor-version":[{"id":3100,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2788\/revisions\/3100"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}