Hi All,
I'm looking to add a number of computers to a security group on the last Monday of every month and then remove them 2-3 days later but having a little difficulty so hoping someone can point me in the right direction,
I have this script to check if the day is the last Monday of the month
function Get
-LastMondayOfMonth
([DateTime]
$d
) {
$lastDay
=
new-object
DateTime(
$d
.Year,
$d
.Month, [DateTime]::DaysInMonth(
$d
.Year,
$d
.Month))
$diff
= ([int] [DayOfWeek]::Monday) - ([int]
$lastDay
.DayOfWeek)
if (
$diff
-ge
0) {
return
$lastDay
.AddDays(- (7-
$diff
))
}
else {
return
$lastDay
.AddDays(
$diff
)
}
}
I now need to know how i pass the results of this to a workflow that already adds the computers to the correct group just that its not automated yet....
Thanks
Alex