Showing posts with label Scripts. Show all posts
Showing posts with label Scripts. Show all posts

Wednesday, March 25, 2009

RPC OVER HTTPS SCRIPT

I have received  many inquiries in regards to RPC over HTTPS script over months, and to be honest I am very happy many people found the script very easy to use.

I finally decided to put it on the sky ready for those who needs to download the script, please don't forgot to leave some comment which is all ask for smile_omg

Click here to get it,

RPCScript

Oz Casey Dedeal

MVP (Exchange)

MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +

Blog: http://www.smtp25.blogspot.com

Monday, February 23, 2009

Add AD group to local administrator Group on every workstation




Task:

Your Company hired couple people to perform hardware refresh on all the workstations and you need to create group called "Local_Admins" and include& configure this group into each workstation " local administrator gorup" in your active directory domain.

The task can be accomplish in different ways and I am going to post two of them here in my blog.

Batch file,

Place same directory as VB script below. The below simple batch file will add the group called "Local_Admins" into local administrators group.

net localgroup administrators "smtp25\local_Admins" /add

net localgroup administrators "smtp25\Local_Admins" /delete


VBScript

Copy and paste below into notepad

Please pay attention you only need to change two lines in below script,

  • Change below to your own domain, my domain name is smtp25.org
  • MyDomain = "smtp25.org"
  • ' Change group name to your desired group
  • GlobalGroup = "Local_Admins"


'VBScript to Add an AD Group to a Local Administrators group

' This script will Add an Active Directory Desktop support Group to the Local

' Administrator Group. this can be Used to provide Local Administrator rights

' to any group

' Script modified by oz ozugurlu, change anything you like , no copy rights

Option Explicit

On Error Resume Next

'Define Variables

Dim Mydomain

Dim GlobalGroup

Dim oDomainGroup

Dim oLocalAdmGroup

Dim oNet

Dim sComputer

Set oNet = WScript.CreateObject("WScript.Network")

sComputer = oNet.ComputerName

' Change below to your own domain, my domain name is smtp25.org

MyDomain = "smtp25.org"

' Change group name to your desired group

GlobalGroup = "Local_Admins"

Set oDomainGroup = GetObject("WinNT://" & MyDomain & "/" & GlobalGroup & ",group")

Set oLocalAdmGroup = GetObject("WinNT://" & sComputer & "/Administrators,group")

oLocalAdmGroup.Add(oDomainGroup.AdsPath)

'Nullify Variables

Set Mydomain = Nothing

Set GlobalGroup = Nothing

Set oDomainGroup = Nothing

Set oLocalAdmGroup = Nothing

Set oNet = Nothing

Set sComputer = Nothing

  • Save the script as "Add_Local_Admins.vbs"
  • Log onto your domain controller, click start run type "gpmc.msc"
  • Locate the OU you wish to apply this script too
  • Create a GPO in this domain and link it here , give it a name to the GPO "Add_Local_Admins"
  • Make a right click, select add , expend Computer configurations
  • Policies, windows settings scripts , double click startup, click add , click Browse
  • **** Copy and paste the script into this location*****
  • Select the script , click okay two time exit.
  • Now make sure the computers are located under this OU
  • Next time computers start the GPO will run the script and specified group will be added to the local administrators group on the workstations

Oz Ozugurlu
MVP (Exchange)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
Blog: http://www.smtp25.blogspot.com



Monday, October 6, 2008

RPC over HTTPS Script



This script will help you to configure your outlook (2003 and 2007) for RPC over HTTPS. It is very easy and requires no scripting knowledge at all. This is one of most asked question, how to make the RPC/HTTP configuration transparent to user?

So I asked one of my friends to write/Modify a script for this purpose. Here is the script below if works like a charm and very easy to modify and I will walk you through step by step.

