{"id":7401,"date":"2021-02-24T13:05:33","date_gmt":"2021-02-24T04:05:33","guid":{"rendered":"https:\/\/www.fenet.jp\/infla\/column\/?p=7401"},"modified":"2021-02-24T13:05:33","modified_gmt":"2021-02-24T04:05:33","slug":"powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97","status":"publish","type":"post","link":"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/","title":{"rendered":"PowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u3068\u306f\uff1fParam\u3092\u4f7f\u3063\u305f\u69d8\u3005\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u3084\u8a18\u8ff0\u65b9\u6cd5\u3092\u7d39\u4ecb"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_11 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u6b21<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/#PowerShell%E3%81%A7%E3%81%AE%E5%BC%95%E6%95%B0%E3%81%AE%E6%89%B1%E3%81%84%E6%96%B9%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%E7%B4%B9%E4%BB%8B%E3%81%97%E3%81%BE%E3%81%99%EF%BC%81\" title=\"PowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\uff01\">PowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\uff01<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/#%E5%BC%95%E6%95%B0%E3%81%AE%E5%9F%BA%E6%9C%AC%E7%9A%84%E3%81%AA%E4%BD%BF%E3%81%84%E6%96%B9\" title=\"\u5f15\u6570\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\">\u5f15\u6570\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/#%E5%9E%8B%E6%8C%87%E5%AE%9A\" title=\"\u578b\u6307\u5b9a\">\u578b\u6307\u5b9a<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/#%E5%BF%85%E9%A0%88%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3\" title=\"\u5fc5\u9808\u30aa\u30d7\u30b7\u30e7\u30f3\">\u5fc5\u9808\u30aa\u30d7\u30b7\u30e7\u30f3<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/#%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E5%80%A4\" title=\"\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\">\u30c7\u30d5\u30a9\u30eb\u30c8\u5024<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/#%E9%85%8D%E5%88%97\" title=\"\u914d\u5217\">\u914d\u5217<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/#%E3%83%91%E3%82%A4%E3%83%97%E3%83%A9%E3%82%A4%E3%83%B3%E5%BC%95%E6%95%B0\" title=\"\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u5f15\u6570\">\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u5f15\u6570<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/#%E3%81%BE%E3%81%A8%E3%82%81\" title=\"\u307e\u3068\u3081\">\u307e\u3068\u3081<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"PowerShell%E3%81%A7%E3%81%AE%E5%BC%95%E6%95%B0%E3%81%AE%E6%89%B1%E3%81%84%E6%96%B9%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%E7%B4%B9%E4%BB%8B%E3%81%97%E3%81%BE%E3%81%99%EF%BC%81\"><\/span>PowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\uff01<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><img src=\"https:\/\/b-engineer-media-cms.s3.amazonaws.com\/item\/image\/user\/9e08934fd24485c7d9e691a312f16a4ef7ff96eb\/c1cb7401-ec6d-4d3a-8aca-ec208efef37e.jpg\" \/><\/p>\n<p>\u4eca\u56de\u306f\u3001PowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br \/>\n<mark>\u5f15\u6570\u3092\u6271\u3046\u306b\u306fParam\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/mark><br \/>\n\u3053\u3053\u3067\u306f\u3001PowerShell\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308bps1\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u30fb\u5b9f\u884c\u3059\u308b\u30b1\u30fc\u30b9\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>PowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u306b\u8208\u5473\u306e\u3042\u308b\u65b9\u306f\u305c\u3072\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<br \/>\n<script src=\"\"https:\/\/cdn.rawgit.com\/google\/code-prettify\/master\/loader\/run_prettify.js?skin=sunburst\"\"><\/script><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%BC%95%E6%95%B0%E3%81%AE%E5%9F%BA%E6%9C%AC%E7%9A%84%E3%81%AA%E4%BD%BF%E3%81%84%E6%96%B9\"><\/span>\u5f15\u6570\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><mark>PowerShell\u3067\u306e\u5f15\u6570\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/mark><br \/>\n\u5b9f\u969b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"\">Param( $name, $age )<\/pre>\n<p>Write-Host &#8220;&#8221;name: $name&#8221;&#8221;<br \/>\nWrite-Host &#8220;&#8221;age: $age&#8221;&#8221;<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">PS C:\\test&gt; .\\pstest.ps1 \"\"taro\"\" 20\r\nname: taro\r\nage: 20\r\nPS C:\\test&gt; # -name, -age\u3092\u4ed8\u4e0e\u3059\u308b\u3068\u3001\u9806\u756a\u3092\u5165\u308c\u66ff\u3048\u3066\u3082\u69cb\u3044\u307e\u305b\u3093\u3002\r\nPS C:\\test&gt; .\\pstest.ps1 -age 20 -name \"\"taro\"\"\r\nname: taro\r\nage: 20\r\nPS C:\\test&gt;\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E5%9E%8B%E6%8C%87%E5%AE%9A\"><\/span>\u578b\u6307\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><mark>PowerShell\u3067\u306e\u5f15\u6570\u306e\u578b\u6307\u5b9a\u306e\u65b9\u6cd5\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/mark><\/p>\n<p>\u5b9f\u969b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"\">Param( [string]$name, [int]$age )<\/pre>\n<p>Write-Host &#8220;&#8221;name: $name&#8221;&#8221;<br \/>\nWrite-Host &#8220;&#8221;age: $age&#8221;&#8221;<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">PS C:\\test&gt; .\\pstest.ps1 -name \"\"taro\"\" -age \"\"20\"\"\r\nname: taro\r\nage: 20\r\nPS C:\\test&gt; .\\pstest.ps1 -name \"\"taro\"\" -age \"\"jiro\"\"\r\nC:\\test\\pstest.ps1 : \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc 'age' \u306e\u5f15\u6570\u5909\u63db\u3092\u51e6\u7406\u3067\u304d\u307e\u305b\u3093\u3002\u5024 \"\"jiro\"\" \u3092\u578b \"\"System.Int32\"\" \u306b\u5909\u63db\u3067\u304d\u307e\u305b\u3093\u3002\u30a8\r\n\u30e9\u30fc: \"\"\u5165\u529b\u6587\u5b57\u5217\u306e\u5f62\u5f0f\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002\"\"\r\n\u767a\u751f\u5834\u6240 \u884c:1 \u6587\u5b57:32\r\n+ .\\pstest.ps1 -name \"\"taro\"\" -age \"\"jiro\"\"\r\n+                                ~~~~~~\r\n    + CategoryInfo          : InvalidData: (:) [pstest.ps1]\u3001ParameterBindingArgumentTransformationException\r\n    + FullyQualifiedErrorId : ParameterArgumentTransformationError,pstest.ps1<\/pre>\n<p>PS C:\\test&gt;<\/p>\n<p>\u6587\u5b57\u5217\u306e\u6570\u5b57\u3092\u5165\u529b\u3059\u308b\u3068int\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u307e\u3059\u304c\u3001\u30ad\u30e3\u30b9\u30c8\u3067\u304d\u306a\u3044\u6587\u5b57\u5217\u3092\u5165\u529b\u3059\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%BF%85%E9%A0%88%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3\"><\/span>\u5fc5\u9808\u30aa\u30d7\u30b7\u30e7\u30f3<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><mark>PowerShell\u3067\u306e\u5f15\u6570\u3092\u5fc5\u9808\u306b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/mark>mandatory=$true\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"\">Param( [parameter(mandatory=$true)][string]$name, \r\n       [parameter(mandatory=$true)][int]$age )<\/pre>\n<p>Write-Host &#8220;&#8221;name: $name&#8221;&#8221;<br \/>\nWrite-Host &#8220;&#8221;age: $age&#8221;&#8221;<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">PS C:\\test&gt; # \u5f15\u6570\u5165\u529b\u6642\r\nPS C:\\test&gt; .\\pstest.ps1 -name \"\"taro\"\" -age 20\r\nname: taro\r\nage: 20\r\nPS C:\\test&gt; # \u5f15\u6570\u7701\u7565\u6642\r\nPS C:\\test&gt; .\\pstest.ps1 -name \"\"taro\"\"<\/pre>\n<p>\u30b3\u30de\u30f3\u30c9 \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u4f4d\u7f6e 1 \u306e\u30b3\u30de\u30f3\u30c9\u30ec\u30c3\u30c8 pstest.ps1<br \/>\n\u6b21\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306b\u5024\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044:<br \/>\nage: 20<br \/>\nname: taro<br \/>\nage: 20<br \/>\nPS C:\\test&gt; # \u5f15\u6570\u7701\u7565\u6642<br \/>\nPS C:\\test&gt; .\\pstest.ps1<\/p>\n<p>\u30b3\u30de\u30f3\u30c9 \u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u4f4d\u7f6e 1 \u306e\u30b3\u30de\u30f3\u30c9\u30ec\u30c3\u30c8 pstest.ps1<br \/>\n\u6b21\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306b\u5024\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044:<br \/>\nname: taro<br \/>\nage: 20<br \/>\nname: taro<br \/>\nage: 20<br \/>\nPS C:\\test&gt;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E5%80%A4\"><\/span>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><mark>PowerShell\u3067\u306e\u5f15\u6570\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/mark><\/p>\n<p>\u5b9f\u969b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"\">Param( [string]$name = \"\"jiro\"\", \r\n       [int]$age = 30 )<\/pre>\n<p>Write-Host &#8220;&#8221;name: $name&#8221;&#8221;<br \/>\nWrite-Host &#8220;&#8221;age: $age&#8221;&#8221;<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">PS C:\\test&gt; .\\pstest.ps1 -name \"\"taro\"\" -age 20\r\nname: taro\r\nage: 20\r\nPS C:\\test&gt; # \u5f15\u6570\u7701\u7565\u6642\r\nPS C:\\test&gt; .\\pstest.ps1 -name \"\"taro\"\"\r\nname: taro\r\nage: 30\r\nPS C:\\test&gt; # \u5f15\u6570\u7701\u7565\u6642\r\nPS C:\\test&gt; .\\pstest.ps1\r\nname: jiro\r\nage: 30\r\nPS C:\\test&gt;\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E9%85%8D%E5%88%97\"><\/span>\u914d\u5217<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><mark>PowerShell\u3067\u306f\u5f15\u6570\u3092\u914d\u5217\u3067\u53d7\u3051\u53d6\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/mark><\/p>\n<p>\u5b9f\u969b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"\">Param( [array]$array )<\/pre>\n<p>$array<br \/>\nWrite-Host &#8220;&#8221;length: &#8220;&#8221; $array.Length<br \/>\n$array.GetType()<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">PS C:\\test&gt; .\\pstest.ps1 \"\"taro\"\",\"\"jiro\"\",\"\"saburo\"\"\r\ntaro\r\njiro\r\nsaburo\r\nlength:  3<\/pre>\n<p>IsPublic IsSerial Name BaseType<br \/>\n&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;- &#8212;&#8212;&#8211;<br \/>\nTrue True Object[] System.Array<\/p>\n<p>PS C:\\test&gt;<\/p>\n<p>\u914d\u5217\u306e\u8981\u7d20\u6570\u306b\u5236\u9650\u3092\u8a2d\u3051\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002ValidateCount\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"\">Param( [ValidateCount(1,5)][array]$array )<\/pre>\n<p>$array<br \/>\nWrite-Host &#8220;&#8221;length: &#8220;&#8221; $array.Length<br \/>\n$array.GetType()<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">PS C:\\test&gt; .\\pstest.ps1 \"\"taro\"\",\"\"jiro\"\",\"\"saburo\"\",\"\"shiro\"\",\"\"goro\"\"\r\ntaro\r\njiro\r\nsaburo\r\nshiro\r\ngoro\r\nlength:  5<\/pre>\n<p>IsPublic IsSerial Name BaseType<br \/>\n&#8212;&#8212;&#8211; &#8212;&#8212;&#8211; &#8212;- &#8212;&#8212;&#8211;<br \/>\nTrue True Object[] System.Array<\/p>\n<p>PS C:\\test&gt; # \u8981\u7d20\u6570\u304c5\u3092\u8d85\u3048\u308b\u306e\u3067\u30a8\u30e9\u30fc<br \/>\nPS C:\\test&gt; .\\pstest.ps1 &#8220;&#8221;taro&#8221;&#8221;,&#8221;&#8221;jiro&#8221;&#8221;,&#8221;&#8221;saburo&#8221;&#8221;,&#8221;&#8221;shiro&#8221;&#8221;,&#8221;&#8221;goro&#8221;&#8221;,&#8221;&#8221;rokuro&#8221;&#8221;<br \/>\nC:\\test\\pstest.ps1 : \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc &#8216;array \u306e\u5f15\u6570\u3092\u78ba\u8a8d\u3067\u304d\u307e\u305b\u3093\u3002\u6307\u5b9a\u3055\u308c\u305f\u5f15\u6570\u306e\u6570 (6) \u304c\u3001\u5f15\u6570\u306e\u6700\u5927\u8a31\u5bb9\u6570 (5) \u3092\u8d85\u3048<br \/>\n\u3066\u3044\u307e\u3059\u30025 \u672a\u6e80\u306e\u6570\u306e\u5f15\u6570\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b3\u30de\u30f3\u30c9\u3092\u518d\u5ea6\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u767a\u751f\u5834\u6240 \u884c:1 \u6587\u5b57:14<br \/>\n+ .\\pstest.ps1 &#8220;&#8221;taro&#8221;&#8221;,&#8221;&#8221;jiro&#8221;&#8221;,&#8221;&#8221;saburo&#8221;&#8221;,&#8221;&#8221;shiro&#8221;&#8221;,&#8221;&#8221;goro&#8221;&#8221;,&#8221;&#8221;rokuro&#8221;&#8221;<br \/>\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br \/>\n+ CategoryInfo : InvalidData: (:) [pstest.ps1]\u3001ParameterBindingValidationException<br \/>\n+ FullyQualifiedErrorId : ParameterArgumentValidationError,pstest.ps1<\/p>\n<p>PS C:\\test&gt;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E3%83%91%E3%82%A4%E3%83%97%E3%83%A9%E3%82%A4%E3%83%B3%E5%BC%95%E6%95%B0\"><\/span>\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u5f15\u6570<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><mark>PowerShell\u3067\u306f\u5f15\u6570\u3092\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u304b\u3089\u53d7\u3051\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/mark><br \/>\nValueFromPipeline\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"\">Param( [Parameter(ValueFromPipeline=$true)][string]$name, \r\n       [Parameter(ValueFromPipeline=$false)][int]$age )<\/pre>\n<p>Write-Host &#8220;&#8221;name: $name&#8221;&#8221;<br \/>\nWrite-Host &#8220;&#8221;age: $age&#8221;&#8221;<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">PS C:\\test&gt; \"\"taro\"\" | .\\pstest.ps1 -age 20\r\nname: taro\r\nage: 20\r\n<\/pre>\n<p>\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u304b\u3089\u5f15\u6570\u3092\u53d7\u3051\u53d6\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002ValueFromPipeline\u3092\u6307\u5b9a\u3057\u306a\u3044\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">Param( [string]$name, [int]$age )<\/pre>\n<p>Write-Host &#8220;&#8221;name: $name&#8221;&#8221;<br \/>\nWrite-Host &#8220;&#8221;age: $age&#8221;&#8221;<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"\">PS C:\\test&gt; \"\"taro\"\" | .\\pstest.ps1 -age 20\r\nname:\r\nage: 20\r\nPS C:\\test&gt;\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E3%81%BE%E3%81%A8%E3%82%81\"><\/span>\u307e\u3068\u3081<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u3044\u304b\u304c\u3067\u3057\u305f\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\nPowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3057\u305f\u3002<br \/>\n<mark>\u5f15\u6570\u3092\u6271\u3046\u306b\u306fParam\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/mark><br \/>\nParam\u306b\u306f\u69d8\u3005\u306a\u30aa\u30d7\u30b7\u30e7\u30f3\u3084\u8a18\u8ff0\u65b9\u6cd5\u304c\u3042\u308a\u3001\u305d\u306e\u3046\u3061\u306e\u3044\u304f\u3064\u304b\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305c\u3072\u3054\u81ea\u8eab\u3067\u30b3\u30de\u30f3\u30c9\u3092\u66f8\u3044\u3066\u3001\u7406\u89e3\u3092\u6df1\u3081\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21 PowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\uff01\u5f15\u6570\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u578b\u6307\u5b9a\u5fc5\u9808\u30aa\u30d7\u30b7\u30e7\u30f3\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u914d\u5217\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u5f15\u6570\u307e\u3068\u3081 PowerShell\u3067\u306e\u5f15\u6570\u306e\u6271\u3044\u65b9\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3059\uff01 \u4eca\u56de\u306f\u3001PowerS<a class=\"read-more\" href=\"https:\/\/www.fenet.jp\/infla\/column\/engineer\/powershell%e3%81%a7%e3%81%ae%e5%bc%95%e6%95%b0%e3%81%ae%e6%89%b1%e3%81%84%e6%96%b9%e3%81%a8%e3%81%af%ef%bc%9fparam%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e6%a7%98%e3%80%85%e3%81%aa%e3%82%aa%e3%83%97\/\"> &#8230;\u3082\u3063\u3068\u8aad\u3080<\/a><\/p>\n","protected":false},"author":17,"featured_media":5410,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[101],"tags":[],"_links":{"self":[{"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/posts\/7401"}],"collection":[{"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/comments?post=7401"}],"version-history":[{"count":4,"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/posts\/7401\/revisions"}],"predecessor-version":[{"id":8107,"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/posts\/7401\/revisions\/8107"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/media\/5410"}],"wp:attachment":[{"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/media?parent=7401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/categories?post=7401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fenet.jp\/infla\/column\/wp-json\/wp\/v2\/tags?post=7401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}