Powershell联合开关声明

时间:2018-02-27 03:41:49

标签: powershell switch-statement

我有以下Powershell代码:

$dow = (get-date).DayOfWeek
switch($dow) {{"Sunday"}{$report_Day = (Get-Date).AddDays(-2).Day}{"Monday", "Tuesday", "Wednesday", "Thursday"}{$report_Day = (Get-Date).Day}}
switch($dow) {{"Sunday"}{$report_Month = (Get-Date).AddDays(-2).Month}{"Monday", "Tuesday", "Wednesday", "Thursday"}{$report_Month = (Get-Date).Month}}

想知道是否可以将2个switch语句组合成1 - 例如:

$dow = (get-date).DayOfWeek
switch($dow) {{"Sunday"}{$report_Day = (Get-Date).AddDays(-2).Day, $report_Month = (Get-Date).AddDays(-2).Month}{"Monday", "Tuesday", "Wednesday", "Thursday"}{$report_Day = (Get-Date).Day, $report_Month = (Get-Date).Month }}

我测试过它不会起作用,但我想知道是否有意义将它们结合起来。

谢谢

0 个答案:

没有答案