Complements and credits goes to Gene Strickland, rest is for me (-: , I took the article out , just e-mail me I will send you the script and the notes showing how to mdify it, real simple


--Oz Ozugurlu

MVP (Exchange) MCITP (EMA),

MCITP (SA) MCSE 2003, M+, S+,

MCDST, Security+, Project +, Server +

Blog: http://www.smtp25.blogspot.com



Monday, January 28, 2008

Exchange White Space Script 1221



There are many scripts available to determine the whitespace on exchange server. Here is another one very simple. All you need to do it to copy and paste below code into notepad, and save it as any name you want, I renamed it "ExchangeWhiteSpaceReport.vbs" and save it to anywhere you want and just run it by double clicking on it. The Script will create a folder on your C drive as follows

Const TEMP_FILE = "C:\scripts\whitespace.txt

Only thing need to be changed it the server name, my server name is as follows rcoevschi001, change this to your own server name

arrComputers = Array("rcoevschi001")

Const TEMP_FILE = "C:\scripts\whitespace.txt"

Const ForWriting = 2

Dim strInput, fso

Set fso = CreateObject("Scripting.FileSystemObject")

Set filDest = fso.OpenTextFile(TEMP_FILE, ForWriting, True)

For Each strComputer In arrComputers

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile='Application' and Eventcode = '1221'")

For each objEvent in colItems

strMessage = objEvent.Message

StartWhiteSpaceDBName = Instr(1,strMessage,"database",1)

EndWhiteSpaceDBName = Instr(1,strMessage,"has",1)

ReturnDBNameLength = ((EndWhiteSpaceDBName-1)-(StartWhiteSpaceDBName+9))

strWSDB = Mid(strMessage,(StartWhiteSpaceDBName+9),(ReturnDBNameLength))

StartWhiteSpaceSize = Instr(1,strMessage,"has",1)

EndWhiteSpaceSize = Instr(1,strMessage,"megabytes",1)

ReturnSizeLength = ((EndWhiteSpaceSize-1)-(StartWhiteSpaceSize+4))+10

strWSSize = Mid(strMessage,(StartWhiteSpaceSize+4),(ReturnSizeLength))

dtmEventDate = objEvent.TimeWritten

strWSTime = WMIDateStringToDate(dtmEventDate)

strOutput = strWSTime & "," & strComputer & "," & strWSDB & "," & strWSSize

filDest.WriteLine strOutput

Next

Next

filDest.Close

Function WMIDateStringToDate(dtmEventDate)

WMIDateStringToDate = CDate(Mid(dtmEventDate, 5, 2) & "/" & Mid(dtmEventDate, 7, 2) & "/" & Left(dtmEventDate, 4) )

End Function


 

Thanks,

Oz ozugurlu

MCITP (EMA), MCITP (SA),

MCSE (M+, S+) MCDST

Security+, Server +, Project+

Thursday, August 16, 2007

Mail-Box Count Script

Below is a nice script to run against your exchange server and get the count of mailboxes, users and size of the mailboxes. You don't have to know scripting at all to make this work. Follow the steps I am listing below, of course I got it from a coworker.

  • Copy and paste the entire code into notepad
  • Change the server name, into your server name (ServerList = Array("server1", "server2", "server3")
  • Save the file on your Hard drive as mailboxCount.vbs ( c:\ mailboxCount.vbs)
  • Now go to command line
  • Drill down to same directory ( c:\ mailboxCount.vbs)
  • Run the file by typing, c:\ mailboxCount.vbs


 

Option Explicit

On Error Resume Next

Dim ServerList        ' List of computers to check

Dim server            ' Current computer to check

Dim fso                ' File System Object

Dim strWinMgmts            ' Connection string for WMI

Dim objWMIExchange        ' Exchange Namespace WMI object

Dim listExchange_Mailboxs    ' ExchangeLogons collection

Dim objExchange_Mailbox        ' A single ExchangeLogon WMI object

Dim logfile            ' Output file

Const cWMINameSpace = "root/MicrosoftExchangeV2"

Const cWMIInstance = "Exchange_Mailbox"

Const LOG_FILE = "EMailSize.csv"

'--------------------------------------

' Set up the array of email servers

'--------------------------------------

ServerList = Array("server1", "server2", "server3")

'--------------------------------------

' Set up log file

'--------------------------------------

set fso = CreateObject("Scripting.FileSystemObject")

Set logfile = fso.CreateTextFile(LOG_FILE)

logfile.WriteLine("""Display Name"",""Mailbox Size"",""Mailbox TotalItems"",""Mailbox StoreName"",""Mailbox ServerName""")

' Create the object string, indicating WMI (winmgmts), using the

' current user credentials (impersonationLevel=impersonate),

' on the computer specified in the constant cComputerName, and

' using the CIM namespace for the Exchange provider.

WScript.Echo "Starting now"

'The rest of the script will fetch mailbox sizes for our servers. Mailbox sizes are in Kilobytes.

For Each server in ServerList

    WScript.Echo "Starting " & server & " search."

    strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//" & server & "/" & cWMINameSpace

    'WScript.Echo strWinMgmts

    

    Set objWMIExchange = GetObject(strWinMgmts)

    ' Verify we were able to correctly set the object.

    If Err.Number <> 0 Then

        WScript.Echo "ERROR: Unable to connect to the WMI namespace."

    Else

        'The Resources that currently exist appear as a list of

        'Exchange_Mailbox instances in the Exchange namespace.

        Set listExchange_Mailboxs = objWMIExchange.InstancesOf(cWMIInstance)

        ' Were any Exchange_Mailbox Instances returned?

        If (listExchange_Mailboxs.count > 0) Then

            ' If yes, do the following:

            ' Iterate through the list of Exchange_Mailbox objects.

            For Each objExchange_Mailbox in listExchange_Mailboxs

                ' Display the value of the Size property.

                logfile.WriteLine("""" & objExchange_Mailbox.MailboxDisplayName & """,""" & objExchange_Mailbox.Size & """,""" & objExchange_Mailbox.TotalItems & """,""" & objExchange_Mailbox.StoreName & """,""" & objExchange_Mailbox.ServerName & """")

            Next

        Else

            ' If no Exchange_Mailbox instances were returned, display that.

            WScript.Echo "WARNING: No Exchange_Mailbox instances were returned."

        End If

    End If

Next

Wscript.Echo "Completed"


 

Best Regards

Oz Ozugurlu