Solved

WMI Filter: If day is Saturday or Sunday

Posted on 2011-09-15
6
940 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
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
This article runs through the process of deploying a single EXE application selectively to a group of user.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

772 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