2 Replies Latest reply on Oct 27, 2008 7:44 PM by zman

    Querie to find Profiles on PCs


      Any ideas as to how to create a querie to either....


      search all PCs for a specific profile in c:documents and settings .... I.E.  find all PCs that have the JohnA profile saved


      or find and list all profiles stored on all PCs?

        • 1. Re: Querie to find Profiles on PCs
          zman Master

          That's a tough one. The information is not currently stored via LANDesk.  So you would have to turn to scripting.  So the second part is what do you do with all the profiles when you extract them? The only way I can see this being usable, is to grab just the user name and put it into a seperated list and stick it into a registry key.  We have machines in our shop that have 200+ profiles so the string would be very long. 

          • 2. Re: Querie to find Profiles on PCs
            zman Master

            Here is some raw Autoitscript code that sucks the profile names out of the registry, puts the names in a delimited string, and writes them to the registry to be picked up by LANDesk.  Test and use at your own risk. Not sure of the limitations/size of REG_SZ or the field size that LANDesk will accept.  I have not tested this within LANDesk, and was just kind of bored and have not scripted anything in a long time.


            ;Use at your own risk-somewhat untested and written in a drug induced state.
            #Include <Array.au3>
            Dim $PP                                             ;Profile Image Path
            Dim $Array                                        ;Array for Strin Split
            Dim $Regkeytowrite                              ;Var to hold the delimited string to write to reg key
            Local $avArray[1]                              ;Final Array
            ; Let's just get 400 Profiles since I don;t know the max size of REG_SZ, and I'm too lazy to look it up.
            For $i= 1 to 400
                 ;Reads the name of a subkey according to it's instance.
                $var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\Windows NT\currentversion\profilelist", $i)
                 ;Dump out if there is an error
                If @error <> 0 then
                 ;Store ProfileImagePath, this contains the profile name %SystemDrive%\Documents and Settings\Administrator
                 $PP = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\Windows NT\currentversion\profilelist\"& $var,"ProfileImagePath")
                 ;Convert to all lowercaseUpper for consistency
                 $PP = StringLower ($PP)
                 ;Don;t really need these profiles since they exist on all pcs; probably a fancier way to do this.
                      Case StringInStr ($PP,"systemprofile") <> 0
                      Case StringInStr ($PP,"LocalService") <> 0
                      Case StringInStr ($PP,"NetworkService")     <> 0
                      Case StringInStr ($PP,"Administrator")     <> 0
                      Case Else
                           ;Split the ProfileImagepath with \ 
                           $Array  = StringSplit($pp,"\")
                           ;We just want the 3 element the username
            ;Pump the array to a delimited string 
            $Regkeytowrite =_ArrayToString($avArray,"|",1)
            ;Let's write to the magic LANDesk Registry Key
            Regwrite("HKLM\Software\Intel\Landesk\Inventory\Custom Fields", "Profiles", "REG_SZ", $Regkeytowrite)