PowerShell【初级篇●Powershell使用对象】
#创建对象
$pocketknife=New-Object object
#增加属性
Add-Member -InputObject $pocketknife -Name Color -Value "Red" -MemberType NoteProperty
#增加方法
# 增加一个新方法:
Add-Member -memberType ScriptMethod -In $pocketknife ` -name cut -Value { "I‘m whittling now" }
# 指定参数类型增加一个新方法:
Add-Member -in $pocketknife ScriptMethod screw { "Phew...it‘s in!" }
#直接通过管道增加一个新方法:
$pocketknife | Add-Member ScriptMethod corkscrew { "Pop! Cheers!" }
$pocketknife.cut()
相关推荐
huha 2020-10-16
lianshaohua 2020-09-23
higheels 2020-08-03
ZoctopusD 2020-08-03
酷云的csdn 2020-08-03
higheels 2020-07-27
liushun 2020-06-28
zhendeshifeng 2020-06-22
Sabrina 2020-06-11
CARBON 2020-06-03
CARBON 2020-06-01
DBATips 2020-05-31
higheels 2020-05-29
applecarelte 2020-04-15
Yyqingmofeige 2020-03-28
yoshubom 2020-03-06
Yyqingmofeige 2020-03-02
SciRui 2020-02-26