cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

Scripting Tool Command - CheckForMachineKey

Hello,

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?

Thanks

8 Replies
Highlighted
Reliable Contributor
Reliable Contributor
Report Inappropriate Content
Message 2 of 9

Re: Scripting Tool Command - CheckForMachineKey

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?

Highlighted

Re: Scripting Tool Command - CheckForMachineKey

Hello,

Thanks for the response, I am currently trying to mitigate the machines that have different machine names/network names by using the command below:

CALL "%~dp0..\3M_SBConnectionInfo.cmd"

%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?

Thanks

Highlighted
Reliable Contributor
Reliable Contributor
Report Inappropriate Content
Message 4 of 9

Re: Scripting Tool Command - CheckForMachineKey

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

     else

            do nothing

     end if

next

now, what do you want to do if the network name does not exist in eem ?

Highlighted

Re: Scripting Tool Command - CheckForMachineKey

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?

Highlighted
Reliable Contributor
Reliable Contributor
Report Inappropriate Content
Message 6 of 9

Re: Scripting Tool Command - CheckForMachineKey

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?

Highlighted

Re: Scripting Tool Command - CheckForMachineKey

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

else

     if getlocalmachinename = netbios name then

          do nothing

     else

          write localmachinename and netbios name to wrong_name.txt

     endif

     if getmachinekey(localmachinename) = false then

          write localmachinename to no_db_key.txt

     else

          do nothing

     endif

endif

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.

Highlighted
Reliable Contributor
Reliable Contributor
Report Inappropriate Content
Message 8 of 9

Re: Scripting Tool Command - CheckForMachineKey

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.

Highlighted

Re: Scripting Tool Command - CheckForMachineKey

Thanks guys, I'll check them out and see if I can get it working in our envrironment.

You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community