Search for a specific string in web.config file

Hi
Is there a way we can search a specific word in web.config using powershell.
I have an entry of "user name" in the connection string. I want to find what the user name is and whether its a correct user name or not based on the criteria set in the script.
i believe its a simple matter of if statement but due to connection string i am unable to do this.
this is my connection string from web.config
    <connectionStrings>
    <add name="Membership" connectionString="Data Source=testdb;Initial Catalog=test;user   
    name=testUser;password=123456;MultipleActiveResultSets=true" 
    providerName="System.Data.SqlClient"/>
    </connectionStrings>
My criteria is. if user name -eq testUser write-host "correct user name" else "user name is incorrect"
This is the script which i am using
    $webConfig = 'C:\Users\test\web.config'
    $cfg = [xml](gc $webConfig)
Not sure how the if statement will work in searching the document and applying critera

Here is the full web.config file. i just modified the credentials.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,
EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler,
Common.Logging" />
    </sectionGroup>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468
-->
  </configSections>
  <connectionStrings>
    <add name="Membership" connectionString="Data Source=TestDB;Initial Catalog=Test;user
id=TestUser;password=1234556;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
    <add name="Administrator" connectionString="Data Source=TestDB;Initial Catalog=Test;user
id=TestUser;password=1234556;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
  </connectionStrings>
   <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory,
EntityFramework" />
  </entityFramework>
  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwExceptions="true">
  <targets>
       <target name="f1" xsi:type="File" fileName="test.log.txt"
layout="${threadname} ${longdate}
     ${callsite} ${logger}[${level}] ${message}" />
       <target name="console" xsi:type="Console" layout="${threadname}
${longdate} ${callsite}
     ${logger}[${level}] ${message}" />
     </targets>
 <rules>
      <!--<logger name="Quartz.*" level="Warn" />-->
      <logger name="*" writeTo="f1" minlevel="Info" />
      <logger name="*" writeTo="console" minlevel="Debug"
/>
    </rules>
  </nlog>
  <common>
    <logging>
      <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
        <arg key="configType" value="INLINE" />
      </factoryAdapter>
    </logging>
  </common>
  <appSettings>
   <add key="V3Import.Import.TestMode" value="true" />
    <add key="MSMQ.QueueName" value="TestQueue" />
    <add key="MSMQ.ErrorQueueName" value="TestQueue" />
    <add key="AdminSignaturePath" value="C:\user\test\myfolder" />
    <add key="SyncQueueJobCRON" value="0 0/2 * 1/1 * ? *" />
  </appSettings>
  <system.web>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="5000000" />
    </authentication>
    <membership defaultProvider="AspNetMembershipProvider">
      <providers>
        <add connectionStringName="Membership" enablePasswordRetrieval="false"
enablePasswordReset="false" requiresQuestionAndAnswer="false" applicationName="/Test" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="AspNetMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </membership>
    <profile>
      <providers>
        <add name="AspNetProfileProvider" connectionStringName="Membership"
applicationName="/Test" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </profile>
    <roleManager>
      <providers>
        <add name="AspNetRoleProvider" connectionStringName="Membership"
applicationName="/Test" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </providers>
    </roleManager>
  </system.web>
  <system.net>
  </system.net>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="dotless.Core" publicKeyToken="96b446c9e63eae34"
culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.1.0" newVersion="1.3.1.0"
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"
culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0"
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"
culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089"
culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c"
culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0"
/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"
/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Similar Messages

  • How to search for a specific String within an ArrayList

    I am creating an inherited class, CD, that has a field of "tracks". I am wondering how you would search through the ArrayList and list the track number that correlates with a search term. For instance, if I have a track called "Radar Love" and it is track number 2, how would I create the search function to find out what track number "Radar Love" is?

    trojansc82 wrote:
    int index = 0;
    boolean found = false;
    while(index < tracks.size() && !found){
    String track = tracks.get(index);
    if(track.contains(searchString)){
    found =true;
    else{
    index++;
    return index;It's still the same code. I attempted putting in a return statement with tracks.get(index), but it didn't work.Edited by: Edward_Kimber on Nov 15, 2008 2:57 PM

  • How do I search for a specific word in the code using Dreamweaver?

    I need to search for a specific word in the code for all of my website pages. How can I do that using Dreamweaver?

    To search local files of a Defined Site in DW...
    Open the Find & Replace tool with Ctrl + F
    Change the Find In dropdown to Entire Current Local Site
    Change the Search dropdown to Text or Source code
    Add the text to find in the Find field
    Add the text to replace in the Replace field (or nothing if you just want to delete the text)
    Hit Replace All

  • How do i search for a specific artist in iTunes store on iPhone 5?

    How do i search for a specific artist in iTunes store on iPhone 5?

    Open the iTunes app > Search > then type the Artist's name

  • How do I search for a specific name of an email sender?

    I'm trying to locate, in the easiest way possible, a name that should have appeared in my inbox... How do I search for a specific name?

    type it in the big box on the toolbar and press enter.

  • How to Search for a specific element in a MultiGraph?

    Hi there
    Im trying to implement a Multigraph ADT in Java. Multigraph is a graph that has multible edges connecting a node. I assume you all know what a Graph ADT looks like.
    So i think ive got all the basic methods functions of a normal graph/mulitgraph and now i want to search for a element in it
    The question is how will i so that?
    Do i use a breadth first search?
    But i thought a BFS traverses all the elements in a graph? And how can i use a BFS to search for a specific element in a graph?
    Thanks

    Hey there
    thanks for your reply but i still some query.
    I thought of doing that but i want to remember the nodes i revisted to get to the target (not all - but the quickest route to that node)
    My design so far is:
    have 3 Interface namely Graph, Node & Edge.
    Classes will inherit those interface to provide the actual implementation as i want the details/coding to be abstract meaning i can give many different way of implementations.
    The graph class will add nodes & edges where when adding edges, edge will store 2 nodes in it respectively source & destination nodes.
    Both Node & Edges will be stored in graph using some data structures atm (arrayList i presume)
    My Design is that i want to (my aim of the task of searching) search for a node in the multigraph by inputting (maybe 2 nodes) into method - start node target node! The method should return a list of nodes to get to the target node.+
    So so far i have this wee algorithm in mind:
    +1. Input start + target node as parameters+
    +2. Use BFS to search the graph+
    +3. When reached target node - halt+
    +4. return the list of nodes that visited to get there (but not all - only the precise & fastest)+
    So will that work?
    If so how do i go about doing implementation?
    Thanks

  • How to search for a pattern string in entire registry and delete all the keys and subkeys that contain the pattern (C# or VB)?

    I want to search for a pattern string in the entire registry and need to delete all the keys and sub-keys that contain the pattern. How can I implement this in VB Script or C#? Appreciate if you can give some sample examples. Now every time, I am manually
    searching for the pattern in registry and deleting one by one.
    Thanks Prasad

    There is no built in way to do this. You'll end up having to enumerate all keys and values in the entire registry and comparing each one for a pattern using Regex or similar.  This is going to be really slow but there isn't much else you can do about
    it (other than parallelize the enumeration).  Also note that you won't have permissions to all keys for read and/or write access so you'll need to skip over those using exception handling.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • HT204266 how to search for a specific app eg tetris in the app store?

    Hi is there anyone that can please help me on how to search for a specific app eg tetris in the app store? Thanks

    Hi Friend,
    You just write down the name of the app or for what the app is used for (eg, write down Notes and then will appear a lot of options), then download what you wish.
    Hope it will be helpful

  • How to search for subset of string

    Hi,
    I'm trying to implement Oracle text in 8i and 9i to search for a given string or a subset of string.
    For example, if the given string="Database Technology", I would like intermedia to first search for the exact string - "Database Technology",
    if not found, then search for either "Database" or "Technology".
    I'm only able to search for the exact string ("Database Technology") so far by using the contain clause. I'm not able to get Oracle Text to return me any records that also contains "Database" or "Technology" if the exact match "Database Technology" cannot be located.
    Any help is very much appreciated.
    thanks.
    elain

    You need to use the ACCUM operator. It raises the score based on the the frequencies of more than one word. Here are the contents of my TEXT1 test table:
    TEXT
    database
    server
    database server
    database blah blah database
    database blah blah server
    select score(1), text1.* from text1 where contains(text,'database ACCUM server ACCUM database server',1) > 0 order by score(1) desc;
    and here are the results:
    SCORE(1) TEXT
    68 database server
    34 database blah blah server
    2 database blah blah database
    1 server
    1 database
    You may want to put a multiplier on the "database server" phrase's score to increase the score on when the complete phrase is found. That looks like this, for example:
    select score(1), text1.text from text1 where contains(text,'database ACCUM server ACCUM database server*3',1) > 0 order by score(1) desc
    Tom Best

  • Is it possible to search for a specific term or data in Numbers for iOS?

    I looked for similar questions, but all of the similar questions did not specify if they were talking about the Mac version or the iOS.  So I apologize if the question has been asked.
    Is there a way to search for a specific term or criteria in Numbers for iOS?
    My father owns a small business and has a large inventory of parts.  He wants a simple way to search his inventory for a particular part number and see how many of a the specific part number he has in his inventory, while not in the shop or having to call in.  He wants to take an iPad along with him.
    My first thought was to create an spreadsheet.  I have a basic knowledge of how spreadsheets work, and I don't think my father would like anything more complicated.
    I was thinking about making the 1st column list the part number, 2nd column list the quantity in the shop, 3rd column list the quantity in the truck.
    If Numbers for iOS is not able to do this, suggestions for alternatives are welcome.
    Thanks in advance

    Hi j4nitor
    Would the "Find" option in the "Tools" menu do the job?
    If you search for the part number, it will be highlightet, and with your outline for a setup, I guess that would give you the overview you are talking about.
    Hope it helps.
    Best regards
    Ole

  • How do i search for a specific music video instead of browsing through thousands

    how do i search for a specific music video instead of browsing through thousands?

    Type a keyword or two in the search area - shown in the upper right here (the oval area):

  • Maximum size video upload settings in web config file

    Hi, i am providing video support in my application, whereas i need to provide support to upload video without any size limit, say for example atleast 1GB video should be uploaded and played via html5 and iframe tag. I have made some changes in web config
    file like maxrequestlength attribute and maxallowedcontentlength attribute set to support maximum of 1 GB video. But it does not affect my application in anyway. Any suggestions please??

    This forum supports setup of the .NET Framework itself.
    As you question concerns configuration of a web application, I recommend that you ask here:
    http://forums.asp.net/26.aspx/1?Configuration+and+Deployment

  • Searching for a word or phrase in a file on NSS Pool/Volume

    I have encountered a strange issue in that if I search for a word or phrase in a file at any level of the volume, from the root, down to sub folders, I get different results from 2 or more PC's.
    Workstations are all Win XP SP2, Novell Client 4.91 SP4 for Windows
    Server NW 6.5 SP6 with all post SP's installed.
    I have ran a nss /PoolRebuild=POOLNAME and a NSS /VisibilityRebuild=VOLNAME
    There is only one volume on this pool.
    And I still encounter the same results.
    As one example:
    On my Admin workstation When I search the top level Folder of Closed Client folders for the word chronology, I get 2 files returned named chronfile1 and chonfile2, when I search from any other workstation (I have tried 4 different workstations at this point) at the same folder level, for the same word Chronology, I get multiple files with the Word in the File, but I do not see files chronfile1 or chronfile2. Likewise, the file names returned form the search results on the other workstations, are not returned in the search list ran on the admin (Mine) workstation. And yes, I am logged in as admin on the other workstations when running the search.
    So far, this issue is only appearing on 1 volume.
    Thoughts?

    Originally Posted by ataubman
    If you log in to the second PC as Admin, does the symptom move? IOW does it follow the user or the workstation? If the user you may have some odd file system rights set, although your specific results you report are puzzling.
    I'm assuming you are using the Windows desktop search tool?
    I ran a NSS /PoolRebuild last night which fixed an issue the workstations not being able to see the 2 files in question.
    Previous night I had just performed an NSS /PoolVerify.
    Part of the other anomoly, the other workstations seeing more files than the admin workstation (I feel so Stupid, after 25 years you think I'd be able to spot the obvious) the reason the other workstations were returning files that the Admin workstation was not - Admin workstation doesn't have Word Perfect installed.
    Somebody, give me a Gibbs head slap, now!

  • How to address the folder out of web site place in web.config file?

    Hi to all,
    I have a website. I want that some folder place out of web site location,then address their in web.config file.
    but don't how to do?
    please guide me.
    Thanks ;)
    Good luck!

    Hi Bahare Aghabarari,
    Welcome to MSDN forums.
    This is a forum for questions about Visual C# language. For ASP.NET questions, please post in
    ASP.NET forums. You can get more valuable replies there.
    Thanks for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Need to append the assembly entry in web.config file while installing NuGet

    Hi,
    Consider that I need to create three NuGets. Second and third are dependents for first one. Each one has its own web.config file, which file content is same except one tag's value. While I'm installing the first NuGet, it will install the second and third too
    which is fine. The NuGets are installing one by one. But the issue is while I'm installing the NuGet in an ASP.NET project, the web.cofig file gets replace with one another that means the last NuGet's web.config file is only remains at last. But I need to
    append that tag value one by one. Is there any possibilities to create NuGets in that way? Please help me as soon as possible. Thanks in advance.
    I need this...
    <assemblies>
    <add assembly="Abc.EM, Version=10.0.0.1, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
    <add assembly="Def.EM, Version=10.0.0.1, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
    <add assembly="Ghi.EM, Version=10.0.0.1, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
    </assemblies>
    But I got this...
    <assemblies>
    <add assembly="Ghi.EM, Version=10.0.0.1, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
    </assemblies>

    Hi mathikp,
    One solution is to use the DTE object model to find the ASP.NET project, enumerate all the project items in the project to find the Web.config file. Then change the content by your self. This will be done after you install the Nuget package in the project.
    https://msdn.microsoft.com/en-us/library/envdte.project.projectitems.aspx
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for