I'm currently looking to try and create a script that would utilize the CheckForMachineKey command. What I'd like to do is get a software inventory dump from SCCM or other utility and put it in a csv file. Once the file is created, I'd like the script to run against the computer names that state EEPC is installed on and have it check the console to ensure a key is located in it for that machine. If it detects a key in the console, it just moves on, if it doesn't see a key in the console it would write that pc name to a log file.
Has anyone done this before or have some sample code that would be close?
it would not be hard, but the challenge you have of course is that the netbios name and eem names don't have to be the same, and you can have multiple machines in eem with the same network name, but different eem names..
so, how would you reconcile the two? Assume that if the network name and eem name are the same, that the machine in EEM is indeed the one SCCM is talking about?
I can probably throw this together for you on Monday if you need it - it's probably only a dozen lines of code + the API class. Why don't you take a stab of documenting the logic here first and I'll wrap some code around for you - try some psudo-code etc?
Thanks for the response, I am currently trying to mitigate the machines that have different machine names/network names by using the command below:
%CommandPrefix% -Command:RenameMachineToNetworkName -Group:* >Machine_Rename.log
So I believe that part of it is covered. So what I'm trying to do is run a query against SCCM that reports all machines with Sbclientmanager.exe on them and export it to a file called EEPC_Installed.csv. Once I have the report, I'd like to run all computer names in that csv file against the console to see if we have a machine key in it, if it does find a key, it moves onto the next pc in the list, if it doesn't it writes that machine to a log file called No_DB_Key.txt, and moves to the next pc in the list, until all have been processed.
Does that make sense?
so for starters..
for each network name in eepc_installed.csv
if getmachinekey(network name) = false then
write network name to no_db_key.txt
now, what do you want to do if the network name does not exist in eem ?
This might be a dumb question, but if the network name doesn't exist in EEM, isn't that already being written out to the no_db_key.txt?
true, but that entry does not mean that the machine in question does not have a key in EEM, it means that network name does not - the difference might be significant to you?
If you borrow some code from AutoDomain, you should be able to do the following and take care of both scenarios.
if getlocalmachinename = false then
write netbios name to no_db_key.txt
if getlocalmachinename = netbios name then
write localmachinename and netbios name to wrong_name.txt
if getmachinekey(localmachinename) = false then
write localmachinename to no_db_key.txt
I'm sure I left out some crucial debugging.
I would note that I've experienced a bit of an issue with the getlocalmachinename routine used in AutoDomain. Your backup method to look into the actual SBFS to find the machine's name is the issue. The script works fine, but it seems that if I manually rename a machine in the EEM, the new name is NOT reflected in the local SBFS. I see this as a fault of the software, as this should be updated with a sync. We have discussed this with support to no resolution. Therefore, I removed that code and instead checked that we were running as an admin, and that I could ping the server before continuing with the steps above.
You'll find your file here https://sites.google.com/site/ctogonewild/Home/intersting-files (CheckMachinesInCDFHaveAKey.zip)
it should work - I have not tested it much (ok, at all!) and the output is up to you to write, it's pretty simple VBS. Just pay attention to the last few lines of code, everything above is just a helper class.