CA Client Automation

  • 1.  Discovering Network Printer's connected to a system

    Posted Sep 18, 2017 11:28 AM

    We currently have Inventory discover enabled and its discovering printers on systems, but it's only discovering non-network printers. 

     

    I took a look over some documentation for Inventory discovery, but I was not able to make it discover network printers.
    Inventory Detection Modules - CA Client Automation - 12.9 - CA Technologies Documentation 

     

    Has anybody had any experience with getting DSM to discover Network printers that a system is connected to?



  • 2.  Re: Discovering Network Printer's connected to a system
    Best Answer

    Posted Sep 18, 2017 12:33 PM

    Because Network Printers can be different for different users, this has to be collected on a per user basis. The attached scripts will collect this information per user. Also included (in case anybody is interested) a script to collect shared drives per user. Instructions to implement are below:

     

     

       

    •   Script GetShares.dms

          

    •   collects the share information when users log on.

          

    •   Does not create any inventory directly, only creates an INI file in the ‘Agent\Units’ directory

          

    •   Use it to create a ‘script’ type UAM job which should be assigned to the ‘All User Accounts’ group

          

    •   There is a problem in Windows 10 and potentially 8.0/8.1 as well, which causes shares created by an administrator account not to be visible when running with elevated privileges (which of course the Agent is).

             

    •   May require the following registry setting to fix: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System DWORD value EnableLinkedConnections=1

             

       

    •   Script GetPrinters.dms

          

    •   collects the printer information when users log on.

          

    •   At this point, collects ‘DeviceID’, ‘Driver Name’ and ‘Port’ for all printers, not just network printers. If I have more detail on what network printers really look like, I can filter it accordingly.

          

    •   Does not create any inventory directly, only creates an INI file in the ‘Agent\Units’ directory

          

    •   Use it to create a ‘script’ type UAM job which should be assigned to the ‘All User Accounts’ group

       

    •   Script UserInventory.dms

          

    •   collects the previously saved user information and creates inventory when the AM Agent collects.

          

    •   Designed to be multi-purpose. It will read properly formatted data with all kinds of user-based info

          

    •   Reads all INI files in the ‘Agent\Units’ directory which start with ‘User_Inv_”, creates a corresponding MIF file in the Agent collect directory for each one.

          

    •   May take a little while to start collecting data since it relies on users logging on to create its input files.

          

    •   Use it to create a ‘script’ type UAM job which should be assigned to the ‘All Computers’ group

     

     

    Steve McCormick, ITIL

    CA Technologies

    Principal Services Consultant

    Stephen.McCormick@ca.com

    <mailto:Stephen.McCormick@ca.com>

    Attachment(s)

    zip
    UserInventory.dms.zip   1 KB 1 version
    zip
    GetPrinters.dms.zip   1 KB 1 version
    zip
    GetShares.dms.zip   878 B 1 version


  • 3.  Re: Discovering Network Printer's connected to a system

    Posted Oct 05, 2017 06:50 AM

    Good piece of script  - THX


    But I have one small issue - my share address is quite long and it seems doesn't work

     

    TXT:

     

    Server:

     

    "short one" works brilliant...

     

    It will be really cool, if You take a look at this

    Regards

    PM



  • 4.  Re: Discovering Network Printer's connected to a system

    Posted Oct 09, 2017 03:50 PM

    Hi Pajqk,

     

    First problem I see here is the language. Since I wrote the script in English using an English language computer, and used some English text from the output of the ‘Net Use’ command to parse the output, it is resulting in some bad entries in your Polish(?) system. Easy fix. In the script there is a line:

     

                       IF NOT(Instr(Line,"New connect") OR Instr(Line,"Status") OR Instr(Line,"----") OR Instr(Line,"The command") OR Instr(Line,"There are") OR Len(Trim(Line)) = 0) THEN

     

    Update this line with the Polish or other language equivalents as they appear in the ‘net use’ output so these lines are not considered as shares.

     

    The other part of your problem is more difficult. Since ‘net use’ also does not list your shares properly and it is this output I am reading, the script also will not work. We can look to see if WMIC lists the drives correctly and adjust the script to read WMIC output instead of net use. Please try the following command on your system to see if it correctly lists the paths:

     

                    wmic logicaldisk where drivetype=4 get caption,providername

     

    Steve McCormick, ITIL

    CA Technologies

    Principal Services Consultant

    Stephen.McCormick@ca.com

    <mailto:Stephen.McCormick@ca.com>



  • 5.  Re: Discovering Network Printer's connected to a system

    Posted Oct 11, 2017 01:18 AM

    Thank You for explanation.
    I gonna try to change scripts for wmic (lists drives correctly)...



  • 6.  Re: Discovering Network Printer's connected to a system

    Posted Oct 11, 2017 08:19 AM

    I can change the script if you like, just needed to know if WMIC works for you. I think you’ll have a problem reading the WMIC output since it is double-byte formatted but I have a function to read it

     

    Steve McCormick, ITIL

    CA Technologies

    Principal Services Consultant

    Stephen.McCormick@ca.com

    <mailto:Stephen.McCormick@ca.com>



  • 7.  Re: Discovering Network Printer's connected to a system

    Posted Oct 11, 2017 11:51 AM
      |   view attached

    Getshares script updated to use WMIC instead of Net Use commands in order to handle long share names properly.

     

    Please note: If you are running this script on a non-english computer, WMIC may use different header information and the script will need to be modified accordingly. The following two lines should be updated to reflect the output of a ‘wmic logicaldisk where drivetype=4 get caption,providername’ command :

     

       IF Instr(Line,"Caption") THEN

    iStart2 =  InStr(Line,"ProviderName")

     

    Replace the words in the quotes with the appropriate headings from WMIC.

     

    Steve McCormick, ITIL

    CA Technologies

    Principal Services Consultant

    Stephen.McCormick@ca.com

    <mailto:Stephen.McCormick@ca.com>

    Attachment(s)

    zip
    GetShares.dms.zip   1 KB 1 version


  • 8.  Re: Discovering Network Printer's connected to a system

    Posted Oct 12, 2017 01:01 AM

    WOooo... You are my personal hero - thanks a lot !