sms 2003 _ sccm 2007_ sccm _ sms vbscript

23
Tuesday, June 15, 2010 script that has WMI connection error will skip it and move to next strComputer = "MYcomputername" Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add intRow = 2 objExcel.Cells(1, 1).Value = "Logon Name" objExcel.Cells(1, 2).Value = "Full Name" objExcel.Cells(1, 3).Value = "Description" objExcel.Cells(1, 4).Value = "Domain" objExcel.Cells(1, 5).Value = "Password Changeable" objExcel.Cells(1, 6).Value = "Password Required" objExcel.Cells(1, 7).Value = "Password Expires" objExcel.Cells(1, 8).Value = "Account Disabled" objExcel.Cells(1, 9).Value = "Account Locked Out" On Error Resume Next Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") If err.Number <> 0 then Call Wscript.echo("Error has occurred connecting to WMI on workstation: " & strComputer) End if Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount") For Each objItem in colItems objExcel.Cells(intRow, 1).Value = objItem.Name Blog Archive 2010 (234) December (1) November (2) October (23) September (5) August (16) July (13) June (37) Microsoft Security Bulletin Minor Revisions All Available IMP Links for SCCM destination SMS 2003 Client Health : GP Based Script Below are the port Numbers used in SMS 2003 OSD Log Files Location Windows Update Explained RUN Command Tip’s List of log files with the description of each to ... SCCM Product released Dates SMS & ConfigMgr Support What Service Pack level required for Supporting Microsoft Desktop Optimization Pack (MDOP) HTTP 500 Internal Server Error when accessing SCCM... Below are the basic exceptional for any antivirus ... APP V ConfigMgr admin must aware of these ConfigMgr 2007 Super Flows IMP Downloads from MYITFORUM Central place script that has WMI connection error will skip it ... Excel output Script : for file version check well ... Send Activity in Inboxes ConfigMgr / SCCM Roles SCCM Roles Collection : For software distribution status if s... Collections based on software updates deployment s... SMS 2003 Patching : Pending for reboot collection One other best site to search for rapid links Compartir Informar sobre mal uso Siguiente blog» Crear un blog Acceder SMS 2003 & SCCM 2007 SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB... 1 of 23 14/12/2011 05:50 p.m.

Upload: mikecoso

Post on 31-Aug-2014

455 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Tuesday, June 15, 2010

script that has WMI connection error willskip it and move to nextstrComputer = "MYcomputername"

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

objExcel.Cells(1, 1).Value = "Logon Name"

objExcel.Cells(1, 2).Value = "Full Name"

objExcel.Cells(1, 3).Value = "Description"

objExcel.Cells(1, 4).Value = "Domain"

objExcel.Cells(1, 5).Value = "Password Changeable"

objExcel.Cells(1, 6).Value = "Password Required"

objExcel.Cells(1, 7).Value = "Password Expires"

objExcel.Cells(1, 8).Value = "Account Disabled"

objExcel.Cells(1, 9).Value = "Account Locked Out"

On Error Resume NextSet objWMIService = GetObject("winmgmts:\\" &strComputer & "\root\cimv2")If err.Number <> 0 then Call Wscript.echo("Error has occurredconnecting to WMI on workstation: " &strComputer)End if

Set colItems = objWMIService.ExecQuery("Select * fromWin32_UserAccount")

For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = objItem.Name

Blog Archive▼ 2010 (234)

► December (1)

► November (2)

► October (23)

► September (5)

► August (16)

► July (13)

▼ June (37)

Microsoft Security Bulletin MinorRevisions

All Available IMP Links for SCCMdestination

SMS 2003 Client Health : GP BasedScript

Below are the port Numbers used inSMS 2003

OSD Log Files Location

Windows Update Explained

RUN Command Tip’s

List of log files with the descriptionof each to ...

SCCM Product released Dates

SMS & ConfigMgr Support

What Service Pack level required forSupporting

Microsoft Desktop Optimization Pack(MDOP)

HTTP 500 Internal Server Error whenaccessing SCCM...

Below are the basic exceptional forany antivirus ...

APP V

ConfigMgr admin must aware of these

ConfigMgr 2007 Super Flows

IMP Downloads from MYITFORUMCentral place

script that has WMI connection errorwill skip it ...

Excel output Script : for file versioncheck well ...

Send Activity in Inboxes

ConfigMgr / SCCM Roles

SCCM Roles

Collection : For software distributionstatus if s...

Collections based on softwareupdates deployment s...

SMS 2003 Patching : Pending forreboot collection

One other best site to search forrapid links

Compartir Informar sobre mal uso Siguiente blog» Crear un blog Acceder

SMS 2003 & SCCM 2007

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

1 of 23 14/12/2011 05:50 p.m.

Page 2: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

objExcel.Cells(intRow, 2).Value = objItem.FullName

