torlee 发表于 2018-9-2 12:00:00

powershell switch和参数

  function funarg()
  {
  switch($args)
  {
  "all" { Get-WmiObject -Class win32_logicaldisk}
  "c" { (Get-WmiObject -Class win32_logicaldisk)}
  "free" { Get-WmiObject -Class win32_logicaldisk.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)

页: [1]
查看完整版本: powershell switch和参数