Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Saturday, February 14, 2009

How Long Until My Password Expires?

How Long Until My Password Expires?

On Error Resume Next




Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D

Const ONE_HUNDRED_NANOSECOND = .000000100

Const SECONDS_IN_DAY = 86400



Set objUser = GetObject("LDAP://CN=myerken,OU=management,DC=fabrikam,DC=com")



intUserAccountControl = objUser.Get("userAccountControl")

If intUserAccountControl And ADS_UF_DONT_EXPIRE_PASSWD Then ' LINE 11

WScript.Echo "The password does not expire."

WScript.Quit

Else

dtmValue = objUser.PasswordLastChanged

If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then ' LINE 16

WScript.Echo "The password has never been set."

WScript.Quit

Else

intTimeInterval = Int(Now - dtmValue)

WScript.Echo "The password was last set on " & _

DateValue(dtmValue) & " at " & TimeValue(dtmValue) & vbCrLf & _

"The difference between when the password was last" & vbCrLf & _

"set and today is " & intTimeInterval & " days"

End If



Set objDomain = GetObject("LDAP://DC=fabrikam,DC=com")

Set objMaxPwdAge = objDomain.Get("maxPwdAge")



If objMaxPwdAge.LowPart = 0 Then

WScript.Echo "The Maximum Password Age is set to 0 in the " & _

"domain. Therefore, the password does not expire."

WScript.Quit

Else

dblMaxPwdNano = _

Abs(objMaxPwdAge.HighPart * 2^32 + objMaxPwdAge.LowPart)

dblMaxPwdSecs = dblMaxPwdNano * ONE_HUNDRED_NANOSECOND ' LINE 37

dblMaxPwdDays = Int(dblMaxPwdSecs / SECONDS_IN_DAY) ' LINE 38

WScript.Echo "Maximum password age is " & dblMaxPwdDays & " days"



If intTimeInterval >= dblMaxPwdDays Then

WScript.Echo "The password has expired."

Else

WScript.Echo "The password will expire on " & _

DateValue(dtmValue + dblMaxPwdDays) & " (" & _

Int((dtmValue + dblMaxPwdDays) - Now) & " days from today)."

End If

End If

End If

Saturday, January 24, 2009

"Installing Dell OpenManage in a VMware ESX Server Software Environment". -PDF

If you've never installed OMSA on ESX, don't start with this script ! Read this piece of documentation first, "Installing Dell OpenManage in a VMware ESX Server Software Environment". Then once you have a grasp of the steps necessary, you can use this script that will install and configure the OMSA agent on VMware ESX 3.x. It will also configure the SNMP settings, and open the default ports in the firewall to allow communication.

Tuesday, January 6, 2009

What happens if two AD objects have the same RDN?

Every Active Directory (AD) object has a distinguished name (DN—e.g., CN=John Savill,CN=Users,DC=SavillTech,DC=Com) that uniquely identifies the object and its position in AD. The system also creates a relative distinguished name (RDN), which is a name relative to the container (e.g., CN=John Savill for the user).
Two objects with the same RDN can't exist in one container. For example, in the container CN=Users,DC=SavillTech, CN=John Savill and OU=John Savill are allowed because one is a user and the other is an organisational unit (OU). However, CN=John Savill and CN=John Savill aren't allowed.

The only way you can have a duplicate RDN is if two objects are created on different domain controllers (DCs). But at the next replication cycle, the system will rename the older object.


To find objects that the system has renamed because of RDN collisions, use the search.vbs script in \support\tools\support.cab as follows:

cscript search.vbs "LDAP:///dc=,dc=com" 
/C:"(CN=*\0ACNF:*)" /P:distinguishedName /S:SubTree 
Any matches will display the RDN for the renamed objects.

Script Gathers Scheduled Task Information

Script Gathers Scheduled Task Information

WMI Bulk data retrieval

Free Utility Lets You Retrieve a Little or a Lot of Inventory Information

System Inventory Mini-App Use this easily customizable script to document deployed computers or check out the health of a system

Saturday, December 13, 2008

ldap queries

the basics

LDAP Search Samples for Windows Server 2003 and Exchange 2000/2003

Active Directory Users and Computers Saved Queries - Ron Crumbaker ...
Active Directory Saved Queries Templates

Ldp Examples msdn


LDAP Attributes from Active Directory Users and Computers petri

Tracing LDAP calls with Powershell




Set MyUser = GetObject ("LDAP://GCName /CN=Administrator,CN=Users,DC=sunnydale,DC=muni")


You may also query only GCs by using the GC:// notation as follows:
Set MyUser = GetObject ("GC://GCName /CN=Administrator,CN=Users,DC=sunnydale,DC=muni")
You can also set properties for an object.
Set MyUser = GetObject ("LDAP://CN=Administrator,CN=Users,DC=sunnydale,DC=muni")
MyUser.msExchHideFromAddressLists = True
MyUser.SetInfo

Thursday, December 4, 2008

shares group has access

DumpSec v2.8.6 

