Documente Academic
Documente Profesional
Documente Cultură
Compartir
Siguiente blog
Crear un blog
Acceder
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
1 of 23
Where MS going? TO GET THE USER STATUS : Guest account status Sysprep parameters Join the computer silently to the Domain Batch file for loop in other way It's Microsoft Patch Tuesday: June 2010 DNS Bulk ADD FIND Collections and its Name in the console SQL ... Sample Prompt option for Collection
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
May (25) April (40) March (30) February (26) January (16)
Labels
Active 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)
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
2 of 23
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)
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 comments Labels: MY Notes, MY Vbscripts, SCCM / SMS VBScript, SCCM 2007
3 of 23
Dim objOU Dim strNewComputerName Dim objNewComputer Dim strDomainDN Dim strDomainFQDN Dim intOULevel Dim strSearchADsPath Dim intStartNumber 'Set variables DQ = Chr(34) 'Create Objects Set objShell = CreateObject("Wscript.Shell") Set objNetwork = CreateObject("WScript.NetWork") 'Verifies script was run using Cscript, and if not relauches it using Cscript If 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 0 End If 'Warn User intWarn = 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 0 End If 'Construct an ADsPath to the Current Domain with rootDSE Set objRootDSE = GetObject("LDAP://rootDSE") strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext") 'Convert domain Distinguished Name to FQDN format strDomainDN = objRootDSE.Get("defaultNamingContext") strDomainFQDN = Replace(Replace(strDomainDN, "DC=", ""), ",", ".") 'Connect to Active Directory Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_ONELEVEL 'Prompt for Path to OU Do 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 Then WScript.Quit
4 of 23
'Search through each OU level in path provided For 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.MoveFirst Do Until objRecordSet.EOF strSearchADsPath = objRecordSet.Fields("ADsPath").Value objRecordSet.MoveNext Loop End If Next 'Get current username to use in description field strAdmin = objNetwork.UserName 'Prompt for the base computer name Do strBaseName = _ InputBox("Please enter the base computer name to use for new accounts:", _ "Base Computer Name", "TestPC") If strBaseName = False Then WScript.Quit End If Loop Until strBaseName <> "" strBaseName = UCase(strBaseName) 'Prompt for starting computer number Do intStartNumber = _
5 of 23
InputBox("Please enter the beginning number to use in computer names:", _ "Starting Computer Number", "001") If intStartNumber = False Then WScript.Quit End If Loop Until intStartNumber <> "" intStartNumber = CInt(intStartNumber) intRecord = intStartNumber 'Prompt for number of accounts to be created Do intRecordMax = _ InputBox("Please enter the number of accounts to be created", _ "Count Input", "10") If intRecordMax = False Then WScript.Quit End If Loop Until intRecordMax <> "" intRecordMax = CInt(intRecordMax)
'Bind to OU that computers will be created in Set objOU = GetObject(strSearchADsPath) 'Create the user accounts Do Until intRecord = intRecordMax + intStartNumber intRecord = Right("000" & intRecord, 3) strNewComputerName = strBaseName & intRecord WScript.Echo "Creating " & strNewComputerName Set objNewComputer = objOU.Create("Computer", "cn= " & strNewComputerName) objNewComputer.Put "samAccountName", strNewComputerName & "$" objNewComputer.Put "userAccountControl", 4096 objNewComputer.Put "description", "Account created: " & Date() & " by: " _ & strAdmin objNewComputer.SetInfo 'Writes settings to AD intRecord = intRecord + 1 Loop WScript.Echo WScript.echo "Finished creating computer accounts."
at 8:36 AM 0 comments Labels: MY Notes, MY Vbscripts, SCCM / SMS VBScript
SMS has a nice feature that allows you to create a collection based on
6 of 23
users. That way when a users logs into a computer SMS will then run an advertisement for whatever computer they are on. The problem is maybe you want to have a collection of computers not the users. The worst flaw this the collection query I have created below and using collections 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 users and create a collection of computers.
--------------------------------------select SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.N ame,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomain ORWorkgroup,SMS_R_System.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.UserName in (select UniqueUserName from SMS_R_User where UserOUName = "xxxx /SECURITY USERS & GROUPS" ) -------------------------------------Windows User account and group discovery must be enabled and run on your server to use this. How does this work. It first grabs the list of users. Then matches them to the comptuers that SMS currently sees them logged into. To change this to Last Logged in user you need to change the SMS_G_System_Computer_System to SMS_R_System.LastLogonUserName for computers. This will give you last logged in user. "Limit to Collection" for all your computer Workstations or further limit it to based on departments If you don't know what group then you can create a query of just (select UniqueUserName from SMS_R_User where UserOUName = "") click values until you have the value you need and paste it into the larger query. ------------------Thanks, http://sccm07.blogspot.com/
at 3:02 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007, SQL Queries
7 of 23
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.SetInfo Next WScript.Echo "1000 Users created."
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Creating an Active Directory User Account------------------------------------------------------------------------Creates a user account in Active Directory. This script only creates the account, it does not enable it.
Set objOU = GetObject("LDAP://OU=management,dc=fabrikam,dc=com") Set
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Demonstration script that: 1) creates a new Active Directory organizational unit; 2) creates a new user account and new security group; and, 3) adds the new user as a member of that security group.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
8 of 23
("LDAP://cn=myerken,
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
("LDAP://CN=myerken,OU=management,DC=Fa
("LDAP://cn=myerken,ou=management,dc=fabr
("LDAP://cn=MyerKe
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9 of 23
Forces a user to change their password the next time they logon.
Set objUser = GetObject _
("LDAP://CN=myerken,OU=management,DC=Fa
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
("LDAP://cn=myerken
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
("LDAP://cn=MyerKen,ou=Management,dc=NA
Enjoy, http://sccm07.blogspot.com/
at 7:05 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007, SQL Queries
Dim FileSyste
10 of 23
3. At the command prompt type export.vbs and press Enter. This creates a file named Marketing.txt, which contains a list of users and some of their attributes, such as distinguished name, name, state, and street address. With appropriate modification, this script can be used with any application that supports COM and Visual Basic technologies. Such applications include Microsoft Visual Basic, Microsoft Excel, and Microsoft Access. Scripting can also be hosted by Internet Explorer and Internet 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 office address. A simple VBScript program is used to perform a batch modification for all user objects in the Marketing organization. The script alters the state, street, locality, and postal code attributes. 1. Copy the following text into your text editor:
Dim oContainer Set oContainer=GetObject("LDAP://
OU=marketing
2. Save the file as Modify.vbs. 3. At the command prompt, type modify.vbs and press Enter. This processes all objects in the Marketing organizational unit and modifies all users, altering the state, street address, postal code, and locality attributes. Using VBScript to Create a User Object in the Marketing OU In this example, you use VBScript to add a new user to the Marketing organization. This example illustrates how easy it is to use ADSI and VBScript to programmatically access the directory. Note that in this example, only a limited set of attributes are configured during the user creation. To create the script and add the user 1. Copy the following text into your text editor:
Dim oContainer 'Parent container of new user Dim
oUser 'Crea
2. Save the file as Adduser.vbs. 3. At the command prompt, type adduser.vbs and press Enter. This creates a new user named Jo Brown in the Marketing OU. Using VBScript to Delete a User In this example, you use VBScript to delete a user from the Marketing organization. 1. Copy the following text into your text editor:
Dim oContainer 'Parent container of object to be
deleted 'Get p
2. Save the file as Deluser.vbs. 3. At the command prompt, type deluser.vbs and press Enter. This deletes the user Jo Brown from the Marketing OU. ------------------Thanks,
11 of 23
http://sccm07.blogspot.com/
at 6:56 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007, SQL Queries
------------------Thanks, http://sccm07.blogspot.com/
at 8:40 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007, SQL Queries
12 of 23
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("MachineList.txt", 1) Do Until objFile.AtEndOfStream strComputer = objFile.ReadLine Set objWMIService = GetObject("winmgmts://" & strComputer) On Error Resume Next Set colDisks = objWMIService.ExecQuery("Select * From Win32_LogicalDisk Where DriveType = 3") For Each objDisk In colDisks objExcel.Cells(intRow, 1).Value = Ucase(strComputer) objExcel.Cells(intRow, 2).Value = objDisk.DeviceID objExcel.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%" Then objExcel.Cells(intRow, 6).Font.ColorIndex = 3 Else End If intRow = intRow + 1 Next Loop objExcel.Range("A1:F1").Select objExcel.Selection.Interior.ColorIndex = 19 objExcel.Selection.Font.ColorIndex = 11 objExcel.Selection.Font.Bold = True objExcel.Cells.EntireColumn.AutoFit MsgBox "Done"
------------------Thanks, http://sccm07.blogspot.com/
at 1:26 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007
' Script to Clear SMS cache files on error resume next dim oUIResManager dim oCache
13 of 23
dim oCacheElement dim oCacheElements set oUIResManager = createobject("UIResource.UIResourceMgr") if oUIResManager is nothing then ' wscript.echo "Couldn't create Resource Manager - quitting" wscript.quit end if set oCache=oUIResManager.GetCacheInfo() if oCache is nothing then set oUIResManager=nothing ' wscript.echo "Couldn't get cache info - quitting" wscript.quit end if set oCacheElements=oCache.GetCacheElements 'wscript.echo "There are " & oCacheElements.Count & " cache elements" 'wscript.echo ' ***** Begin CLEAR CACHE ***** for each oCacheElement in oCacheElements oCache.DeleteCacheElement(oCacheElement.CacheElementID) next ' ***** End CLEAR CACHE ***** ' ***** Clean up ***** set oCacheElements=nothing set oUIResManager=nothing set oCache=nothing ------------------Thanks, http://sccm07.blogspot.com/
at 8:08 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007
Simple save above script into .bat file and give the computer name after the batch file and run like
14 of 23
Thanks, http://sccm07.blogspot.com/
at 7:26 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007, SCCM Client Deployment, SCCM Reports
SCCM Client Installation Script:-here is my SCCM Client Installation batch file script. ================================================================== ================================================================== ============================================ ECHO *********** %1 runing X copy kil.exe xcopy /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 Cleint psexec \\%1 -c kill.exe "kill.exe ccmsetup.exe" psexec \\%1 \\%1\ADMIN$\ccmsetup.exe /uninstall del \\%1\admin$\SMSCFG.INI ECHO *********** %1 Install SCCM Client psexec \\%1 \\%1\ADMIN$\ccmsetup.exe fsp=SCCMSERVER smssitecode=auto ================================================================== ================================================================== ============================================
------------------Thanks, http://sccm07.blogspot.com/
at 4:38 AM 0 comments Labels: End to End, SCCM / SMS VBScript, SCCM 2007, SCCM Client Deployment
15 of 23
================================================================== ================================================================== ================================================================== ====================================================== On Error Resume Next Const HKEY_LOCAL_MACHINE = &H80000002 Set Fso = CreateObject("Scripting.FileSystemObject") Set InputFile = fso.OpenTextFile("MachineList.Txt") Do While Not (InputFile.atEndOfStream) strComputer = InputFile.ReadLine Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root \default:StdRegProv") strKeyPath = "SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" strValueName = "WUServer" objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue If IsNull(dwValue) Then Wscript.Echo "The registry key does not exist. (" & dwValue & ") and computer name" & StrComputer Else Wscript.Echo "The registry key exists. (" & dwValue & ") and computer name" & StrComputer End If Loop ''''HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows \WindowsUpdate ================================================================== ================================================================== ================================================================== ====================================================== ------------------Thanks, http://sccm07.blogspot.com/
at 4:22 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007, SCCM Client Deployment
16 of 23
Set objFirewall = CreateObject("HNetCfg.FwMgr") Set objPolicy = objFirewall.LocalPolicy.CurrentProfile Set colServices = objPolicy.Services Set objService = colServices.Item(0) objService.Enabled = True ------------------Thanks, http://paddymaddy.blogspot.com/
at 8:24 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007
17 of 23
Set colOS = objWMI.ExecQuery("Select Caption From Win32_OperatingSystem") Set colSP = objWMI.ExecQuery("Select CSDVersion From Win32_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 Loop End IF wscript.echo ("Script Complete") wscript.quit ------------------Thanks, http://paddymaddy.blogspot.com/
at 8:23 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007
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"
18 of 23
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
19 of 23
MsgBox "Done"
------------------Thanks, http://paddymaddy.blogspot.com/
at 8:22 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007
Admin$ check
Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add intRow = 2
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_Share Where Name = 'ADMIN$'")
20 of 23
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
Wscript.Echo "Done"
------------------Thanks, http://paddymaddy.blogspot.com/
at 8:21 AM 0 comments Labels: SCCM / SMS VBScript, SCCM 2007
21 of 23
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 comments Labels: PowerShell, SCCM / SMS VBScript, SCCM 2007
22 of 23
Home
Older Posts
23 of 23