objExcel.Cells(intRow, 3).Value = objItem.Description

objExcel.Cells(intRow, 4).Value = objItem.Domain

If objItem.PasswordChangeable = True Then

objExcel.Cells(intRow, 5).Value = "Yes"

objExcel.Cells(intRow, 5).Font.ColorIndex = 10

Else

objExcel.Cells(intRow, 5).Value = "No"

objExcel.Cells(intRow, 5).Font.ColorIndex = 3

End If

If objItem.PasswordRequired = True Then

objExcel.Cells(intRow, 6).Value = "Yes"

objExcel.Cells(intRow, 6).Font.ColorIndex = 10

Else

objExcel.Cells(intRow, 6).Value = "No"

objExcel.Cells(intRow, 6).Font.ColorIndex = 3

End If

If objItem.PasswordExpires = True Then

objExcel.Cells(intRow, 7).Value = "Yes"

objExcel.Cells(intRow, 7).Font.ColorIndex = 10

Else

objExcel.Cells(intRow, 7).Value = "No"

objExcel.Cells(intRow, 7).Font.ColorIndex = 3

End If

If objItem.Disabled = True Then

objExcel.Cells(intRow, 8).Value = "Yes"

objExcel.Cells(intRow, 8).Font.ColorIndex = 10

Else

objExcel.Cells(intRow, 8).Value = "No"

objExcel.Cells(intRow, 8).Font.ColorIndex = 3

End If

If objItem.Lockout = True Then

objExcel.Cells(intRow, 9).Value = "Yes"

objExcel.Cells(intRow, 9).Font.ColorIndex = 10

Where MS going?

TO GET THE USER STATUS : Guestaccount status

Sysprep parameters

Join the computer silently to theDomain

Batch file for loop in other way

It's Microsoft Patch Tuesday: June2010

DNS Bulk ADD

FIND Collections and it’s Name in theconsole SQL ...

Sample Prompt option for Collection

► May (25)

► April (40)

► March (30)

► February (26)

► January (16)

► 2009 (121)

► 2008 (123)

► 2004 (1)

LabelsActive Directory (3)Anti Virus (1)APP-V (2)Asset Intelligence (11)Backup Recovery (2)Batch files (2)cbts (1)Client Health (3)Collections (14)DCM (11)Discovery (1)DP - BDP (1)Draft (1)End to End (37)Extra Tools / Softwares (12)Genaral Windows (14)GroupPolices (1)Hardware (1)Hyer V (2)IBM (1)inventory (1)Limitation (1)loginscript (1)mdop (1)MED-V (1)MP (5)MY Notes (94)MY Vbscripts (12)Native Mode (5)OBT (1)OSD (22)others (8)PatchManagement (22)Personal / Free Time (7)PORT NUMBERS (1)PowerShell (10)R3 (2)Reporting Services (1)SCCM - Accounts (1)

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

2 of 23 14/12/2011 05:50 p.m.

Page 3: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Else

objExcel.Cells(intRow, 9).Value = "No"

objExcel.Cells(intRow, 9).Font.ColorIndex = 3

End If

intRow = intRow + 1

Next

