The CSI-Windows VBScript UAC Function for Snooping Permissions (IfUserPerms.vbs) Version 1.2 written by our pal Darwin Sanoy has been released and is available for download.
With this script you can quickly determine if your current session is capable of elevating to administrator rights AND whether the session is currently elevated. The beauty of the script is that you can first determine if you have the necessary privileges and credentials or rights to perform a task or start an executable. If your current rights are not elevated then you can take additional scripting actions to elevate (not a part of this particular sample).
Darwin developed this script because many UAC scripting solutions and samples do not take a proactive approach to examining the environment before deciding whether to attempt a privileged operation. Checking things out ahead of time allows for assured results, fewer errors and more intelligent status messages to logs or end users when the environment does not support the desired privileges.
Download 116_IfUserPerms.zip:
http://csi-windows.com/toolkit/ifuserperms
This VBS Script will send your resources assigned and installed site codes to Excel.
VBS Script:
strServer = InputBox ("Enter Site Server Name")
strDatabase = InputBox ("Enter Three Letter Site Code")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Machine Name"
objExcel.Cells(1, 2).Value = "Assigned Site"
objExcel.Cells(1, 3).Value = "Installed Site"
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=SQLOLEDB;Data Source =" & strServer & ";" & _
"Trusted_Connection=Yes;Initial Catalog =SMS_" & strDatabase
Set objRecordSet = CreateObject("ADODB.Recordset")
objRecordSet.Open _
" Select SD.Name0, A.SMS_Assigned_Sites0, I.SMS_Installed_Sites0" & _
" From v_R_System SD" & _
" Join v_RA_System_SMSAssignedSites A On SD.ResourceID = A.ResourceID" & _
" Join v_RA_System_SMSInstalledSites I On SD.ResourceID = I.ResourceID" _
, objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
objExcel.Cells(intRow, 1).Value = objRecordSet.Fields("Name0").Value
objExcel.Cells(intRow, 2).Value = objRecordSet.Fields("SMS_Assigned_Sites0").Value
objExcel.Cells(intRow, 3).Value = objRecordSet.Fields("SMS_Installed_Sites0").Value
objRecordSet.MoveNext
intRow = intRow + 1
Loop
objExcel.Range("A1:C1").Select
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
Set objRange = objExcel.Range("A1")
objRange.Sort objRange,1,,,,,,1
MsgBox "Done"
This VBS Script will take a remote site servers name and site code and will send the site servers roles to an Excel spreadsheet for your records.
strComputer = InputBox("Enter Site Server Name")
strSiteCode = InputBox("Enter Site Code")
objExcel.Cells(1, 1).Value = "Server Name"
objExcel.Cells(1, 2).Value = "Site Code"
objExcel.Cells(1, 3).Value = "Role Name"
Set objWMIService = GetObject("winmgmts://" & strComputer & "\root\sms\site_" & strSiteCode)
Set colItems = objWMIService.ExecQuery("Select * from SMS_SystemResourceList")
For Each objItem in colItems
objExcel.Cells(intRow, 1).Value = objItem.ServerName
objExcel.Cells(intRow, 2).Value = objItem.SiteCode
objExcel.Cells(intRow, 3).Value = objItem.RoleName
Next
objExcel.Selection.Interior.ColorIndex = 19
Msgbox "Done"
This VBS Script will send the Windows Updates from a specified machine name to excel.
strComputer = InputBox ("Enter Machine Name")
objExcel.Cells(1, 2).Value = "Update"
objExcel.Cells(1, 3).Value = "Status"
objExcel.Cells(1, 4).Value = "Date"
objExcel.Cells(1, 5).Value = "Source"
On Error Resume Next
Set objSession = CreateObject("Microsoft.Update.Session", strComputer)
Set objSearcher = objSession.CreateUpdateSearcher
intHistoryCount = objSearcher.GetTotalHistoryCount
Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)
For Each objEntry in colHistory
objExcel.Cells(intRow, 1).Value = UCase(strComputer)
objExcel.Cells(intRow, 2).Value = objEntry.Title
Select Case objEntry.ResultCode
Case 0 ResultCode = "Not Started"
Case 1 ResultCode = "In Progress"
Case 2 ResultCode = "Success"
Case 3 ResultCode = "Error"
Case 4 ResultCode = "Failed"
Case 5 ResultCode = "Cancelled"
End Select
objExcel.Cells(intRow, 3).Value = ResultCode
objExcel.Cells(intRow, 4).Value = objEntry.Date
objExcel.Cells(intRow, 5).Value = objEntry.ClientApplicationID
objExcel.Range("A1:E1").Select
Set objRange = objExcel.Range("D1")
objRange.Sort objRange,2,,,,,,1
This VBS Script will allow you to find SMS Services on a specified site server.
objExcel.Cells(1, 1).Value = "Service Name"
objExcel.Cells(1, 2).Value = "Account Name"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service Where Name like 'SMS_%'")
objExcel.Cells(intRow, 1).Value = objItem.Name
objExcel.Cells(intRow, 2).Value = objItem.StartName
objExcel.Range("A1:B1").Select