Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll

p0w3rsh3ll/Get-DayInMonth.exmaple.ps1 Secret

Last active Jun 15, 2017
Embed
What would you like to do?
[System.Enum]::GetValues([System.DayOfWeek]) | ForEach-Object {
$day = $_.ToString()
1..12 | ForEach-Object {
$fi = Get-DayInMonth -Day $day -Month $_ -Year 2016 -asDate -Position First
$la = Get-DayInMonth -Day $day -Month $_ -Year 2016 -asDate -Position Last
$fo = Get-DayInMonth -Day $day -Month $_ -Year 2016 -asDate -Position Fourth
[PSCustomObject]@{
Day = $day
Month = $_
DaysBetweenFirstandLast = (New-TimeSpan -Start $fi -End $la).Days
First = $fi.ToString('yyyy/MM/dd')
Last = $la.ToString('yyyy/MM/dd')
Fourth = $fo.ToString('yyyy/MM/dd')
}
}
} | ft -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.