2012年4月27日 星期五

使用VBScript將OU內的User名稱改大寫


要將OU內的所以使用者名稱,將英文小寫部份都變更為大寫。
爬文了一下, 原來DN (distinguishedName) 是不能用 objUser.put 方式來改的..
要用Move的方式來處理..
如下 : 將User Object 由原來的名稱, 移到大寫的新名稱的位置.

' Change DN (distinguishedName) to UpperCase by VBScript
' -----------------------------------------------'
Option Explicit
Dim objOU, objUser , UName, LName
Set objOU = GetObject("LDAP://ou=OU1,dc=demo,dc=com")
For each objUser in objOU
If objUser.class="user" Then
LName = objUser.displayName
UName = UCase(objUser.displayName)
objUser.Put "displayname", UName
objUser.Put "givenName", UName
objUser.Put "sAMAccountName",UName
objUser.SetInfo
GetObject(objUser.parent).moveHere ObjUser.adspath,"CN=" & UName
End If
Next

2012年4月9日 星期一

How to delete files after archiving in Schedule tasks

發現一個目前是winrar 獨有的功能, delete files after archiving , 下的參數是  rar -df , 目前download winrar 4.11 是具備此功能的,其他如 7zip / winzip 目前都沒有發現對應的功能.

把它寫成一個VBS

strshell = "RAR.exe a -r -df d:\arc\demo-datetime.rar  d:\datafolder\"
result1 = wshshell.run (strshell,0,False)


放到 WIN2k8做成排程

怪了..居然可以壓縮,但不能刪除舊檔..??

Why?

查了一下 Task Security Context ,是權限不足,勾選排程的"run with highest privileges", 即可正常執行.