objExcel.Range("A1:I1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

MsgBox "Done"

at 10:12 PM 0 commentsLabels: MY Notes, MY Vbscripts, SCCM / SMS VBScript, SCCM 2007

Saturday, May 8, 2010

'Below script to create number ofcomputers in AD--for testing'Below script to create number of computers in AD--for testing

'=============================================================================='' Description: This script creates multiple sequential computer accounts' in an AD OU. It appends a 3 digit number to the base name starting with' the number entered at the prompt.'==============================================================================Option Explicit'Define ConstantsConst ADS_SCOPE_ONELEVEL = 1'Declare VariablesDim DQDim strAdminDim intRecordDim objShellDim objNetworkDim intWarnDim objRootDSEDim strADsPathDim objConnectionDim objCommandDim strOUPathDim objRecordSetDim strBaseNameDim intRecordMaxDim bEnabled

SCCM / SMS VBScript (24)SCCM 2007 (313)SCCM Client Deployment (84)SCCM Conole (1)SCCM Designing Requests (4)SCCM Reports (66)Senders (2)site code (1)SMS 2003 (6)SMS Installer (1)Software Distrubution (7)SQL Queries (44)SRS (1)SuperFlow (1)SYSPREP (2)System Center Family (2)Task Sequence - TS (1)Test (1)trainings (2)Troubleshooting (4)Virtual App (2)Virtual LAbs (2)VPro (1)Windows 2008 (68)Windows Installer (1)WMI (2)WOL (13)Workgroup (1)WQL (7)wsus (1)

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

3 of 23 14/12/2011 05:50 p.m.

Page 4: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Dim objOUDim strNewComputerNameDim objNewComputerDim strDomainDNDim strDomainFQDNDim intOULevelDim strSearchADsPathDim intStartNumber'Set variablesDQ = Chr(34)'Create ObjectsSet objShell = CreateObject("Wscript.Shell")Set objNetwork = CreateObject("WScript.NetWork")'Verifies script was run using Cscript, and if not relauches it using CscriptIf Not WScript.FullName = WScript.Path & "\cscript.exe" Then

objShell.Popup "Relaunching script with Cscript in 5 seconds...", 5, _"Script Host Message", 48

objShell.Run "cmd.exe /k " & WScript.Path & "\cscript.exe //NOLOGO " &_DQ & WScript.scriptFullName & DQ, 1, False

Script.Quit 0End If

'Warn UserintWarn = MsgBox("This will make changes to AD." & VbCr & _"Are you sure you want to do this?", 308, "ID 10 T Check")'308 = Yes/No (4) + 'Exclaimation (48) + Default Button 2 (256)If intWarn = vbNo Then

WScript.Quit 0End If'Construct an ADsPath to the Current Domain with rootDSESet objRootDSE = GetObject("LDAP://rootDSE")strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext")'Convert domain Distinguished Name to FQDN formatstrDomainDN = objRootDSE.Get("defaultNamingContext")strDomainFQDN = Replace(Replace(strDomainDN, "DC=", ""), ",", ".")'Connect to Active DirectorySet objConnection = CreateObject("ADODB.Connection")Set objCommand = CreateObject("ADODB.Command")objConnection.Provider = "ADsDSOObject"objConnection.Open "Active Directory Provider"Set objCommand.ActiveConnection = objConnectionobjCommand.Properties("Page Size") = 1000objCommand.Properties("Searchscope") = ADS_SCOPE_ONELEVEL'Prompt for Path to OUDo

strOUPath = _InputBox("Please enter the path to the OU where the computer accounts" & _" will be created - Seperate OUs With a \", "OU Path Input","TopOU\SubOU")If strOUPath = False ThenWScript.Quit

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

4 of 23 14/12/2011 05:50 p.m.

Page 5: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

End IfLoop Until strOUPath <> ""

'Split OU path by OUstrOUPath = UCase(strOUPath)strOUPath = Split(strOUPath, "\")

'Prepare variables for searchintOULevel = 0strSearchADsPath = strADsPath

'Search through each OU level in path providedFor intOULevel = 0 To UBound(strOUPath)

objCommand.CommandText = "SELECT ADsPath FROM '" &strSearchADsPath & _"'" & " WHERE objectCategory='organizationalUnit' AND Name = '" & _strOUPath(intOULevel) & "'"

Set objRecordSet = objCommand.Execute

'Verify OU was found

If objRecordSet.EOF Then

WScript.echo "OU named " & strOUPath(intOULevel) & _" not found, Exiting script."

WScript.quit

Else

objRecordSet.MoveFirstDo Until objRecordSet.EOFstrSearchADsPath = objRecordSet.Fields("ADsPath").ValueobjRecordSet.MoveNextLoopEnd IfNext'Get current username to use in description fieldstrAdmin = objNetwork.UserName'Prompt for the base computer nameDostrBaseName = _InputBox("Please enter the base computer name to use for newaccounts:", _"Base Computer Name", "TestPC")If strBaseName = False ThenWScript.QuitEnd IfLoop Until strBaseName <> ""strBaseName = UCase(strBaseName)'Prompt for starting computer numberDo

intStartNumber = _

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

5 of 23 14/12/2011 05:50 p.m.

Page 6: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

InputBox("Please enter the beginning number to use in computernames:", _"Starting Computer Number", "001")If intStartNumber = False Then

WScript.Quit

End IfLoop Until intStartNumber <> ""intStartNumber = CInt(intStartNumber)intRecord = intStartNumber'Prompt for number of accounts to be createdDo

intRecordMax = _InputBox("Please enter the number of accounts to be created", _"Count Input", "10")If intRecordMax = False Then

WScript.Quit

End IfLoop Until intRecordMax <> ""intRecordMax = CInt(intRecordMax)

'Bind to OU that computers will be created inSet objOU = GetObject(strSearchADsPath)

'Create the user accountsDo Until intRecord = intRecordMax + intStartNumberintRecord = Right("000" & intRecord, 3)strNewComputerName = strBaseName & intRecordWScript.Echo "Creating " & strNewComputerNameSet objNewComputer = objOU.Create("Computer", "cn= " &strNewComputerName)objNewComputer.Put "samAccountName", strNewComputerName & "$"objNewComputer.Put "userAccountControl", 4096objNewComputer.Put "description", "Account created: " & Date() & " by: "_& strAdminobjNewComputer.SetInfo 'Writes settings to ADintRecord = intRecord + 1Loop

WScript.EchoWScript.echo "Finished creating computer accounts."at 8:36 AM 0 commentsLabels: MY Notes, MY Vbscripts, SCCM / SMS VBScript

Tuesday, August 11, 2009

Collection of Computers based on Users

Collection of Computers based on Users

SMS has a nice feature that allows you to create a collection based on

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

6 of 23 14/12/2011 05:50 p.m.

Page 7: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

users. That way when a users logs into a computer SMS will then run anadvertisement for whatever computer they are on. The problem ismaybe you want to have a collection of computers not the users. Theworst flaw this the collection query I have created below and usingcollections based on users is that if a person logs in to another machine,for whatever reason, SMS will find them and push software to them.That in mind, here is a collection that will take any OU group of usersand create a collection of computers.

---------------------------------------selectSMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client from SMS_R_System inner joinSMS_G_System_COMPUTER_SYSTEM onSMS_G_System_COMPUTER_SYSTEM.ResourceID =SMS_R_System.ResourceId whereSMS_G_System_COMPUTER_SYSTEM.UserName in (selectUniqueUserName from SMS_R_User where UserOUName = "xxxx/SECURITY USERS & GROUPS" )--------------------------------------Windows User account and group discovery must be enabled and run onyour server to use this.

How does this work. It first grabs the list of users. Then matches them tothe comptuers that SMS currently sees them logged into. To change thisto Last Logged in user you need to change theSMS_G_System_Computer_System to SMS_R_System.LastLogonUserNamefor computers. This will give you last logged in user.

"Limit to Collection" for all your computer Workstations or further limitit to based on departments

If you don't know what group then you can create a query of just (selectUniqueUserName from SMS_R_User where UserOUName = "") click valuesuntil you have the value you need and paste it into the larger query.-------------------Thanks,http://sccm07.blogspot.com/

at 3:02 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007, SQL Queries

Tuesday, August 4, 2009

Creating 1000 User Accounts-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

--Creating 1000 User Accounts Set objRootDSE = GetObject("LDAP://rootDSE")

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

7 of 23 14/12/2011 05:50 p.m.

Page 8: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Set objContainer = GetObject("LDAP://cn=Users," & _ objRootDSE.Get("defaultNamingContext"))

For i = 1 To 1000 Set objLeaf = objContainer.Create("User", "cn=UserNo" & i) objLeaf.Put "sAMAccountName", "UserNo" & i objLeaf.SetInfoNext

WScript.Echo "1000 Users created." ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Creating an Active Directory UserAccount------------------------------------------------------------------------- Creates a user account in Active Directory. This script only creates theaccount, it does not enable it.

Set objOU = GetObject("LDAP://OU=management,dc=fabrikam,dc=com") Set objUser

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Creating a User, a Group, and an OU

Demonstration script that: 1) creates a new Active Directoryorganizational unit; 2) creates a new user account and new securitygroup; and, 3) adds the new user as a member of that security group.

