我有以下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 }}
我测试过它不会起作用,但我想知道是否有意义将它们结合起来。
谢谢