SomarSoft's DumpSec is a security auditing program for Microsoft Windows® NT/XP/200x. It dumps the permissions (DACLs) and audit settings (SACLs) for the file system, registry, printers and shares in a concise, readable format, so that holes in system security are readily apparent. DumpSec also dumps user, group and replication information. 


get server name

enumerate shares

fore each share

Dump all NTFS file permissions, printer permissions, share permissions to a db.


enumerate service accounts

Clean Up After Terminated Windows Administrators


Enumerate Service Accounts from jeff hick's scripts

Change passwords on service accounts. 


Listing 15.21 Changing a Service Account Password









Script to Audit Service Accounts




If you keep getting request to create multiple (service) accounts in AD , you got to think what PowerShell can do for this task. 
================================= scripts ================
 Go to a command line and type:
dsquery user -desc *service account* > serviceaccounts.txt

or

dsquery user -desc *service account* | dsget user -samid -desc
(Where | is shift-\)

*************************








Open Active Directory Users and Computers
Right-click Saved Queries
Select New, Query
Give it a name like "service accounts"
Click Define Query
Select Users, Contacts and Groups in Find box
Click Advanced tab
Click Field button
Select User, Description
Type *service account* in the value field
Click Add
Click OK
Now that you have a list, you can drag and drop these accounts into a new OU.

*********************************

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
 
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
 
Set objRootDSE = GetObject("LDAP://RootDSE")
 
objCommand.CommandText = _
 " & objRootDSE.Get("defaultNamingContext") & ">;" & _
 "(&(objectCategory=person)(objectClass=user)(description=*service account*));" & _
 "displayName,distinguishedName;subtree"
 
Set objRecordSet = objCommand.Execute
 
strResults = """Display Name"",""Distinguished Name"""
If objRecordset.EOF Then
        Wscript.Echo "No user accounts found."
Else
        While Not objRecordset.EOF
                strResults = strResults & VbCrLf & """" & objRecordset.Fields("displayName") & """,""" & objRecordset.Fields("distinguishedName") & """"
                objRecordset.MoveNext
        Wend
End If
 
objConnection.Close
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("Results.csv", True)
objFile.Write strResults
objFile.Close
Set objFile = Nothing
 
MsgBox "Done. Please see Results.csv"



Wednesday, November 26, 2008

Microsoft Script Editor

If you are on a machine that does not have a professional script editor, like primalScript, you can use the Microsoft Script Editor which is part of office


Search for mse7.exe for its location based on the version of office being used

Wednesday, November 12, 2008

project - exchaneg automation

  • create a 15 element samacctIndex array and populate with 0
  • remove spaces from last name - use regx
    • combine 1st letter of frist name with revised last name -samacctMain
  • search 4 all samacctMain
    • 4 each samacctMain use regex 2 strip samacctIndex
      • put samacctIndex in samacctIndex(samacctIndex) element replacing 0
    • search 4 first 0 in samacctIndexarray the element # will become the samacctIndex
    • combine samacctMain+samacctIndex = samacctName
    • destroy & recreate a 15 element samacctIndex array and populate with 0
admin ou & groups

  • get all users with admin loc codes
    • ou they're in
      • groups they're in
      • other qualifiers i.e department responsibility
    • look 4 coreolation



HOW TO: Reconnect a mailbox to another user

VBScript to create a large number of mailbox-enabled user accounts

sorting excel data via VBA
sort method doc
Using VBA to Sort Data on Multiple Sheets
Sorting Cells using VBA
subroutine which will sort the active worksheet by first column, then remove any duplicates
re-sorts a named range when data is added

replace a user acct ctrl-F

Sorting a Range using VBA - Excel Help Forum

The Recipient Update Service and Linked Value Replication

Select a Product Advanced SearchHow to work with the Exchange Recipient Update Service

How to Manually Update the Recipient Update Service via script

Creating Exchange Users with Excel (Part 1)


exchange Management & Administration Articles

The SelfADSI Tutorial introduces administrators to the scripting in Active Directory environments and other LDAP directory systems. The aim is to understand and being able to develop directory scripts without having specific previous knowledge in ADS or LDAP. Preferred scripting language is Visual Basic Script (VBScript). ADS scripting / LDAP scripting is easy - learn it with SelfADSI.

The minimum attributes needed for RUS are mailNickname (Exchange Alias) and msExchHomeServerName

In this section of the SelfADSI Scripting tutorial the Exchange 2000/Exchange 2003 attributes of an Active Directory Services object will be described. These AD attributes and the additional tabs in the admin utility are only visible if Exchange has been installed in the Active Directory forest and if the according management tools exist on your machine - and if the regarding object is mail enabled.

http://www.microsoft.com/technet/scriptcenter/scripts/message/default.mspx?mfr=true

Alphabetical list of AD attributes


SelfADSI tutorial according "Creating mail enabled users".

A User Comes and a User Goes


http://www.petri.co.il/creating_exchange_users_with_excel.htm



http://msdn.microsoft.com/en-us/library/aa221612(office.11).aspx



http://msdn.microsoft.com/en-us/library/aa221357(office.11).aspx



http://www.ozgrid.com/



http://digiassn.blogspot.com/2006/01/multiple-row-selection-in-excel-vba.html

