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
Solved

WMI Filter: If day is Saturday or Sunday

Posted on 2011-09-15
6
944 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

860 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