#189659 - 2008-09-14 05:57 AM
Putting it all together.....
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
Hi, have a questions, ok several that i hope someone will be kind enough to help me along the way. A little background, I am a network designer but volunteer at my church helping with the IT stuff. Originally I was just to support the network side of things but ended up doing much more and the latest is setting up a new server/domain controller. I have pretty much have the server pretty much ready to go and the last thing that I am struggling with is login scripts. Most of all of my work/play deal with linux, so you can see that I have had to read quite alot regarding MS servers and how they like to do things. So here is what I am trying to accomplish I have most of the pieces I just need a better understanding of how to put it together.
What I would like to accomplish is to create a Outlook/exchange profile if the user needs one (I want to use Kdyers code, i have created my outlook profile), mount certain drives on the server based on groups ( I have code to do this), mount the common network printers ( I have code to do this). So what I am wrestling with is how to have a main script that runs and then calls each of the subscripts to complete. I am also trying to understand how to/where to place the files on the server. I am using SBS 2003 R2 and intend to use a GPO and assign a startup script to accomplish. If anyone has some guidance/how to's that would help me on my way it would be greatly appreciated. Thanks.
|
|
Top
|
|
|
|
#189662 - 2008-09-14 02:39 PM
Re: Putting it all together.....
[Re: Mart]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
|
Biscuit,
Welcome!
1. You could use the pre-built login script from my site to do all of this. This script is in use at dozens of sites without code modification.
Simply define the resource records in the config file to map drives and printers. You can control what is mapped by generic privilege (anyone, notguest, admin), group membership, or OU membership. There are complex mapping capabilities - you can require membership in multiple groups; membership in one (set of) group(s) and not other(s); or even map only when the user is NOT a member of a (set of) group(s).
Another powerful feature is path rewriting. This lets you map dozens of different resources to the same place based on user, group, OU, or network subnet. Let's say you have 10 departments and each has a unique share. You decide that each department should map their share to the T: drive. Each department is represented by a distinct OU. You could create 10 resource records based on the OU membership, or, you could create 1 resource record and 10 lookup values using Path Rewriting. The resource path "&OU:Dept&" would be translated to a correct UNC path by looking for the user's OU in the Dept lookup record.
Once basic resource mappings are complete, you can display message files and run commands to customize the user environment, such as using Kent's Outlook profile script. You can Run them asynchronously, Shell them to run synchronously, or even Call other Kix scripts, taking advantage of the built-in variables and UDFs.
2. \\MyDomain\netlogon is probably the quickest/easiest way to push files to the netlogon share across the network, where they will be replicated to other DCs. In SBS, it's unlikely you'd have a second DC, and even if you did, it would be not be of much value.
3. You can't use Startup scripts - those control computer initialization, not user environment initialization. If you're new to login scripting, I'd avoid using GPOs to define them and instead simply define "Kix32.exe" in each user's Login Script profile field, especially in an SBS environment where there's no dedicated admin. Do you really want "Joe's cousin's son" (he has a PC at home...) tinkering with GPOs when you're on vacation? Been here, done this - SBS+Volunteer=Keep It Simple!
LogIn scripts - defined in the user profile - run in an envoinment where the Netlogon share is the initial directory. This makes things easy to find. LogOn scripts - defined by GPO - need to have full UNC paths defined for everything, and are a bit less forgiving. Also, referencing UNC paths for everything, admins often refer to specific servers - \\server\netlogon - instead of the domain - \\%USERDOMAIN%\netlogon. This practice can wreak havoc when DCs are downed for maintenance or replaced. This is almost the same as Mart's "@ldrive + '\mapdrivesscript.kix'" - I just prefer a system environment var over the macro. $LDRIVE isn't a drive letter as the name implies, but a UNC reference to the Netlogon share on the authenticating DC. It really doesn't matter which you use - "6 of one, half dozen of another" as they say in the Old Country. Just pick one method and use it consistently.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#189744 - 2008-09-19 04:37 AM
Re: Putting it all together.....
[Re: Glenn Barnas]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
Thanks Matt and Glenn, so I have been looking at Glenns scripts and reading, reading...I have 2 little ones so I can only do things later, ya know like I have all the free time I want from 8:30 to 6am, lol. So what I am trying to figure out is how to put it to use I know you say to use /sysvol/ directory and I see that but SBS has a default bat file that is used when you connect a new PC to the domain, it looks something like this: \\xyzSERVER02\Clients\Setup\setup.exe /s xyzSERVER02
So my question is Glenn, how do I go about incorporating your scripts with the one that is already there, I wasn't sure if I could just put all of the files in there or if I needed to do something else. I know this is probably a noob question but I can't seem to find the answer anywhere...Thanks for the universal script and your help...
|
|
Top
|
|
|
|
#189778 - 2008-09-21 06:58 PM
Re: Putting it all together.....
[Re: biscuit]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
Glenn, First off thanks for the site and scripts I am reading and playing with them right now. One question that I have is that why can I not read the contents of the kixstart.kix file, I thought this would be a normal text based script file. What am i missing? Thanks.
|
|
Top
|
|
|
|
#189791 - 2008-09-22 02:41 PM
Re: Putting it all together.....
[Re: Glenn Barnas]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
Thanks Glenn, I have most of it working the way that I want it would just be nice to be able to look at the code (I come from an open source world), I can understand about folks modifying etc, but if I am to install the code in a production environment it would be nice to be able to see what the actually code looks like. The last thing that I need to integrate is kdyers outlook profile creation, so far I am calling everything from the login.bat file and I was just going to call his script after calling yours, just add an additional \0%\kix32.exe outlook.kix, or is there a better way. In kdyers notes it says you just need to call outlook but i think that is from a kix script...anyone have any suggestions. Thanks.
|
|
Top
|
|
|
|
#189792 - 2008-09-22 03:08 PM
Re: Putting it all together.....
[Re: biscuit]
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
Configuring Outlook from a kix script is kinda easy. Have a look at the script below.
What does it do? 1 - Get the path to outlook.exe from the registry. 2 - Get the productversion of outlook.exe. 3 - Select the actions to take based on the version (11 = 2003 and 12 = 2007) 4 - Copy the default profile from the server to a private location for the user. 5 - Delete the FirstRun registry value so outlook does not prompt to setup a mail account the first time it is started. 6 - Set the ImportPRF registry value and point it to the location you copied the profile to.
The default profile can be created with the custom installation wizard that comes free as part of the resource kit on every Office 2003 CD or can be downloaded from the Microsoft website as part of the Office 2003 resource kit.
Break on
;Get outlook version
$olpath = ReadValue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "Path")
$olversion = GetFileVersion($olpath + "outlook.exe", "ProductVersion")
Select
Case Left($olversion, 2) = "11"
;Outlook 2003
Copy @LDRIVE + "\tools\outlook2003.prf" @HOMESHR + "\" + @USERID + "\outlook.prf"
$rc = DelValue("HKCU\Software\Microsoft\Office\11.0\Outlook\Setup", "First-Run")
$rc = WriteValue("HKCU\Software\Microsoft\Office\11.0\Outlook\Setup", "ImportPRF", @HOMESHR + "\" + @USERID + "\outlook.prf", "REG_SZ")
Case Left($olversion, 2) = "12"
;Outlook 2007
Copy @LDRIVE + "\tools\outlook2007.prf"
$rc = DelValue("HKCU\Software\Microsoft\Office\12.0\Outlook\Setup", "First-Run")
$rc = WriteValue("HKCU\Software\Microsoft\Office\12.0\Outlook\Setup", "ImportPRF", @HOMESHR + "\" + @USERID + "\outlook.prf", "REG_SZ")
EndSelect
[edit] Now that I'm think about it it might be best to build in a check if outlook is actually installed and not do all this stuff when it is not. I copied the code from my logon script and all clients always have outlook so it was not necessary to check for the presence of outlook.
something like:
If $olpath <> ""
; configure outlook.
Else
; do nothing.
EndIf
[/edit]
Edited by Mart (2008-09-22 03:14 PM)
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
#189893 - 2008-09-26 04:01 AM
Re: Putting it all together.....
[Re: Glenn Barnas]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
So where can I can I find the mkOprofile.kix file? I looked on your site but if it is there I missed it. Thanks.
|
|
Top
|
|
|
|
#189913 - 2008-09-27 07:16 AM
Re: Putting it all together.....
[Re: Mart]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
Configuring Outlook from a kix script is kinda easy. Have a look at the script below. What does it do? 1 - Get the path to outlook.exe from the registry. 2 - Get the productversion of outlook.exe. 3 - Select the actions to take based on the version (11 = 2003 and 12 = 2007) 4 - Copy the default profile from the server to a private location for the user. 5 - Delete the FirstRun registry value so outlook does not prompt to setup a mail account the first time it is started. 6 - Set the ImportPRF registry value and point it to the location you copied the profile to. The default profile can be created with the custom installation wizard that comes free as part of the resource kit on every Office 2003 CD or can be downloaded from the Microsoft website as part of the Office 2003 resource kit.
Break on
;Get outlook version
$olpath = ReadValue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "Path")
$olversion = GetFileVersion($olpath + "outlook.exe", "ProductVersion")
Select
Case Left($olversion, 2) = "11"
;Outlook 2003
Copy @LDRIVE + "\tools\outlook2003.prf" @HOMESHR + "\" + @USERID + "\outlook.prf"
$rc = DelValue("HKCU\Software\Microsoft\Office\11.0\Outlook\Setup", "First-Run")
$rc = WriteValue("HKCU\Software\Microsoft\Office\11.0\Outlook\Setup", "ImportPRF", @HOMESHR + "\" + @USERID + "\outlook.prf", "REG_SZ")
Case Left($olversion, 2) = "12"
;Outlook 2007
Copy @LDRIVE + "\tools\outlook2007.prf"
$rc = DelValue("HKCU\Software\Microsoft\Office\12.0\Outlook\Setup", "First-Run")
$rc = WriteValue("HKCU\Software\Microsoft\Office\12.0\Outlook\Setup", "ImportPRF", @HOMESHR + "\" + @USERID + "\outlook.prf", "REG_SZ")
EndSelect
[edit] Now that I'm think about it it might be best to build in a check if outlook is actually installed and not do all this stuff when it is not. I copied the code from my logon script and all clients always have outlook so it was not necessary to check for the presence of outlook. something like:
If $olpath <> ""
; configure outlook.
Else
; do nothing.
EndIf
[/edit]
So I have not had any luck getting Kent's code to work I have a profile and looking at your code, going to try it next...couple of questions. If There is a profile already there do you re-create it? Looks like you are using @homeshr, what are my other options, I have folder redirection enabled so I am not sure what the best place is...Just so you know this is on a SBS 2003 R2 machine...Thanks.
|
|
Top
|
|
|
|
#189915 - 2008-09-28 06:43 AM
Re: Putting it all together.....
[Re: biscuit]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
Mart/Glenn, Need some advice...I am using Mart's code above and it's kind of working..;) when I run it from the machine it works however when I run it from the netlogon directory it doesn't....and I think I have figured it out. When it runs from the netlogon directory this environment variable doesn't get set....
$olpath = ReadValue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "Path") $olversion = GetFileVersion($olpath + "outlook.exe", "ProductVersion")
and it's because on the server I don't have outlook installed so it returns a blank, so the question is how can I have these ran against the local machine that is logging in instead. I will keep reading but thought this would be a softball for you guys.. Thanks.
|
|
Top
|
|
|
|
#189917 - 2008-09-28 03:13 PM
Re: Putting it all together.....
[Re: Glenn Barnas]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
How are you invoking the command when you are testing? It shouldn't matter where the script is.. On the PC where you are testing, you should run
\\MyDomain\netlogon\kix32.exe \\MyDomain\netlogon\OutlookScript.kix Of course, change the MyDomain to your local domain name, and the proper script name (and subfolder path, if used). The commands you pointed out reference the local computer (where the script is running) and not the computer where the script is stored. Glenn
Ok, So when I run it that way it works, however when it is ran from the logon script it is not working, when I mean not working it is not copying the file to the location that I want it to. Here is what I have in my logon.ini file:
[CreateOutlookProfile] CLASS=COMMAND PATH=\\domainname\netlogon\outlook.kix METHOD=CALL
all of the files are in the netlogon directory, any thoughts?
Edited by biscuit (2008-09-28 06:43 PM)
|
|
Top
|
|
|
|
#189918 - 2008-09-28 07:18 PM
Re: Putting it all together.....
[Re: biscuit]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
Mart/Glenn, ok so it looks like I am getting errors on the variables in Mart's script, which is listed above they are:
$olversion = GetFileVersion($olpath + "outlook.exe", "ProductVersion") $olpath = ReadValue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "Path")
Funny thing is if I manually run the script from the workstation ie, \\domainname\\netlogon\kix32.exe \\domainname\netlogon\outlook.kix it works, but I get errors when defined in the login.ini, I have tried call/shell etc...thanks for providing tips to look at...
|
|
Top
|
|
|
|
#189920 - 2008-09-28 08:16 PM
Re: Putting it all together.....
[Re: biscuit]
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
Maybe the errors come up because all variables should be dimmed in your script. Do you have SETOPTION("Explicit", "On") in the main script? If so then you need to declare (DIM) all the variables used in the script you got from me. If not then can you lets us know what error come up? Is it just empty variables or does kix actually give some kind of error?
....
If There is a profile already there do you re-create it? Looks like you are using @homeshr, what are my other options, I have folder redirection enabled so I am not sure what the best place is...Just so you know this is on a SBS 2003 R2 machine... ….
I use @homeshrs because it is a unique location for every user (at least in my network it is), you can use whatever you want as long as the location is accessible for the user. If you have redirected some folders that should be no problem because the @homeshr macro is filled with the data that is in the user’s properties in AD. Yep, every time the script runs it sets the registry values. That is one of the flaws in the script. It does not really matter but it could slow things down (don’t know the difference in time for checking a registry value and writing a registry value). A check to see if a profile exist and do the magic when there is no profile might be better.
.... When it runs from the netlogon directory this environment variable doesn't get set.... ....
Try the code below (as a logon script) on a test user. I put in lots of debugging lines so you can see where thing go wrong. All screen output is written to a file called outlook_config_log.txt on the c: drive of the system that you are logging on to.
.... and it's because on the server I don't have outlook installed so it returns a blank, so the question is how can I have these ran against the local machine that is logging in instead. ....
Nope, it is not because on the server outlook is not installed. If you run it as a logon script it runs in the environment of user that is logging on.
Break on
ReDirectOutput("c:\outlook_config_log.txt", 1)
;Get outlook version
$olpath = ReadValue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "Path")
?"Outlook path = " $olpath
$olversion = GetFileVersion($olpath + "outlook.exe", "ProductVersion")
?"Outlook version = " $olversion
Select
Case Left($olversion, 2) = "11"
;Outlook 2003
Copy @LDRIVE + "\tools\outlook2003.prf" @HOMESHR + "\" + @USERID + "\outlook.prf"
$rc = DelValue("HKCU\Software\Microsoft\Office\11.0\Outlook\Setup", "First-Run")
?"Deleting first run registry value result: " $rc
$rc = WriteValue("HKCU\Software\Microsoft\Office\11.0\Outlook\Setup", "ImportPRF", @HOMESHR + "\" + @USERID + "\outlook.prf", "REG_SZ")
?"Write import prf registry value result: " $rc
Case Left($olversion, 2) = "12"
;Outlook 2007
Copy @LDRIVE + "\tools\outlook2007.prf"
$rc = DelValue("HKCU\Software\Microsoft\Office\12.0\Outlook\Setup", "First-Run")
?"Write import prf registry value result: " $rc
$rc = WriteValue("HKCU\Software\Microsoft\Office\12.0\Outlook\Setup", "ImportPRF", @HOMESHR + "\" + @USERID + "\outlook.prf", "REG_SZ")
?"Write import prf registry value result: " $rc
EndSelect
ReDirectOutput("")
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
#189922 - 2008-09-28 10:15 PM
Re: Putting it all together.....
[Re: Mart]
|
biscuit
Fresh Scripter
Registered: 2008-09-14
Posts: 16
|
Thanks Mart for the reply let me give you both pieces, I am using Glenn's script but alsotrying to use yours that work just not both together so here goes....my login.ini which is used by Glenn's kixxtart file:
[CreateOutlookProfile]
CLASS=COMMAND
PATH=\\dpcserver02\netlogon\outlook.kix
METHOD=call
Mart's code with embellishments ( I am still messing with and have alot commented out right now:
$olversion = GetFileVersion($olpath + "outlook.exe", "ProductVersion")
$olpath = ReadValue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "Path")
;If $olpath <> ""
;If NOT Exist (@LSERVER + "\" + "users\" + @USERID + "\outlook.prf")
; configure outlook profile
;Get outlook version
Select
Case Left($olversion, 2) = "11"
;Outlook 2003
;Copy @LDRIVE + "outlook2003.prf" @HOMESHR + "\" + @USERID + "\outlook.prf"
Copy @LDRIVE + "outlook2003.prf" + " " @LSERVER + "\" + "users\" + @USERID + "\outlook.prf"
$rc = DelValue("HKCU\Software\Microsoft\Office\11.0\Outlook\Setup", "First-Run")
$rc = WriteValue("HKCU\Software\Microsoft\Office\11.0\Outlook\Setup", "ImportPRF", @LSERVER + "\" + "users\" + @USERID + "\outlook.prf", "REG_SZ")
Case Left($olversion, 2) = "12"
;Outlook 2007
;Copy @LDRIVE + "outlook2007.prf" @HOMESHR + "\" + @USERID + "\outlook.prf"
Copy @LDRIVE + "outlook2007.prf" + " " @LSERVER + "\" + "users\" + @USERID + "\outlook.prf"
$rc = DelValue("HKCU\Software\Microsoft\Office\12.0\Outlook\Setup", "First-Run")
$rc = WriteValue("HKCU\Software\Microsoft\Office\12.0\Outlook\Setup", "ImportPRF", @LSERVER + "\" + "users\" + @USERID + "\outlook.prf", "REG_SZ")
EndSelect
;EndIf
;Else
; do nothing.
;EndIf
It's the first 2 variables that it is having problems with, either one gives me:
error undefined variable [olversion]!
or
error undefined variable [olpath]!
I'm not sure about the SETOPTION, i've been reading through Glenn's documentation buit nothing has jumped out at me. Thanks.
Edited by biscuit (2008-09-28 10:15 PM)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 293 anonymous users online.
|
|
|