Solved

WMI Filter: If day is Saturday or Sunday

Posted on 2011-09-15
6
945 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to install and use the NTBackup utility that comes with Windows Server.
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
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

679 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