powershell switch和參數

function funarg()ide

{spa

    switch($args)orm

    {ip

        "all" { Get-WmiObject -Class win32_logicaldisk}it

        "c" { (Get-WmiObject -Class win32_logicaldisk)[1]}io

        "free" { Get-WmiObject -Class win32_logicaldisk[1].freespace}function

        "help" { $help = @"form

This script will print out the c drive information for all divers,only the cclass

drive,or the free space on c: it also will print out a help topic Example:top

>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)

相關文章
相關標籤/搜索