Set objDomain = GetObject("LDAP://dc=fabrikam,dc=com") Set objOU = objDomain.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Deleting a User Account from Active Directory----------------------------------------------------------------------Deletes the user account for MyerKen from the HR organizational unit ina hypothetical domain named fabrikam.com.

Set objOU = GetObject("LDAP://ou=hr,dc=fabrikam,dc=com") objOU.Delete "user",

Determining When an Account Expires

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

8 of 23 14/12/2011 05:50 p.m.

Page 9: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Returns the expiration date for a user account.

On Error Resume Next Set objUser = GetObject _ ("LDAP://cn=myerken,ou=manag

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Determining When a Password Expires Determines the date when a user password will expire.

Const SEC_IN_DAY = 86400 Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000 Set objU

Determining When a Password was Last Set

Identifies the last time a user password was set.

Set objUser = GetObject _ ("LDAP://CN=myerken,OU=management,DC=Fabrikam,D

Determining User Account Status

Identifies whether a user account is enabled or disabled.

Set objUser = GetObject _ ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=

Determining When a User Account Expires

Reports the date that the MyerKen Active Directory user accountexpires.

On Error Resume Next Set objUser = GetObject _ ("LDAP://cn=MyerKen,ou=Man

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Moving a User Account

Moves a user account from one OU to another.

Set objOU = GetObject("LDAP://ou=sales,dc=na,dc=fabrikam,dc=com") objOU.MoveH

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Requiring a Password Change

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

9 of 23 14/12/2011 05:50 p.m.

Page 10: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Forces a user to change their password the next time they logon.

Set objUser = GetObject _ ("LDAP://CN=myerken,OU=management,DC=Fabrikam,D

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Retrieving User Account Account Properties

Retrieves user account attributes found on the Account page of the useraccount object in Active Directory Users and Computers.

On Error Resume Next Set objUser = GetObject _ ("LDAP://cn=myerken,ou=mana

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Unlocking an Active Directory User Account

Unlocks the MyerKen Active Directory user account.

Set objUser = GetObject _ ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabr

Enjoy,http://sccm07.blogspot.com/at 7:05 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007, SQL Queries

Using VBScript to PLAY with ActiveDirectory

Using VBScript to Export All Objects in the Marketing OU

In this example, you use a text editor such as Notepad to create aVBScript program. The script searches the Marketing OU and creates atext file that lists all of the user objects and a subset of their attributes.

To create the export script

Copy the following text into your text editor:

'Global variables Dim oContainer Dim OutPutFile Dim FileSystem 'Init

1.

Save the file as Export.vbs.2.

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

10 of 23 14/12/2011 05:50 p.m.

Page 11: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

At the command prompt type export.vbs and press Enter. Thiscreates a file named Marketing.txt, which contains a list of usersand some of their attributes, such as distinguished name, name,state, and street address.

3.

With appropriate modification, this script can be used with anyapplication that supports COM and Visual Basic technologies. Suchapplications include Microsoft Visual Basic, Microsoft Excel, andMicrosoft Access. Scripting can also be hosted by Internet Explorer andInternet Information Services 5.0, which is part of Windows 2000 Server.

Using VBScript to Modify All Objects in the Marketing OU

In this example, the Marketing organization has moved to a new officeaddress. A simple VBScript program is used to perform a batchmodification for all user objects in the Marketing organization. Thescript alters the state, street, locality, and postal code attributes.

Copy the following text into your text editor:

Dim oContainer Set oContainer=GetObject("LDAP:// OU=marketing,DC=resk

1.

Save the file as Modify.vbs.2.

At the command prompt, type modify.vbs and press Enter. Thisprocesses all objects in the Marketing organizational unit andmodifies all users, altering the state, street address, postal code,and locality attributes.

3.

Using VBScript to Create a User Object in the Marketing OU

In this example, you use VBScript to add a new user to the Marketingorganization. This example illustrates how easy it is to use ADSI andVBScript to programmatically access the directory. Note that in thisexample, only a limited set of attributes are configured during the usercreation.

To create the script and add the user

Copy the following text into your text editor:

Dim oContainer 'Parent container of new user Dim oUser 'Created user

1.

Save the file as Adduser.vbs.2.

At the command prompt, type adduser.vbs and press Enter. Thiscreates a new user named Jo Brown in the Marketing OU.

3.

Using VBScript to Delete a User

In this example, you use VBScript to delete a user from the Marketingorganization.

Copy the following text into your text editor:

Dim oContainer 'Parent container of object to be deleted 'Get parent c

1.

Save the file as Deluser.vbs.2.

At the command prompt, type deluser.vbs and press Enter. Thisdeletes the user Jo Brown from the Marketing OU.-------------------Thanks,

3.

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

11 of 23 14/12/2011 05:50 p.m.

Page 12: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

http://sccm07.blogspot.com/

at 6:56 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007, SQL Queries

Friday, May 29, 2009

Enable File and Printer Sharing ThroughWindows FirewallSet objFirewall = CreateObject("HNetCfg.FwMgr")Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colServices = objPolicy.ServicesSet objService = colServices.Item(0)objService.Enabled = TRUE

-------------------Thanks,http://sccm07.blogspot.com/at 8:40 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007, SQL Queries

Wednesday, May 27, 2009

Excelent Artical for WMI TroubleshootingTipsWMI Troubleshooting Tips http://blogs.technet.com/configmgrteam/archive/2009/05/08/wmi-troubleshooting-tips.aspx

-------------------Thanks,http://sccm07.blogspot.com/at 7:58 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007, SQL Queries

Tuesday, February 24, 2009

VB Script Drive Space Check on list ofSystem Set objExcel = CreateObject("Excel.Application")objExcel.Visible = TrueobjExcel.Workbooks.AddintRow = 2 objExcel.Cells(1, 1).Value = "Machine Name"objExcel.Cells(1, 2).Value = "Drive"objExcel.Cells(1, 3).Value = "Total Size"objExcel.Cells(1, 4).Value = "Used Space"objExcel.Cells(1, 5).Value = "Free Space"objExcel.Cells(1, 6).Value = "Free Space Percentage"

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

12 of 23 14/12/2011 05:50 p.m.

Page 13: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile("MachineList.txt", 1) Do Until objFile.AtEndOfStreamstrComputer = objFile.ReadLineSet objWMIService = GetObject("winmgmts://" & strComputer) On Error Resume NextSet colDisks = objWMIService.ExecQuery("Select * FromWin32_LogicalDisk Where DriveType = 3")For Each objDisk In colDisksobjExcel.Cells(intRow, 1).Value = Ucase(strComputer)objExcel.Cells(intRow, 2).Value = objDisk.DeviceIDobjExcel.Cells(intRow, 3).Value = (FormatNumber(objDisk.Size/ 1024^3,1)) & " GB"objExcel.Cells(intRow, 4).Value = (FormatNumber(objDisk.Size/ 1024^3,1) - FormatNumber(objDisk.FreeSpace/ 1024^3, 1)) & " GB"objExcel.Cells(intRow, 5).Value = (FormatNumber(objDisk.FreeSpace/1024^3, 1)) & " GB"objExcel.Cells(intRow, 6).Value =FormatPercent(objDisk.FreeSpace/objDisk.Size, 0) If FormatPercent(objDisk.FreeSpace/objDisk.Size, 0) <= "25%" ThenobjExcel.Cells(intRow, 6).Font.ColorIndex = 3ElseEnd If intRow = intRow + 1NextLoop objExcel.Range("A1:F1").SelectobjExcel.Selection.Interior.ColorIndex = 19objExcel.Selection.Font.ColorIndex = 11objExcel.Selection.Font.Bold = TrueobjExcel.Cells.EntireColumn.AutoFit MsgBox "Done"

-------------------Thanks,http://sccm07.blogspot.com/at 1:26 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007

Thursday, February 5, 2009

vb script To Clear SCCM / SMS CCM /Cache FolderTo Clear SCCM / SMS CCM / Cache Folder ' Script to Clear SMS cache fileson error resume nextdim oUIResManagerdim oCache

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

13 of 23 14/12/2011 05:50 p.m.

Page 14: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

dim oCacheElementdim oCacheElementsset oUIResManager = createobject("UIResource.UIResourceMgr")if oUIResManager is nothing then' wscript.echo "Couldn't create Resource Manager - quitting" wscript.quitend ifset oCache=oUIResManager.GetCacheInfo()if oCache is nothing then set oUIResManager=nothing' wscript.echo "Couldn't get cache info - quitting" wscript.quitend ifset oCacheElements=oCache.GetCacheElements'wscript.echo "There are " & oCacheElements.Count & " cache elements"'wscript.echo' ***** Begin CLEAR CACHE *****for each oCacheElement in oCacheElementsoCache.DeleteCacheElement(oCacheElement.CacheElementID)next' ***** End CLEAR CACHE *****' ***** Clean up *****set oCacheElements=nothingset oUIResManager=nothingset oCache=nothing

-------------------Thanks,http://sccm07.blogspot.com/at 8:08 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007

Wednesday, January 14, 2009

SMS / SCCM Cleint health find Scripthere is the Batch file script for SCCM / SMS Clients health along withLast hardware scan report sent time and lastheartbeat time stamp itwill show you in the command window this will help you to know thestatus of Client agent. ====================================================================================@echo off@echo Client Version Last Hardware Inventory Hours Since Last HINVosql.exe -S SCCMDBSERVERNAME -d SMS_Sitecode -h-1 -E -Q"setnocount on select Distinct cast(Client_Version0 aschar(20)),cast(max(TimeStamp) as char(30)) ashinvDate,datediff(hh,max(TimeStamp),getdate()) as hoursLame fromv_r_system,v_GS_WORKSTATION_STATUS where v_r_system.ResourceID =v_GS_WORKSTATION_STATUS.ResourceID and Name0 like '%1' group byClient_Version0"================================================================================================== Simple save above script into .bat file and give the computer nameafter the batch file and run like

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

14 of 23 14/12/2011 05:50 p.m.

Page 15: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

client.bat systemname Yes.............Life is a batch, and then you FLY -------------------

Thanks,http://sccm07.blogspot.com/at 7:26 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007, SCCM Client Deployment, SCCM Reports

Monday, January 12, 2009

SCCM Client Installation Script:-- batchfile program

SCCM Client InstallationScript:-- here is my SCCM Client Installation batch file script. ================================================================================================================================================================================ECHO *********** %1 runing X copy kil.exexcopy /y kill.exe \\%1\admin$psexec \\%1 -c kill.exe "kill.exe ccmexec.exe"ECHO *********** %1 Copy dependent files to client admin$ xcopy /y ccmsetup.exe \\%1\admin$ECHO *********** %1 Uninstall SCCM Cleintpsexec \\%1 -c kill.exe "kill.exe ccmsetup.exe"psexec \\%1 \\%1\ADMIN$\ccmsetup.exe /uninstalldel \\%1\admin$\SMSCFG.INI

ECHO *********** %1 Install SCCM Clientpsexec \\%1 \\%1\ADMIN$\ccmsetup.exe fsp=SCCMSERVERsmssitecode=auto ================================================================================================================================================================================

-------------------Thanks,http://sccm07.blogspot.com/at 4:38 AM 0 commentsLabels: End to End, SCCM / SMS VBScript, SCCM 2007, SCCM Client Deployment

SCCM Client SUP registry Value CheckScriptTo find SCCM Client have the SUP server Registry key value status This script will check Weather the Client system is scanning properlywith SUP server or not

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

15 of 23 14/12/2011 05:50 p.m.

Page 16: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

============================================================================================================================================================================================================================================================On Error Resume NextConst HKEY_LOCAL_MACHINE = &H80000002Set Fso = CreateObject("Scripting.FileSystemObject")Set InputFile = fso.OpenTextFile("MachineList.Txt")Do While Not (InputFile.atEndOfStream)strComputer = InputFile.ReadLineSet objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"strValueName = "WUServer"objRegistry.GetStringValueHKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValueIf IsNull(dwValue) Then Wscript.Echo "The registry key does not exist. (" & dwValue & ") andcomputer name" & StrComputerElse Wscript.Echo "The registry key exists. (" & dwValue & ") and computername" & StrComputerEnd IfLoop''''HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate ============================================================================================================================================================================================================================================================

-------------------Thanks,http://sccm07.blogspot.com/at 4:22 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007, SCCM Client Deployment

Wednesday, November 5, 2008

VBS Script To Copy A File To A RemoteMachineFrom Myitforum VBS Script To Copy A File To A Remote Machine http://www.myitforum.com/articles/11/view.asp?id=12334

-------------------Thanks,http://paddymaddy.blogspot.com/at 7:43 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007

Monday, November 3, 2008

File and Print Enable

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

16 of 23 14/12/2011 05:50 p.m.

Page 17: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Set objFirewall = CreateObject("HNetCfg.FwMgr")Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colServices = objPolicy.ServicesSet objService = colServices.Item(0)objService.Enabled = True

-------------------Thanks,http://paddymaddy.blogspot.com/

at 8:24 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007

System Info OS and Service Pack Level' **************************' ServerInfo.vbs' Collects OS and SP info' List of systems must be in same directory as script' Run using cscript' **************************' Name of Input FilestrInputFile = "Syslist.txt"' Name of Output FilestrOutputFile = "ServerInfo.csv"

' Create file system objectset objFSO = CreateObject("Scripting.FileSystemObject")' Check for Existing Output file, Create output fileIf objFSO.FileExists(strOutputFile) Then Wscript.echo "You must delete or remove " & strOutputFile & " fromthis directory prior to running script" wscript.quitEnd Ifset objOutputFile = objFSO.OpenTextFile(strOutputFile, 2 , True)If objFSO.FileExists(strInputFile) Then set objInStream = objFSO.OpenTextFile(strInputFile, 1)' Begin reading input fileSet objWebmLocator = CreateObject("WbemScripting.SWbemLocator")On Error Resume NextDo While objInStream.AtEndOfStream <> True strComputer = objInStream.Readline 'Wscript.echo ("Connecting to " & strComputer) Set objWMI = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") If Err.number <> 0 Then Err.clear Set objWMI = objWebmLocator.ConnectServer(strComputer,"root\CIMV2", strUser, strPassword) End If If Err.Number <> 0 Then objOutputFile.Writeline(strComputer & ",Unavailable") 'WScript.echo ("Connection Failed") Else

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

17 of 23 14/12/2011 05:50 p.m.

Page 18: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Set colOS = objWMI.ExecQuery("Select Caption FromWin32_OperatingSystem") Set colSP = objWMI.ExecQuery("Select CSDVersion FromWin32_OperatingSystem") intOSCount = 0 intSPCount = 0 For Each objOS In colOS intOSCount = intOSCount + 1 strOSVal = Replace(objOS.Caption, ",", " ") Next For Each objSP in colSP intSPCount = intSPCount + 1 strSPVal = objSP.CSDVersion Next If intOSCount + intSpCOunt > 2 Then strVerified = "Unconfirmed" Else strVerified = "Confirmed" End If objOutputFile.Writeline(strComputer & "," & strOSVal & "," & strSPVal &"," & strVerified)

End If Err.Clear LoopEnd IFwscript.echo ("Script Complete")wscript.quit

-------------------Thanks,http://paddymaddy.blogspot.com/at 8:23 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007

WMI Connectivity CheckSet objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Status"

objExcel.Cells(1, 3).Value = "Error Number"

objExcel.Cells(1, 4).Value = "Hex Error Number"

objExcel.Cells(1, 5).Value = "Error Description"

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

18 of 23 14/12/2011 05:50 p.m.

Page 19: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

On Error Resume Next

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

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

If Err.Number <> 0 Then

objExcel.Cells(intRow, 2).Value = "Error"

objExcel.Cells(intRow, 3).Value = Err.Number

objExcel.Cells(intRow, 4).Value = Hex(Err.Number)

ElseIf Err.Number = 0 Then

objExcel.Cells(intRow, 2).Value = "Success"

objExcel.Cells(intRow, 5).Value = "No Errors"

Err.Clear

End If

If Err.Number = 462 Then

objExcel.Cells(intRow, 5).Value = "Machine Not Found"

ElseIf Err.Number = "-2147217394" Then

objExcel.Cells(intRow, 5).Value = "WMI Class Not Found"

ElseIf Err.Number = "-2147217405" Then

objExcel.Cells(intRow, 5).Value = "Access Denied"

Err.Clear

End If

If objExcel.Cells(intRow, 2).Value = "Error" Then

objExcel.Cells(intRow, 2).Font.ColorIndex = 3

Else

objExcel.Cells(intRow, 2).Font.ColorIndex = 10

End If

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

19 of 23 14/12/2011 05:50 p.m.

Page 20: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

intRow = intRow + 1

Loop

objExcel.Range("A1:E1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

MsgBox "Done"

-------------------Thanks,http://paddymaddy.blogspot.com/

at 8:22 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007

Admin$ checkSet objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Admin Share Exists"

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

On Error Resume Next

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

Set colShares = objWMIService.ExecQuery("Select * from Win32_ShareWhere Name = 'ADMIN$'")

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

20 of 23 14/12/2011 05:50 p.m.

Page 21: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

If colShares.Count > 0 Then

objExcel.Cells(intRow, 2).Value = "Yes"

Else

objExcel.Cells(intRow, 2).Value = "No"

End If

If Err.Number <> 0 Then

objExcel.Cells(intRow, 2).Value = Err.Description

Err.Clear

End If

intRow = intRow + 1

objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

loop

Wscript.Echo "Done"

-------------------Thanks,http://paddymaddy.blogspot.com/

at 8:21 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007

Remote Systems Discovery DataCollection Cycle Client agent initiateOn Error Resume NextDim oCPAppletMgrSet oCPAppletMgr = CreateObject("CPApplet.CPAppletMgr")Dim oClientActionsSet oClientActions = oCPAppletMgr.GetClientActions()Dim oClientActionFor Each oClientAction In oClientActionsIf oClientAction.Name = "Discovery Data Collection Cycle" ThenoClientAction.PerformActionEnd IfIf oClientAction.Name = "Request & Evaluate Machine Policy" Then

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

21 of 23 14/12/2011 05:50 p.m.

Page 22: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

oClientAction.PerformActionEnd IfNext

-------------------Thanks,http://paddymaddy.blogspot.com/at 8:17 AM 0 commentsLabels: SCCM / SMS VBScript, SCCM 2007, SCCM Client Deployment

Friday, October 10, 2008

RoboCopy VBS Script

VBS script with source and destination folder input dialog boxes as wellas hard coding the RoboCopy command line switches opposed to issuingthe commands from the command prompt Set objShell = CreateObject("Wscript.Shell") objSource = InputBox("Enter Source")objDestination = InputBox("Enter Destination") objCommand = "RoboCopy.Exe " & Chr(34) & objSource & Chr(34) & " " &Chr(34) & objDestination & Chr(34) & " /e /r:1 /w:2"objShell.Run(objCommand) MsgBox "Done"at 6:20 AM 0 commentsLabels: PowerShell, SCCM / SMS VBScript, SCCM 2007

Wednesday, October 8, 2008

Dell recommend using SMS WOL BIOSSettings remote Enable

Dell recommend using SMS and Dell OpenManage Client Instrumentation(OMCI). However, this requires WMI scripting which may be prevented ifsecurity lockdown settings prevent such scripts from running.

Pros: Exposes the Dell BIOS to WMI and therefore enablesalmost any modification to be made by running VB script. It alsomeans SMS hardware inventory can then report upon BIOSsettings by extending the SMS_DEF.MOF.

Cons: Requires agent software to be run on the client.

The Dell Client Configuration Utility (DCCU) can be used as an alternativeto the OMCI client to create stand-alone executables that can outputconfiguration settings ('Get Values') to an XML file and/or configure BIOSsettings ('Set Values'), including enabling WOL.

Pros: Leaves not footprint on the client

Cons: An executable file needs to be created for every actionyou want to perform against the BIOS; meaning heavier networkutilization.

at 7:37 AM 0 commentsLabels: End to End, SCCM / SMS VBScript, SCCM 2007, SCCM Client Deployment, SCCMReports, WOL

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

22 of 23 14/12/2011 05:50 p.m.

Page 23: Sms 2003 _ Sccm 2007_ Sccm _ Sms Vbscript

Newer Posts Older PostsHome

Subscribe to: Posts (Atom)

SMS 2003 & SCCM 2007: SCCM / SMS VBScript http://sms2003-sccm2007.blogspot.com/search/label/SCCM / SMS VB...

23 of 23 14/12/2011 05:50 p.m.