次の方法で共有


13日は何曜日?

????????13??????????????????????????????????????????????

?????????????????????13????????????????Windows PowerShell ????????????

?????????????.NET Framework ? DateTime ???????????????? DateTime ????????????????????????

???? DateTime ???????????????? DateTime ?????????????

psh> [DateTime]”2008/6/13”
2008?6?13? 0:00:00

?????????? DayOfWeek ??????

psh> ([DateTime]”2008/6/13”).DayOfWeek
Friday

??????????Get-Member ???????????????????????DayOfWeek ??? System.DayOfWeek ?????????????????????????????????????? 0 ????????

psh> ([DateTime]"2008/6/13").DayOfWeek -eq "Friday"
True
psh> ([DateTime]"2008/6/13").DayOfWeek -eq 5
True

???????????????????????????????????????????1?????????2??????????????????

psh> ([DateTime]"2008/6/13").ToString("r")
Fri, 13 Jun 2008 00:00:00 GMT
psh> ([DateTime]"2008/6/13").ToString("yyyy/MM/dd dddd")
2008/06/13 ???

???????6???????13?????????????????2008/6/13 ???????1???????????AddMonths() ???????????????1??6????????? ForEach-Object ????????????% ? ForEach-Object ???? (?????) ???(???2?????????????1????)

psh> 1..6 | %{([DateTime]"2008/6/13")
.AddMonths($_).ToString("yyyy/MM/dd dddd")}
2008/07/13 ???
2008/08/13 ???
2008/09/13 ???
2008/10/13 ???
2008/11/13 ???
2008/12/13 ???

????????????????????????50????????????????????13??????? $d ???????????????????1????????????????????????…

psh> 1..50 | %{$d = ([DateTime]"2008/6/13").AddMonths($_);
if($d.DayOfWeek -eq 5)
{$d.ToString("yyyy/MM/dd dddd")}}
2009/02/13 ???
2009/03/13 ???
2009/11/13 ???
2010/08/13 ???
2011/05/13 ???
2012/01/13 ???
2012/04/13 ???
2012/07/13 ???

??????????????????????????????????????????????????Outlook ??????????????????Outlook ???????????????????Script Center ????????????(VBScript ??????)

??? Outlook ?????? COM ?????????????

$ol = New-Object -com outlook.application

?????????? Outlook ????????????????????????????CreateItem() ???? 1 ???????????????????????????????????

??????????????????????????????????????????????????????????????????3??? $ol ? Outlook ????????????????????????????

function new-schedule {
param([DateTime]$date)
$sch = $ol.CreateItem(1)
$sch.AllDayEvent = $true
$sch.start = $date
$sch.subject = "13?????"
$sch.body = "??????"
$sch.Save()
}

???????????50????????????????????

psh> $ol = New-Object -com outlook.application
psh> 1..50 | %{$d = ([DateTime]"2008/6/13").AddMonths($_);
if($d.DayOfWeek -eq 5){new-schedule($d)}}

image

Comments

  • Anonymous
    January 01, 2003
    13日の金曜日、いかがお過ごしでしょうか。 昨年、PowerShell を使って Outlook の予定を作成しておいたので、しっかり昨日から、アラームが表示されていました。半年越しの仕込みが日の目を見ましたので、ここに記しておきたいと思います。