cornetthd
asked on
Execute a portion of a Powershell Script on a Specific Day
Is there a way to setup a portion of a powershell script to execute on a specific day.
Ex.
If Day = Monday
execute code
Else Skip
Ex.
If Day = Monday
execute code
Else Skip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked perfectly. I modified it a little to add a variable for the day.
$d = get-date
$day = 'Monday'
if ($d.dayofweek -eq $day) {
Code to Execute
}
I used this portion of the script in mutilple places.
if ($d.dayofweek -eq $day) {
Code to Execute
}
$d = get-date
$day = 'Monday'
if ($d.dayofweek -eq $day) {
Code to Execute
}
I used this portion of the script in mutilple places.
if ($d.dayofweek -eq $day) {
Code to Execute
}
$d = get-date
if ($d.dayofweek -eq 'Monday') {
code to execute goes in here