none
Find text in .ini file which is in subfolders and print if the text exists Yes or No to csv RRS feed

  • Question

  • Hi, we have a INI files in user directories (home\profiles\%username%). need to create a powershell script to go to each file and look for text and if text exists print yes else No to CSV. 
    Thursday, October 29, 2020 1:59 PM

All replies

  • Use Get-Content to retrieve the INI file and pipe the results to Select-String with the desired pattern.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Thursday, October 29, 2020 2:49 PM
  • Thanks Rich, i think we may need to use get-childitem instead of get-content since it has to fetch the data in multiple subfolders.
    • Edited by sn84176 Thursday, October 29, 2020 6:17 PM
    Thursday, October 29, 2020 6:17 PM
  • Thanks Rich, i think we may need to use get-childitem instead of get-content since it has to fetch the data in multiple subfolders.

    Get-Content does exactly that.   Please always read the help before making statements that are observably false.  Guessing in science and technology will almost always get you and those around you in trouble.

    I know most people coming into this forum today are not trained in science, math or technology because none of that is needed to use simple GUI tools.  Unfortunately it is necessary to know these things to actually use non-GUI tools.

    Consider that all you need to know can be obtained as follows:

    Get-Content -?

    This would immediately tell you that Get-Content can do almost anything that Get-ChildItem can do.  The real issue is that, without science, technology and math you wouldn't know how to get this information.  We see this because you are making preposterous claims about whether Rich's answer can work and you did this without even typing the above example.

    You need to take time to learn some basic things about how the world works and how to use that knowledge to learn about technology.

    Rich's answer is the correct answer and will do what you ask.  It is up to you to learn enough to understand your own questions and how to research the answers that you are not capable of understanding without that research.

    Push on and learn.  It is not painful and is actually fun.  Don't use4 guesswork.  In science we do not guess.


    \_(ツ)_/

    Friday, October 30, 2020 12:27 AM
  • There was no mention of subfolders in your original question. If you need to descend a folder hierarchy use Get-ChildItem with the -Recurse and -Include parameters. Pipe the results of that to Get-Contents, etc.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Friday, October 30, 2020 2:13 AM