Solved

WMI Filter: If day is Saturday or Sunday

Posted on 2011-09-15
6
948 Views
Last Modified: 2012-05-12
I want a certain GPO to only apply on the weekends. I am trying to restrict all computer logons for a lab on Saturday and Sunday.

I thought a WMI filter would be an easy way to go that essientially applies the policy if the day is saturday or sunday. The policy would Deny a security group interactive logon rights.

If someone has an easier way, I am open to other ideas.
0
Comment
Question by:Joseph Moody
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 5

Expert Comment

by:warddhooghe
ID: 36542389
If you want to restrict users or groups to logon on any of your servers/workstations then a logon hours restriction might be a better way.
This can also be done with a GPO   http://support.microsoft.com/kb/816666
0
 
LVL 22

Author Comment

by:Joseph Moody
ID: 36542607
The problem with that is I want to restrict all users on a certain group of computers but during only certain time frames.

Is that possible with that?
0
 
LVL 26

Accepted Solution

by:
MidnightOne earned 500 total points
ID: 36546602
You can pull the day of the week from WMI as seen in the code sample.

Given Thursday is listed as value 4, that suggests (and the WMI method lookup confirms) it goes from zero to six for Sunday to Saturday.
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_CurrentTime",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_CurrentTime instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "DayOfWeek: " & objItem.DayOfWeek
Next

Open in new window

0
Office 365 Training for Admins

Learn how to provision tenants, synchronize on-premise Active Directory, and implement Single Sign-On with these master level course.  Only from Platform Scholar

 
LVL 22

Author Comment

by:Joseph Moody
ID: 36548513
Thank you MidnightOne! How would I use this filter in Group Policy?
0
 
LVL 22

Author Comment

by:Joseph Moody
ID: 36548879
This is the final WMI filter I used:

Select * from Win32_LocalTime where DayofWeek = '6' OR DayofWeek = '7'
0
 
LVL 22

Author Closing Comment

by:Joseph Moody
ID: 36548884
Thank you so much! You taught me quite a bit!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question