Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


  • Content count

  • Donations

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Aen

  • Birthday 06/25/1979
  1. I was going to create a new function and stop the query on both of those..i was just fooling around. Really just need to figure out how to pull that. I am surprised no one else has really done that before..i couldnt find any code snippets.
  2. i can find the DN by going through ADSIedit.msc. But, i am making a script that when a user will enter in a username and employee number, it will change the custom employee ID field. We dont really want to give them access to ADSIedit because it can be very dangerous. We are only using Windows AD.
  3. Writing a script that basically does this: 1. Ask user for a username 2. Ask user for employee number 3. script verifies if it is real username - if it is, continues - if not, it stops script 4. (step i need help with) - Query AD through LDAP and pull DN 5. Add employee number to 2 different fields in AD (employeeID, employeeNumber) Real simple script.. but having some issues getting the DN from AD. *DN = distinguishedName Here is what i got: Set objFile = CreateObject("Scripting.FileSystemObject") Set objNetName = CreateObject("WScript.NetWork") DIM strEmpID Name = GetUserName() EmployeeID = GetEmployeeID() UserExists = CheckUser(Name) If UserExists = TRUE then msgbox strEmpID msgbox Name Call LoadEmployeeID Else Msgbox "User does not exist, try again." wscript.quit(0) End If '=========================== Function LoadEmployeeID() Set objUser = GetObject objUser.Put "employeeNumber", strEmpID 'objUser.Put "employeeID", EmployeeID objUser.SetInfo End Function '=========================== Function GetEmployeeID() EmployeeID = Inputbox ("Please enter in 5 digit employee number") strEmpID = EmployeeID End Function '======================================= Function GetUserName() i = 0 UserName = InputBox ("Ex. Firstname.LastName ", " Please Enter User Name") Do While Instr(UserName, ".") = 0 and i <= 5 Username = InputBox ("Ex. Firstname.LastName ", " Please Enter User Name") i=i+1 Loop If Instr(UserName, ".") = 0 Then WScript.Quit(0) Else GetUserName = Trim(UserName) End If End Function '=========================================== Function CheckUser(strUserName) dtStart = TimeValue(Now()) Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Provider=ADsDSOObject;" Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.CommandText = _ "<LDAP:/*removed*t>;(&(objectCategory=User)" & _ "(samAccountName=" & strUserName & "));samAccountName;distinguishedName;subtree" Set objRecordSet = objCommand.Execute If objRecordset.RecordCount = 0 Then 'WScript.Echo "sAMAccountName: " & strUserName & " does not exist." CheckUser = FALSE Else objRecordset.MoveFirst Do while Not objRecordset.EOF wscript.echo objRecordset("samAccountName") & " | " & objRecordset("distinguishedName") objRecordset.MoveNext Loop 'WScript.Echo strUserName & " exists." CheckUser = TRUE End If objConnection.Close End Function '==================================================== Can anyone please give some advice or code that can help? I think if i can just pull the DN from LDAP query and put that into a variable..i can finish the rest.
  4. I have it DIM'd a few lines up from that Dim oDict, oUser, oGroup, strDNSDomain, objRootLDAP do i need to do something else to it?
  5. I am trying to make a logon VBScript. The purpose of the script is if a user is part of a AD Security Group, then it will unmap a drive letter, and then map a drive letter. I am having issues getting the part of finding if the user is part of that SG. Now i will admit, i have no idea what i am doing, and probably not the best way of doing it. Here is what i got so far: Option Explicit Dim objShell, objNetwork, ObjGroupDict Dim drFinance, drFOutlook, drTest Dim sgFinance, sgFinance2, sgFOutlook, sgFOutlook2, sgTest Dim shFinance, shFOutlook, shTest Dim strDomain, strUser, strAdsPath Set objNetwork = WScript.CreateObject("Wscript.Network") strDomain = objNetwork.UserDomain strUser = objNetwork.UserName strAdsPath = strDomain & "\" & strUser Set objShell = CreateObject("WScript.Shell") Set objNetwork = CreateObject("WScript.Network") 'Drive letters drFinance = "F:" drFOutlook = "G:" drTest = "Z:" 'Security Groups sgFinance = "CFOOrganization - Finance - M" sgFinance2 = "CFOOrganization - Finance - R" sgFOutlook = "CFOOrganization - FinanceOutlook - M" sgFOutlook2 = "CFOOrganization - FinanceOutlook - R" sgTest = "testdrivemapping" 'Shares: shFinance = "\\none\data\CFOOrganization\Finance" shFOutlook = "\\none\data\CFOOrganization\FinanceOutlook" shTest = "\\none\data" if isMember(sgTest) then objNetwork.RemoveNetworkDrive drTest, 1, true wscript.Sleep 10000 objNetwork.MapNetworkDrive drTest, shTest End If if isMember(sgFinance) then objNetwork.RemoveNetworkDrive drFinance, 1, true wscript.Sleep 10000 objNetwork.MapNetworkDrive drTest, shFinance End If if isMember(sgFinance2) then objNetwork.RemoveNetworkDrive drFinance, 1, true wscript.Sleep 10000 objNetwork.MapNetworkDrive drTest, shFinance End If if isMember(sgFOutlook) then objNetwork.RemoveNetworkDrive drFOutlook, 1, true wscript.Sleep 10000 objNetwork.MapNetworkDrive drTest, shFOutlook End If if isMember(sgFOutlook2) then objNetwork.RemoveNetworkDrive drFOutlook, 1, true wscript.Sleep 10000 objNetwork.MapNetworkDrive drTest, shFOutlook End If '========================================================================= 'FUNCTIONS '========================================================================= Set objNetwork = Nothing Set objShell = Nothing Wscript.Quit Function IsMember(sGroup) Dim oDict, oUser, oGroup, strDNSDomain, objRootLDAP If IsEmpty(oDict) Then Set oDict = CreateObject("Scripting.Dictionary") set strDNSDomain = objRootLDAP.Get("DefaultNamingContext") oDict.CompareMode = vbTextCompare 'Location in AD: none.ad.none.net/None Domain Users/Standard Accounts/Americas Set oUser = GetObject("LDAP://cn=Americas, cn=Standard Aaccounts, cn=None Domain users," & strDNSDomain) For Each oGroup In oUser.Groups oDict.Add oGroup.Name, "-" Next Set oUser = Nothing End If End Function right now when i run it i get: C:\mapdrivetest.vbs(74, 3) Microsoft VBScript runtime error: Object required: 'objRootLDAP' which is this line: set strDNSDomain = objRootLDAP.Get("DefaultNamingContext") I just have no idea what i am doing wrong. I am not sure if i am doing this right at all. Can you point me to the right direction? --Aen
  6. we are going to be using MSI files to later to deploy with Altiris once that gets all the way up and going. I will check out 7zip's self extracting though. That may help on a few things.
  7. Then it's an issue with WSH or such, because it's supposed to wait, and it does wait then I try it (with another process at least). Or maybe msiexec spawns another process and terminates almost instantly, and then the script continues, in which case a short delay would work (or waiting for the install to be finished)... its kinda weird. I just tried with a different MSI install and it worked the way its supposed to. I am going to rebuild it. Thanks again for your insight and help
  8. that script has the same issue as my last one. It changes the registery which is good, then kicks off the install then right that second it turns back off that key. How do i get it so when the install is finished, it will put the keys back to way its supposed to be?
  9. Thanks! I got to look at why it says my MSI is not a valid windows installation package.
  10. Sorry, i got so many things going on at once. What it is really doing is changing 2 different registry values so windows security will no longer pop up. Then install the application. After the application installs (which is my issue, it starts it then goes to the next line) then puts the value back to what it was orginally. When installing the application from a remote server it uses the internet settings for files, so that is why i am trying to disable those.
  11. heh, i have been googling a LOT last few days. And i have been just piecing together what i have found. Problem is, i dont know the best way to script this stuff. I just do a search and try to piece things together. I get tossed a project and they say "use vbscript" and i am trying to work on it best i can. When i try to do the silent commands for msi files, it still comes up with windows security asking if i want to run the file. The whole project has to be done without human intervention and work 100% without someone touching it. Using the regread (that you just mentioned) i can change my commands to do that, but when i launch the msi app, it still asks for that security code and still have the same issue.
  12. I am doing a unattended install through Altiris. Boss wishes to have all of the applications installed through VBScript. But after the unattended install, Windows Security pops up and asks "do you really want to install....." And you need to click Run. So i found some registry keys to disable that feature, then run the install of the app, then adds the keys again to re-enable it. My problem is, is that the way i got my VBScript it basically runs the commands through a command prompt. so, it does this: Remove key Remove Key install app add key add key It does not wait for the app to finish installing, once it sends the command, it goes to the next line. Putting in a sleep command can waste a lot of time and i just need to figure out how for the script to know when the application is finished, it will add the keys back. I am a newb with VBScript and my coworkers just say "figure it out yourself" and i have been wasting my day away trying to figure this out. Boss is very anal and requires it a certain way and wants it so when the applications are finished, it will add the key back and not just use a wscript.sleep command. here is my script so far. Any help would be great. I will take advice or if you want to write it lol. *shrugs* Option Explicit Dim objShell Set objShell = CreateObject("Wscript.Shell") objShell.Run "reg add ""HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /v ""1806"" /t REG_DWORD /d 0 /f", 1, True objShell.Run "reg add ""HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /v ""CurrentLevel"" /t REG_DWORD /d 0 /f", 1, True WScript.Sleep(10000) objShell.Run "cmd /c start \\Server\e$\file.msi", 1, True WScript.Sleep(10000) objShell.Run "reg add ""HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /v ""1806"" /t REG_DWORD /d 1 /f", 1, True objShell.Run "reg add ""HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /v ""CurrentLevel"" /t REG_DWORD /d 12000 /f", 1, True WScript.Quit
  13. I just inherited a windows 2003 server that has Word 2002 and Excel 2002 installed on it. When i try to remove it from the server it is asking for the source disks. looking for the excel.msi and word.msi files. I have a copy of office xp but it can not locate those files and i can not get rid of those prgms. Server they gave my group has a 4 gig C drive and its killing me on space. Need to get it usable for a month till our new server comes in for replacement. Anyone know how i can fix this?
  14. Upgrade File/Print Server

    glad it can help I am just learning all of this too. We are migrating 10 file servers into 3 servers. I will post if i learn anything else that is useful.
  15. Upgrade File/Print Server

    We had done the same thing here last week. we used the print migrater to get all of the printers off of one server and use it again on the new system. The file share are a little different. First what you need to do is do a robocopy of all of your old data to your new server. Once it is synced up, disjoin the server from the domain and change the name. Join it back to the domain and do the robocopy again so all files that were in use are no longer in use and no user will connect to it again while you are trying to do this. Next add in a DNS record for the old server's name to the new server. This way DFS will still work and anyone using the old printserver/fileserver will be able to still use there shortcuts and network mappings. Shares were the tricky part. We used Hyena to pull out Sharename, Sharepath, Description, Type of share into a CVS document. Then pulled out all of the default system shares so none of the shares are the same. After that i wrote a script that will create the shares: This was ran from DOS as cscript 'Define Constants and Global Variables Const FILE_SHARE = 0 Const MAXIMUM_CONNECTIONS = Null Const ForReading = 1 Const TristateTrue = -1 strComputer = "SERVER NAME" 'Instantiate WMI objects to create shares Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objNewShare = objWMIService.Get("Win32_Share") 'Instantiate File System Object and open input file Set objFSO = CreateObject("Scripting.FileSystemObject") 'add the path where your txt document is at Set objTextFile = objFSO.OpenTextFile ("D:\Migration\Users-Standard.txt", ForReading, False, TristateTrue) 'Loop through input file Do Until objTextFile.AtEndOfStream CreateShare(objTextFile.Readline) Loop 'arrShares(0) = share name 'arrShares(1) = share path 'arrShares(2) = Description 'arrShares(3) = type of share Sub CreateShare(txtLine) arrShares = Split(txtLine, ",") Wscript.Echo """" & arrShares(1) & """" &","& arrShares(0) &","& arrShares(3) &","& MAXIMUM_CONNECTIONS &","& arrShares(2) errReturn = objNewShare.Create (arrShares(1), arrShares(0), arrShares(3), MAXIMUM_CONNECTIONS, arrShares(2)) 'Wscript.Echo errReturn End Sub Here is a sample of the txt file we used to create the shares: NAME1$,G:\Users\Standard\NAME1,,0 NAME2$,G:\Users\Standard\NAME2,,0 Robocopy What i did was create a batch file with all of the robocopy commands. We are taking down 3 file servers into 1 with a single drive. Each server had 2 drives on it. So i just set a schedule task to run this robocopy nightly just to make sure we get all of the data until we are ready. sample: robocopy.exe "\\Sourceserver\f$" "\\Destserver\f$\Sourceserver_FDrive" /S /E /ZB /COPYALL /R:2 /W:5 /PURGE /XD \\Sourceserver\F$\DFSROOT\ /log:C:\robocopy\sourceserver-f.log Robocopy.exe [source location] [dest location] /S - Copy subfolders /E - Copy subs including empty /Z - copy files in restartable mode (survive network glitch). /B - copy files in Backup mode. /COPYALL - copy all file info /R:2 - 2 retries /W:5 - Wait 5seconds between tries /PURGE - delete dest files/folders that no longer exist in source. /XD \\[source server & location] - Do not copy a selected folder. I did this because DFSROOT would not copy and error out. It would take HOURS to sync that with the /r & /w /log [location] - output a log to see what failed and what copied. Hope that helps some. Good luck