First you need to setup up your preferred server configuration correctly otherwise this will not work at all. IE imaging folder (location of OS file) setup exactly as your core and have your permissions setup to replicate/access. Second, when deploying the OS (selecting the location of the WIM or TBI file) you should see check boxes to first use preferred servers. You can also do the same for post install and system configuration within the template. If you can explain your ultimate goal using preferred servers, I can go into more detail.
1 of 1 people found this helpful
In addition to the above - if you want to see / play around with this stuff in a controlled method (that is to say - from command line) be it in WinPE or in a full Windows Agent, have a look at this - How to use PEDownloader.exe to Duplicate / Troubleshoot Software Distribution .
But yes - the Preferred Server stuff is set up on the Core & the client downloads it automatically.
Thanks guys, but you both totally missed the intent of my question. I don't want to know how to use preferred servers, I want to know how to use the environment variable LDMS_PREFERRED_SERVER from within PE...
What I'm trying to do... I've written a DriverClient of our own, cause quite frankly, LANDESK's sucks. Any whooo, I use a command line argument to pull from a preferred server (i.e. driverclient.exe installhh). With 2016 I'm trying to take my 30 templates and pare them down to 6 or so by using preferred servers and conditionals. I think I may just have to rewrite my client to check if I: is mapped, if not use a default server. It would be REALLY nice though if it were accessible for stuff in the future though.
Okay, so you are wanting to have a template check its location or closest to the preferred server in WinPE to pull from it verses the core right?
If you trying to do that, an eaiser way would be to use Compare Variables in combination with If/Else statements.
Check out these articles, you can have it look for an IP subnet How to use Conditionals in LANDESK 2016 Provisioning
I store nothing on the core (just patches). I could do that but we have too many subnets and preferred servers for it to make sense doing. PLUS, LANDESK HAS ALREADY DONE IT! The idea was to piggyback off of the work of "connect to preferred server".
1 of 1 people found this helpful
OK - to clarify then...
Are you talking about accessing this (the INVENTORY variable) from a script?
... or are you talking about accessing the environment variable directly "on the client" as it were?
... if you literally just want to access the device-local OS environment variable, then use
or just "%LDMS_PREFERRED_SERVER%" as part of your command-line / input parameter or whatnot...
If you're after the inventory value, that CAN be done via run-time substitution, but requires a bit of careful thought potentially ...
... so yeah - this should give you a starting point. But it'd still be useful if you give us a fuller explanation of what you want to do precisely (and why - context helps), in case there are more elegant solutions?
Hope this helps?
I believe I explained what I needed it for quite well. At this point I've rewritten my driver client to handle it already but like I said, it could be useful in the future. I am looking to use the environment variable on the client.
Were you in PE when you echoed that??? I don't have it in PE.
Unfortunately, the variable is not available in WinPE...
I've written a VBscript that you can use to set it, but it assumes the Preferred Server name is an IP address though. You can find it in the ShareIT section somewhere.
Like I think you alluded to a few answers back wouldn't it just be as easy to have the template map a drive to the preferred server and you make use of it rather than trying to work it out yourself? That way all of the credentials required to connect and access have been setup for you and you just use the drive letter you decide to use as standard?
MarXtar Ltd/MarXtar Corporation
LANDESK One Development Partner
Try MarXtar State Management for LANDESK to Better Understand and Manage your Assets
2 of 2 people found this helpful
OK - so there are several things that should be explained, so that it can be appreciated what you're asking.
- Point 1 - whilst in Win PE, the client doesn't have access to its "full on Windows" environment variables. This should not need much explaining as the client is booting into effectively an entirely separate OS.
- Point 2 - By and large, whilst you can do run-time substitution of inventory attributes via CUSTJOB (i.e. - "Manage Scripts') you can't do it with 1:* (one-to-many) data relationships. 1:1 is fine - but 1:* is not - and environment variables are a 1:* data relationship.
- Point 3 - the actual purpose of the Environment Variable registry key is purely "human readability" - it's an easy way to add the preferred server information into inventory for people to read up on in easy strings. The client itself doesn't actually make use of it.
- Point 4 - Clients store their preferred servers in a file - C:\Program Files (x86)\LANDesk\LDClient\sdmcache\preferredservers.dat - which you can crack open in notepad happily enough (the file only lives for a max of 24 hours, so if your client doesn't have such a file, tell it to download a file & it'll build the preferred server list).
For reference, the contents are by and large just a simple CTIME datestamp & the name of the preferred server. So something like this:
- ... so you could always try to crack open the Preferredserver.dat file on the C:\-drive (or wherever you install the agent) & extract the string you want from there (obviously you'd need to do that before you blow the system away) via a script easily enough.
- Point 5 - You could equally write & resolve a query from the client via the MBSDK
Introduction with example scripts can be found here - Getting Started with the MBSDK (Example Scripts Included) - but you'd need to (a) script and (b) authenticate - all of which is doable (I'd suggest not hard-coding authentication into the "run" line, but simple passing them down as variables from Provisioning).
The relevant operation you'd be interested in would be "GetMachineData"-operation and since you'd want to do so dynamically - based on the device ID (which you will need to resolve separately) - you would need to build it on the fly. Ultimately, the query BNF you would want to run would look something like this (I'm using the browser way of accessing the MBSDK, as it's more demonstrative):
Which will net you information like the following in XML form, where you can then pick your desired inventory information from to your hearts' content:
... you'd control what data you're displaying easily by configuring a relevant custom column set - and in *THAT* you'd qualify the fact that you want to have the "ENVIRONMENT VARIABLE NAME = LDMS_PREFERRED_SERVER" logic like so (here's the exact column set I used - you'll see this name being used above):
You could get the device ID by querying for the MAC-address (which is how PXE identifies devices) in the same manner as above, for instance by using the "RunQuery" method & finding out which devicename / whatever has "your current MAC-address" ... that makes that bit nice & dynamic.
... and if you don't fancy doing it in VB, with LD 2016 you have PowerShell 1.0 on the WinPE image as well. So - chose your own poison.
So there you go - now you know how to access inventory data from any environment. You can do so via the MBSDK.
... personally, I'd argue it'd be easier to just use preferred servers "in-built" as they are, but since there's no clear explanation as to what's wrong with that, I came up with a way with which you can query anything.
2 of 2 people found this helpful
Unfortunately the maptopreferredserver action in LD2016 is not very reliable, especially when running a couple of provisioning tasks at the same time... (Awaiting bugfix here). In that case a variable that you can use on the command line for a net use command can be very useful. Also in full Windows we use the variable a lot for command line options with Distribution Packages.