您的位置:首页 > 运维架构 > Shell

powershell switch和参数

2015-05-04 11:33 337 查看
function funarg()
{
switch($args)
{
"all" { Get-WmiObject -Class win32_logicaldisk}
"c" { (Get-WmiObject -Class win32_logicaldisk)[1]}
"free" { Get-WmiObject -Class win32_logicaldisk[1].freespace}
"help" { $help = @"
This script will print out the c drive information for all divers,only the c
drive,or the free space on c: it also will print out a help topic Example:
>GetDriverargs.ps1 all
print out information on all drices
>GetDriverargs.ps1 c
print out information on only the c drive
>GetDriverargs.ps1 free
print out freespace on the c drive
"@
write-host $help}
}
}
#$args="help"
funarg($args)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  function drive topic