Reuse UserDomain and UserID?
-
Thursday, August 23, 2012 3:14 PM
I have a vbscript that has to be run at the end of every deployment. It validates all of the security settings on the laptop before deployment and notifies two other teams that this device has been completed. My problem is that during deployment I'm logged into the laptop as Administrator obviously. The local user is pulled from the device and not only tells who deployed the laptop but also uses this to CC them on the outbound email.
Ultimately, I would like to use the credentials supplied at the beginning of the deployment (for conencting to network shares) as the user running the script.
I don't know what the best method is to pull this off. I would love to powershell this but my powershell skills are still basic to intermediate, so I'm stuck with a VBS/BAT/MDT solution right. Below is the script we're using if you need to reference what we're doing. I would appreciate any method, tips, or suggestions anyone might have.
On Error Resume Next Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const HKEY_LOCAL_MACHINE = &H80000002 Dim ObjItem strComputer = "." Set objWMIService = GetObject("winmgmts:"_ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSettings = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each objComputer in colSettings sysComputerName = "System Name : " & objComputer.Name sysManufacturer = "System Manufacturer : " & objComputer.Manufacturer sysMachineType = "System Model : " & objComputer.Model sysMemory = "Total Memory : " & objComputer.TotalPhysicalMemory Next Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48) For Each objItem in colItems sysCurrentUser = "Current User : " & objItem.UserName Next Set colSettings = objWMIService.ExecQuery _ ("Select * from Win32_BIOS") For Each objBIOS in colSettings sysSerialNumber = "Serial Number : " & objBIOS.SerialNumber Next Set objFSO = CreateObject("Scripting.FileSystemObject") strMcAfee = "McAfee Version : " & objFSO.GetFileVersion("c:\Program Files\McAfee\VirusScan Enterprise\Shstat.exe") Set objFSO = CreateObject("Scripting.FileSystemObject") strPointsec = "Pointsec Version : " & objFSO.GetFileVersion("c:\Program Files\Pointsec\Pointsec for PC\P95Tray.exe") strData = sysCurrentUser & vbCrlf & sysComputerName & vbCrlf & sysManufacturer & vbCrlf & sysMachineType & vbCrlf & sysSerialNumber & vbCrlf & sysMemory & vbCrlf & strMcAfee & vbCrlf & strPointsec & vbCrlf & strOAC user=Right(sysCurrentUser, 8) user=LCase(user) user=Replace(user, "abcx", "abcn") user=Replace(user, "venx", "vend") strCopyAHSN = user & "@company.com" Set objEmail = CreateObject("CDO.Message") objEmail.From = " email@company.com " objEmail.To = " email1@company.com, email2@company.com,email3@company.com" objEmail.Cc = strCopyAHSN objEmail.Subject = "Laptop Security Summary " & "for " & sysComputerName objEmail.Textbody = "Security Team a laptop has been deployed. Please see the details below..." & vbCrlf & vbCrlf & strData objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ "172.xxx.xxx.xxx" objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objEmail.Configuration.Fields.Update objEmail.Send
All Replies
-
Sunday, August 26, 2012 12:14 AM
One easy way is to execute it with the %userid% as argument from your TS.
Then add a few lines of vbscript code to grab the first argument if it exist.
- Marked As Answer by roberts0515 Wednesday, August 29, 2012 4:54 PM