getting married

http://forums.msexchange.org/m_1800465423/tm.htm

http://forums.msexchange.org/m_180041600/tm.htm

http://forums.msexchange.org/m_1800412283/tm.htm

http://forums.msexchange.org/m_10075700/tm.htm



what is your recipient policy.

Sunday, October 26, 2008

user account automation

Accessing E-mail Addresses

Removing duplicate and unwanted proxy addresses in Exchange

vbscript example

 export - inport email addresses

example2

 example3

add a new Proxy Address to all the users in active directory





===============================================

 
dim oRootOU
dim oUser
dim oProxy
Set oRootOU = GetObject("LDAP://dc=com/dc=georgfischer/dc=ad/dc=piping/ou=test")

for each oUser in oRootOU
if oUser.class = "user" then
for each oProxy in oUser.ProxyAddresses
if instr(oProxy,"Gwise:gf.rlssh") then oUser.msExchHideFromAddressLists = TRUE
next
end if
next

set oRootOU = nothing

======================

Checking ProxyAddresses for Duplicates

Originally published December 30, 2004

Today I needed to know if all of my proxyaddresses (that is, the entries on the “E-Mail Addresses” tab in Active Directory Users and Computers) were unique.
ADU&C prevents you from entering a duplicate manually, but it's possible for a script or for the RUS to generate a duplicate under certain situations.
So, I wrote a script. There are several ways to attack this problem,  including using adfind and adcsv (which Joe Richards has done) but I wanted a vbscript solution.
My solution is below. It can easily be modified to dump all of your addresses as well.
Option Explicit
Dim strDomainDN, strBase, strFilter, strAttrs, strScope
Dim objDIC
Dim objCmd, objConn, objRS
Dim proxyaddresses, proxyaddress
Dim iCount
strDomainDN = "dc=brnets,dc=int"
strBase   =  ";"
strFilter = "(proxyAddresses=*);"
strAttrs  = "name,adspath,proxyaddresses;"
strScope  = "subtree"
Set objDIC = CreateObject ("Scripting.Dictionary")
Set objConn = CreateObject ("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objCmd = CreateObject ("ADODB.Command")
objCmd.ActiveConnection = objConn
objCmd.CommandText = strBase & strFilter & strAttrs & strScope
objCmd.Properties ("Page Size") = 1000
Set objRS = objCmd.Execute
objRS.MoveFirst
while Not objRS.EOF
 'Wscript.Echo "name = " & objRS.Fields(0).Value
 'wscript.echo "adspath = " & objRS.Fields(1).Value
 proxyaddresses = objRS.Fields(2)
 for each proxyaddress in proxyaddresses
  proxyaddress = LCase (proxyaddress)
  If objDic.Exists (proxyaddress) Then
   objDic.Item (proxyAddress) = objDic.Item (proxyAddress) & "|" & objRS.Fields(1).Value
   wscript.echo "Dup: " & objDic.Item (proxyAddress)
   iCount = iCount + 1
  Else
   objDic.Add proxyAddress, objRS.Fields(1).value
  End If
 next
 'wscript.echo
 objRS.MoveNext
wend
wscript.echo "Total unique addresses found: " & objDic.Count
If iCount = 0 Then
 Wscript.Echo "No dups found."
Else
 Dim objArr, objIt, strVals
 wscript.echo iCount & " dups found."
 objArr = objDic.Keys
 For Each objIt in objArr
  strVals = objDic.Item (objIt)
  If Instr (strVals, "|") > 0 Then
   Dim arrNames, strName
   arrNames = Split (strVals, "|")
   wscript.echo objIt
   For each strName in arrNames
    wscript.echo vbTab & strName
   Next
  End If
 Next
End If
wscript.quit 0

Thursday, July 17, 2008

omatics

Building an Exchange-O-Matic

PowerShell Scriptomatic has other helpful features you can read about in the PowerShell Scriptomatic Web page. This page also includes a link to download the tool.

In case you're interested in the other -omatic utilities, here's what they do and where you can find information about them:
Scriptomatic 2.0 is a utility for writing WMI scripts using VBScript, JScript, Perl, or Python. For write-ups about this utility, check out the articles "Automate Tasks with Scriptomatic" (InstantDoc ID 45316), "Rem: Scriptomatic 2.0 Is Worth the Wait" (InstantDoc ID 44334), "Take Advantage of Scriptomatic 2.0 to Maximize Your WMI Scripting Efforts" (InstantDoc ID 44360), and "Scrutinizing Scriptomatic" (InstantDoc ID 44300). Note that there is also the WMI Code Creator tool for generating VBScript, C#, and Visual Basic .NET code that performs WMI management tasks.
ADSI Scriptomatic is a utility for writing Active Directory Service Interfaces (ADSI) scripts in VBScript.
HTA Helpomatic is a utility for writing HTML Applications (HTAs) that you can use to provide GUIs for scripts. HTA Helpomatic's sample code is in VBScript and HTML.
Tweakomatic is a utility that helps you use WMI to write scripts that retrieve and configure Windows and Microsoft Internet Explorer (IE) registry settings.