powershell switch和参数

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,topic,Drive)