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
LVL 5
cornetthdAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wonko_the_SaneCommented:
Something like that should work:

$d = get-date
if ($d.dayofweek -eq 'Monday') {
          code to execute goes in here
0
Wonko_the_SaneCommented:
Wrong button... Again:

Something like that should work:

$d = get-date
if ($d.dayofweek -eq 'Monday') {
          code to execute goes in here
          }

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cornetthdAuthor Commented:
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
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.