qshinoの日記

Powershell関係と徒然なこと

cmdletbinding

powershell の[cmdletbinding()]

 

これを記述する事で、write-verboseやwrite-debugが使用できる。

---

パラーメータ記述

 

1. [parameter()] デコレーター

2. [switch]指定

 

1. [parameter()]デコレーター

 

Mandatory = $true or $false

Position = <number>

 

2. [switch]

 

パラーメータ指定があると $true

ないと $false

 

例)

[cmdletbinding()]

param(

  [parameter(Mandatory=$true, Position=1)]

  [string]$poi,

   [parameter(Mandatory=$false, Position=2)]

  [string]$qwe = "Hi!"]

)