Categories
VBScript

VBScript ; Enable Out-Of-Office (OOO)

VBScript ; Enable Out-Of-Office (OOO)

The following script will allow you to enable Out Of Office on any users mailbox (provided you have permissions that it…)

Set objMAPISession = CreateObject(“MAPI.Session”)

‘strExchangeSvr = InputBox(“Please provide the name of your Exchange Server”)
strExchangeSvr = “mailserver-name”

strMailbox = InputBox(“Please enter the mailbox name to enable Out-Of-Office…”)

strMAPI = strExchangeSvr & vbLf & strMailbox

On error Resume Next

objMAPISession.Logon “”, “”, False, True, 0, False, strMAPI

If err <> 0 Then
Wscript.Echo “An Error occured: ” & err.description
Err.clear
Wscript.Sleep 7000
Wscript.Quit
End If

strOOOMessage = InputBox(“Please enter Out-Of-Office message…”)

objMAPISession.OutOfOfficeText = strOOOMessage
objMAPISession.OutOfOffice = 1
strOOOMessage = objMAPISession.OutOfOfficeText

objMAPISession.Logoff
Set objMAPISession = Nothing
MsgBox “All done”

 

Categories
VBScript

VBScript ; Enable Remote Desktop Remotely

VB Script Enable Remote Desktop Remotely

I recently came across the following useful script that will enable Remote Desktop connections (access via RDP) on a remote server as long as you have permission to do so with your current logon credentials.

The script below will function on both Windows Server 2000 and Windows Server 2003 machines.

‘———————————————————–
strComputer = InputBox (“Enter Machine Name”)
Set objWMIService = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!” & strComputer & “\root\cimv2”)Set colTSSettings = objWMIService.InstancesOf(“Win32_TerminalServiceSetting”)
For Each colTS in colTSSettings
colTS.SetAllowTSConnections(1)
Wscript.Echo UCase(strComputer) & ” Remote Desktop Is Now Enabled”
Next
‘———————————————————–‘,
Categories
VBScript

VBScript ; Create Active Directory Organisational Unit (OU)

VB Script Create Active Directory Organisational Unit (OU) – ADSI

Another useful time-saving tip when deploying a new Active Directory Tree.It is possible to script the creation of all Organisational Units in the Active Directory Tree using vbscript. This can save a great deal of time when it comes to the deployment of a new domain.

The following script will create a tree as follows: yourdomain.com > Sites – {new Top Level OU} > UK – {new sub-OU}

It will then create sub-OUs for each site listed in the object arrOus.

Site names must be seperated by a semi-colon (;)

For each Site sub-OU created a Users container and Computers container will be created.Again, the script is simple to modify for your environment.
 
‘—————————————–
Dim objRoot, objDomain, objOU, arrOUsDim strOUContainerDim intUser
 
Set oRoot = GetObject(“LDAP://rootDSE”)
oDomain = oRoot.Get(“defaultNamingContext”)
Set oDomain = GetObject(“LDAP://” & oDomain)strOUContainer =”OU=Sites”
Set objOU = objDomain.Create(“organizationalUnit”, strOUContainer)
objOU.SetInfostrOUContainer =”OU=UK,OU=Sites”
Set objOU = objDomain.Create(“organizationalUnit”, strOUContainer)
objOU.SetInfo
 
arrOUs = “Belfast;Birmingham;Bristol;Chessington;Dublin;Glasgow;Greenwich”arrOUs = Split(arrOUs,”;”)
 
For Each ou in arrOUs
        strOUContainer =”OU=” & ou & “,OU=UK,OU=Sites”
        Set objOU = oDomain.Create(“organizationalUnit”, strOUContainer) objOU.SetInfo strOUContainer =”OU=Users,OU=” & ou & “,OU=UK,OU=Sites” ‘
 
        ‘On Error Resume next
        Set objOU = oDomain.Create(“organizationalUnit”, strOUContainer)
        objOU.Put “Description”, “User Object Organisational Unit”
        objOU.SetInfo
        WScript.Echo “New OU created = ” & strOUContainer strOUContainer =”OU=Computers,OU=” & ou & “,OU=UK,OU=Sites” ‘
 
        Set objOU = oDomain.Create(“organizationalUnit”, strOUContainer)
        objOU.Put “Description”, “Computer Object Organisational Unit”
        objOU.SetInfo
        WScript.Echo “New OU created = ” & strOUContainer
Next’
‘—————————-

 The script has been tested on Windows Server 2000 and 2003 Domains.

Categories
VBScript

VBScript ; List All Processes On Remote Computer

VBScript list all processes on remote computer

VB Script to echo all processes running on a remote system, including the process path@

strComputer = “computer_name”
Set objWMIService = GetObject(“WinMgmts:” & “{impersonationLevel=impersonate}!” & strComputer & “\\\\root\\\\cimv2”) \r\n
Set colProcesses = objWMIService.ExecQuery (“Select * from Win32_Process”)
i=0
For Each objProcess in colProcesses
ProcessID = objProcess.ProcessID
Wscript.echo objProcess.ExecutablePath i=i+1
Next