/build/static/layout/Breadcrumb_cap_w.png

How to fetch a xml file name via Custom inventory Rule



Hi 


I want to read the file name as below and trim it using CIR. 

File location C:\Program Files\IBM\Notes\Data

File name 
CN=Greg Nixon_OU=MEL_OU=AUS_OU=APAC_O=COMPUTINGSolutions.xml

any commands to trim this file name ? i want to start the trim the file name from  Greg Nixon till _ score  CN=Greg Nixon_OU=MEL_OU=AUS_OU=APAC_O=COMPUTINGSolutions.xml

click to view the image

CQLhoM.bmp

1 Comment   [ + ] Show comment
  • out of 1900 machines 900 machines were able to execute the script successfuly but other machines are not able to run this CIR rule, how can i check what stops it from running the CIR rule created.


    this my command in bat file

    ======================================================================================================================
    powershell.exe -nologo -Executionpolicy Bypass -WindowStyle Hidden -noprofile -file C:\ProgramData\Dell\KACE\downloads\33593\usernamefind.ps1
    =======================================================================================================================




    Powershell script

    if ((gwmi win32_operatingsystem | select osarchitecture).osarchitecture -eq "64-bit")
    {
    #64 bit logic here
    gci "C:\Program Files (x86)\IBM\Notes\Data\workspace\.metadata\.plugins\com.ibm.collaboration.realtime.login\*.xml" | % {($_.name.split('_')[0]).substring(3)} | Out-File C:\Windows\Temp\USERNAMES.txt -Force

    }

    else
    {
    #32 bit logic here
    gci "C:\Program Files\IBM\Notes\Data\workspace\.metadata\.plugins\com.ibm.collaboration.realtime.login\*.xml" | % {($_.name.split('_')[0]).substring(3)} | Out-File C:\Windows\Temp\USERNAMES.txt -Force

    } - rahimpal 6 years ago

Answers (1)

Answer Summary:
Posted by: flip1001 7 years ago
Black Belt
1

Top Answer

I tried these in a command prompt but using the echo command instead of dir since I don't have this program.

You may have to adjust the settings, and also I assume there is only 1 xml file in that directory.

cmd
for /f "tokens=1 delims=_" %a in ('dir /b "C:\Program Files\IBM\Notes\Data\*.xml"') do set filename=%a && echo %filename:~3%

powershell
gci "C:\Program Files\IBM\Notes\Data\*.xml" | % {($_.name.split('_')[0]).substring(3)}

Comments:
  • thanks a lot for posting these.


    \Program was unexpected at this time.

    C:\>for /f "tokens=1 delims=_" \Program Files\IBM\Notes\Data\workspace\.metadat
    a\.plugins\com.ibm.collaboration.realtime.login\*.xml"') do set filename=filenam
    e:~3 - rahimpal 7 years ago
  • gci "C:\Program Files\IBM\Notes\Data\*.xml" | % {($_.name.split('_')[0]).substring(3)}


    this is perfect, but i want to try through batch commands as powershell success is not 100% in our network, also sometimes consumes CPU - rahimpal 7 years ago
  • C:\Program Files\Dell\KACE>set filename=CN=Robert Chris && echo %filename:~3%
    %filename:~3%


    i get above output in CIR , how can i trim and output only Robert Chris ?

    also how can i include


    for /f "tokens=1 delims=_" %a in ('dir /b "C:\Program Files\IBM\Notes\Data\*.xml"') do set filename=%a && echo %filename:~3%


    or


    for /f "tokens=1 delims=_" %a in ('dir /b "C:\Program Files(X86)\IBM\Notes\Data\*.xml"') do set filename=%a && echo %filename:~3%

    in same CIR - rahimpal 7 years ago
    • Try this

      ShellCommandTextReturn(cmd.exe /q /c if exist “C:\Program Files\IBM\Notes\Data\.” (for /f "tokens=1 delims=_" %a in ('dir /b "C:\Program Files\IBM\Notes\Data\*.xml"') do set filename=%a && echo %filename:~3%) else (for /f "tokens=1 delims=_" %a in ('dir /b "C:\Program Files(x86)\IBM\Notes\Data\*.xml"') do set filename=%a && echo %filename:~3%)) - flip1001 7 years ago
      • thanks again..

        i added this to CIR but i dont see any output in the inventory for x86 or 64 bit machines



        ShellCommandTextReturn(cmd.exe /q /c if exist “C:\Program Files\IBM\Notes\Data\workspace\.metadata\.plugins\com.ibm.collaboration.realtime.login\.” (for /f "tokens=1 delims=_" %a in ('dir /b "C:\Program Files\IBM\Notes\Data\workspace\.metadata\.plugins\com.ibm.collaboration.realtime.login\*.xml"') do set filename=%a && echo %filename:~3%) else (for /f "tokens=1 delims=_" %a in ('dir /b "C:\Program Files (x86)\IBM\Notes\Data\workspace\.metadata\.plugins\com.ibm.collaboration.realtime.login\*.xml"') do set filename=%a && echo %filename:~3%)) - rahimpal 7 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