Regex Parsing in powershell

Trying to parse out IISLog and insert an * to separate columns but not sure how to combine the following into a line and insert * for import to excel,
^(\d{4}\-\d{2}\-\d{2}\s+\d{2}\:\d{2}\:\d{2}\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s+?\GET\s+?\/owa/keepalive.owa)
(\bserver.lab.local\b)
(\blab\\tyo\b)
(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s+)
Filtered LOG:
2013-12-18 00:27:16 192.168.10.99 GET /owa/keepalive.owa &Initial+Budget>>Conn:1,HangingConn:0,AD:18000/18000/0%,CAS:900
00/90000/0%,AB:18000/18000/0%,RPC:90000/90000/0%,FC:1000/0,Policy:DefaultThrottlingPolicy_a434b282-f172-4e3d-abde-073fd
a250426,Norm&v=14.3.158.1&mbx=server.lab.local&sessionId=52d807c3171944c081b9ccffaa64824e&prfltncy=
2&prfrpccnt=0&prfrpcltncy=0&prfldpcnt=0&prfldpltncy=0&prfavlcnt=0&prfavlltncy=0&End+Budget>>Conn:1,HangingConn:0,AD:180
00/18000/0%,CAS:90000/90000/0%,AB:18000/18000/0%,RPC:90000/90000/0%,FC:1000/0,Policy:DefaultThrottlingPolicy_a434b282-f
172-4e3d-abde-073fda250426,Norm 443 lab\tyo 76.157.152.100 Mozilla/5.0+(compatible;+MSIE+9.0;+Windows+NT+6.1;+WOW6
4;+Trident/5.0) 200 0 0 0
Trying to grab as follows and import to Excel: 
2013-12-18 00:27:16 192.168.10.99 GET /owa/keepalive.owa server.lab.local lab\tyo 76.157.152.100 Mozilla/5.0+

See - space delimited:
PS C:\scripts> $i='2013-12-18 00:27:16 192.168.10.99 GET /owa/keepalive.owa server.lab.local lab\tyo 76.157.152.100 Mozilla/5.0+'
PS C:\scripts> $i -replace ' ','|'
2013-12-18|00:27:16|192.168.10.99|GET|/owa/keepalive.owa|server.lab.local|lab\tyo|76.157.152.100|Mozilla/5.0
PS C:\scripts>
See - all spaces become pipes.  Excel canalso import the file directly as a space-delimited file with a header.
¯\_(ツ)_/¯

Similar Messages

  • Bug regex parser since 15.0.0.223

    Hi,
    I have a major issue on the version 15.0.0.223
    I have the following regex :
    /\${((?>[^${}]*)(?:(?>[^${}]+|(?R)))*(?>[^${}]*))}/
    I use it in a Parameter resolver to match the first encountered ${...} on strings like:
    "${serverBaseURL}/${appName}"
    "Some string thiny says : ${field0.subfield}--${field1.${field2}.subfield13}"
    When I test on previous versions of flash it works fine. But it fails on 15.0.0.223
    I tested out of my own solution to be sure, using : http://www.sevenson.com.au/actionscript/testing-regular-expressions/
    for "${serverBaseURL}/${appName}" It works on the version 15.0.0.189 and anterior and find this:
    0 = ${serverBaseURL}
    1 = serverBaseURL
    (i then procedurally go to the next pattern.. but this is not the point)
    Have you had similar issues with the 15.0.0.223 ?
    I created a bug report there : Bug#3851436 - BUG: flash player 15.0.0.223 reg exp

    I escalated the bug to the engineering team.  My guess is that this is fallout from a recent security change to regex parsing.

  • Regex replaceAll question

    I am using replaceAll to replace a bunch of "tags" with content for this bit of software that I am porting (from something else) that creates documents (in the end) by populating templates with data.
    Here's my problem. The "tags" are all okay (not giving any regex content) but some of the data is. Because at first now I hit data that as a String has some regex funky characters in it. And regex got all all whiny about that because there aren't any matching groups. Well no. That's true.
    So I have to escape the $. But it occurs to me that I could well have more than this problem with other bits of content (including some parts I haven't gotten to yet) and I am wondering if there is any sort of easy solution. Is there way to tell replaceAll that the replacement String is a "literal" replacement i.e. I don't want any regex parsing at all just replace the found "tag" with the "content", that's it.
    Some sort of escape the whole sequence? Possibly. But I don't understand what it would be. \ is just for as single character?
    So any quick solution? Or alternative?
    BTW I am stuck with 1.4 on this project.

    yawmark wrote:
    I'd recommend trying Apache Commons StringUtils.
    Hope this message doesn't disappear into the aether.
    ~I think it did for awhile but like Lazarus arose...
    Anyway thank you for the effort.
    This is an interesting suggestion but I'd rather not go the route of adding more libraries.
    What I did at first was
    private void replaceAll(StringBuffer buff, String toFind, String toReplace){
      while(buff.indexOf(toFind)>-1){
         buff.replace(buff.indexOf(toFind),buff.indexOf(toFind)+toFind.length(),toReplace);
    }which worked good enough for me but someone else pointed out quoteReplacement and just doing my own version of that. Which works well too.
    Anyway thanks again I do appreciate it what with the current situation and all.

  • Three new bioinformatic coding problems now in WIKI (all require regex)

    At the bottom of this page:
    https://wiki.sdn.sap.com/wiki/display/EmTech/Bio-InformaticBasicsInRelationtoScriptingLanguages
    I've defined three new bioinformatic coding problems (Problems 3a-c).
    These all involve regex parsing in one way or another and are therefore a lot more interesting than the first two problems I've presented.
    I'm hoping that Anton will continue to knock out solutions, and that others will feel challenged enough to join him.
    djh

    Anton -
    I am way impressed - not just by your code and how fast you produced it, but also by the speed with which you grasped the STRIDE documentation and put it to very good use.
    Regarding the question you ask at the very end - this question goes to the heart of why protein tertiary structure (the actual 3-dimensional shape of one chain of a protein) is so hard to predict, and why governments, universities, and pharma are throwing so much money at it.
    If protein primary and secondary structure were many-to-one, prediction of protein tertiary strructure would be a lot lot simpler.  (For example, if "VVAY" and all "similar" primary structure subsequences mapped to the same secondary structure.)
    But the mapping is, unfortunately, many-to-many because the amino acids (AAs) in a primary structure chain always bond the same way - the COOH (carboxy) of one  AA bonds to the HN (amino) of the next one to produce C-N with the OH and H going away to make a water moleculre ... COOH - HN ---> C-N + H20.
    And as pointed out by Linus Pauling (the discoverer of protein secondary structure), the C-N bond can take two forms:
    a) one that is llkely to force the two amino acids to become HH (part of a helix)
    b) one that is likely to force the two amino acids to become EE (part of a "stand")
    You may be surprised to find out that even primary structure subsequences of six amino acids can wind up as different secondary structures - not always "H" vs "E", the variants might be
    E TT H
    H TT E
    EEE HH
    HH EEE
    etc.
    Anyway, thanks a lot for what you've done here.
    If you decide to stay involved a little longer, you will very soon be able to understand why there may be real promise in the approach to protein structure that is being taken here:
    http://strucclue.ornl.gov
    (This is why I want to get SAP interested in the vertical bioinformatic sector - you can see why an integrated IDE with a robust DB is so important.)
    BTW, the site mentions Dr. Arthur Lesk as a team member.  Arthur is considered one of the fathers of what is called "structural alignment" (as opposed to pure sequence alignment.)
    If you Google him, you'll see that he has written many many books on bioinformatics - all worth purchasing if you're going to become involved in this area.  Arthur was at Cambridge (MRC) until recently, when he reached mandatory EU retirement age and took a position at Penn State here in the US.
    Best
    djh

  • Extract Variables from Powershell Script

    Hey Guys
    I am building a workflow that sync's active directory to the IAC database and i am looking to make it as efficient as possible by reducing the amount of powershell scripts I use into one and then utilise the powershell variables to get what i need.
    Is it possible to extract the stored variables into a workflow variable as opposed to using the output of the powershell statement?
    Has anyone else built a workflow that sync's users to a DB that runs efficiently possible on the when modified date at the moment mine takes 28 minutes to sync 200 users.
    Matt

    From a design perspective, I would suggest to use the Generic OLEDB database adapter.  There is an OleDB provider for Active Directory called ADsDSOObject. You can find it through a search on the Microsoft site.  It may be installed as a part of standard Windows or .Net.  Not sure. If you could get this registered on the PO server, you would be able to do a select and use the output as a native table instead of Powershell output parsing.
    Powershell tends to be non-performant.  Definitely I would caution against calling PowerShell repeatedly in a loop.

  • Get Variant Attribute Should Search for and return multiple values based on RegEx

    I am using Variants as lookup tables (see this article):
    Using Variant Attributes to Build a Dictionary or Look-up Table
    I would like to be able to use some sort of wildcard to return multiple results from the Get Variant Attribute VI (all results are of the same type, and I don't know the exact names of all the results - those two points make this idea distinct from this idea: Set/Get Variant Attribute for Multiple Attributes).
    Ideally the wildcard would be RegEx.  If it were, the means by which you specify what to return is standardized.
    In the above example, there would be some ambiguity in terms of whether or not you would want to return a result or an array of results given an input, and I doubt you could detect and assume RegEx is what the programmer desires to use.  So I think this means a new input would be required to specify whether or not the "name" input of the Get Variant Attribute VI should be interpreted as a RegEx query.
     

    Why RegEx? Why not SQL query? Why not filename wildcard matching?
    I don't see anything that makes RegEx special. For this kind of functionality, the code that you've written seems like exactly the right way to do it rather than bolting a RegEx parser or any other system into the primitives or clouding the palette with a bunch of primitives to support various search functions. I could see a primitive that takes a VI refnum that has a conpane of string in/boolean out that you would pass in to supply the filter functionality that you want for any given application, but even that I'd lean toward just letting that be a library that someone writes on top of the primitives. Yes, there is some memory reduction that can be done if it is internal to the primitives, no question about that. But there are so many variations in how to do that filtration/sorting/etc that I'm not confident that any prim would cover a sufficient use case to be worth it. I could be wrong here ... let's see what other comments come in.

  • Question on how to loop through a variable amount of objects

    I have a csv file which I am parsing with powershell and it works perfectly. I would like to speed it up. Currently, I call a line that is customized for each groups list of subnets.
    I have about 30 groups.
    Some groups have one subnet, some have 5 subnets.
    I want to set up some sort of loop to parse everything while executing a single Import-CSV. Currently I call Import-CSV once per group. It takes me about 2-4 minutes to parse the entire file depending on the speed of the machine.
    The csv file has about 30,000 rows. I am not concerned about running out of resources. This is as much a learning challenge as a desire to make better powershell scripts.
    Below is a portion of the one liner that would parse the entire csv file looking only for those items that match, and writing them out to that groups specific csv file.
    Example #1
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.1.*" -or $_."IP Address" -Match "^192.2.*" -or $_."IP Address" `-Match "^192.3.*"  .....}| do more stuff...
    Example #2
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.7.*" ....}| do more stuff...
    The example above is just a snippet from code that works perfectly.
    The problem I am asking for help with is, when I loop through the items I am matching against (subnets), if one group has 3 items to match against, another has 1, another has 7, how do I set up such a loop?
    Am I using some sort of 'while'  $_."IP Address" or...?
    Do I create a big 30,000 array (Does PS even use arrays?)
    I would love to know what this type of looping is called, and what I can read with examples on how to understand approaching this challenge..
    Thank you for any help.
    -= Bruce D. Meyer

    The reason for the parsing (I thought I explained it, must have been too vague) is I have about 30 agencies in a csv file.
    Each agency can be determined by their subnet(s) and domain(s)
    I need to put all lines in the csv relating to each agency in their own separate csv file to distribute to them so I am not sharing agency 'A' info with the other 29 agencies.
    I get the regex comment. Thank you. For some reason I am rather hesitant to use PCRE under windows. I'll see how it works.
    Your comment on "Reloading a large file repeatedly takes more time", is the exact reason why I asked the question. I want to get away from that.
    I appreciate your quick reply, I think your example will work nicely. 
    -= Bruce

  • Delete all text after string...

    I have a series of text files that I am attempting to parse with PowerShell. I haven't done much with text file manipulation and would love some advice. Thanks in advance to anyone willing to give this a go!
    Example File: (file name = "report_20131231.txt")
    **** SAMPLE1 ****
    user1 username1
    user2 username2
    user3 username3
    **** SAMPLE2 ****
    user4 username4
    user5 username5
    user6 username6
    I want to import the text file and reformat it to the following:
    Date | SAMPLE # | Username
    <file name date> | <sample #> | <username>
    Example Output:
    Date | SAMPLE # | Username
    20131231 | SAMPLE 1 | username1
    20131231 | SAMPLE 1 | username2
    20131231 | SAMPLE 1 | username3
    20131231 | SAMPLE 2 | username4
    20131231 | SAMPLE 2 | username5
    20131231 | SAMPLE 2 | username6

    This code seems to work for parsing your original file format:
    function Import-YourSampleFile
    [CmdletBinding()]
    param (
    [Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
    [Alias('FullName', 'PSPath')]
    [string[]]
    $Path
    process
    foreach ($string in $Path)
    if ($string -match '(\d{4})(\d{2})(\d{2})(?:\.[^\.]*)?$')
    $date = Get-Date -Year $matches[1] -Month $matches[2] -Day $matches[3] -Format yyyyMMdd
    else
    $date = 'Unknown'
    $sampleNumber = $null
    Get-Content -Path $string |
    ForEach-Object {
    $line = $_
    switch -Regex ($line)
    '^\s*\*{4}\s*SAMPLE(\d+)\s*\*{4}\s*$'
    $sampleNumber = $matches[1]
    break
    '^\s*\S+\s+(\S+)\s*$'
    if ($null -ne $sampleNumber)
    New-Object psobject -Property @{
    Date = $date
    Sample = "SAMPLE $sampleNumber"
    UserName = $matches[1]
    break
    } # ForEach-Object
    } # foreach ($string in $Path)
    } # process
    } # function Import-YourSampleFile
    The rest is just using this function in conjunction with Export-Csv (or something very like it) to produce the pipe-separated format you wanted.  Something like this:
    Get-ChildItem -Path .\report_*.txt |
    Import-YourSampleFile |
    Export-Csv .\output.txt -NoTypeInformation -Delimiter '|'

  • Line break in an SVG object

    Hi friends,
    I am using an SVG object to create a pdf from BLS.I am assigning a string value to a variable pre-defined in that SVG object.The problem here is i am unable to get carriage return in that string(string is of huge length) which is being displayed on the PDF.It is getting out of the PDF created.I had used 'crlf' but it is not working.Any suggestions on this would be really appreciated.
    regards,
    Ravi Kumar
    Message was edited by:
            Ravi Kumar

    Hi, Ravi.
    One of the cool things about SVG is that it is nothing more than an XML document!  So, you have two options to achieve what you would like to do:
    Solution 1 involves using the animation editor's expression capabilities to meet your needs:
    1a) If you can assume a "maximum" number of lines (let's assume 8 line items maximum), you can place all 8 text objects in their correct position on the SVG object (and name the SVG element ID's something like TextLine1,TextLine2, etc.).  In the animation editor, provide 8 input properties (of type String) corresponding to these text values.  In fact, let's call them TextLine1,TextLine2...TextLine8.
    1b) In the animation editor, link the these properties to the corresponding text property for each of your 8 SVG elements.
    1c) Now, here's the magic part:  link the following expression (adjusted for each text line item) to the "visibility" attribute of each of your 8 SVG elements.
    stringif(stringlength(TextLine1) > 0,"visible","hidden")
    1d) Then, in your BLS transaction you'll need to split your list of barcode items and loop through them or assign them.  I'm not sure what your query is returning, but I'm sure there's a way, either with the functions or  the web scraper (a RegEx parser) to do what you need.  Let us know more specifics, and we can provide some guidance.
    There's one other approach that takes advantage of the fact that an SVG document is nothing more than a special type of XML document.  In this case, instead of "pre-adding" a fixed number of items, you'll simply use the "append XML" link type and a local property of type XML, which will contain your SVG text element, to dynamically add any number of items.
    The key with these approach is to dynamically calculate the x and y positions for each text item (usually based on some fixed height), assign these attributes as well as the text content to a Local property, then append this to the SVG.
    You have a few choices for how to load the SVG.  One option is the XML Loader.  However, you can mix the capabilities of the AnimatedObject + direct SVG manipulation as well.
    Option 2a is to use the XML loader, manipulate the XML with assignment actions, then use the SVG renderer to convert it to an image.
    Option 2b is to use the AnimatedObject action, which outputs both XML and an (optional) image - you should turn off "Render Image" in this case.  You can then manipulate the SVG output to add your text items, and send this to an SVG renderer to convert it to an image.
    The advantage of approach 2b is that you can use the standard functionality of the AnimationObject to make the easy stuff, and extend it with SVG manipulation for your "super dynamic" stuff.
    Hope this helps,
    Rick
    R

  • Update on Bioinformatics WIKI, scripting challenges, and a general question

    I am waiting for my site to go on-line at Oak Ridge National Labs (USA, Tennessee).  Should be another week or so, maybe less.
    When that happens, you will see a veritable explosion of scripting challenges in my wiki (Emerging Technologies->Bioinformatics.)
    One general question in preparation for these challenges.
    There are a number of standard  bioinformatic programs that can be run interactively via the web at various sites, e.g. "BLAST" and "STRIDE". 
    Although these can also be run locally, this requires that you download large databases and keep them updated.
    So here's my question to the scripting experts:
    Are scripting languages powerful enough to submit queries to web pages and then use regex's to parse the html that is returned?
    Bill Mann has used PERL to do some of the required regex parsing, but there is a lot left to do, and, his stuff only works when a perl program is invoking a bioinformatic program locally, not interactively.
    If so, we all can do some beautiful stuff together , if anyone is interested ...

    ...my wiki on...
    There is by it's very nature no such thing as MY WIKI, except you run your own wiki project in an exclusive mode. Which were...well ... unusual.
    Are scripting languages powerful enough to submit queries to web pages and then use regex's to parse the html that is returned?
    Yes.
    anton

  • HTML code displayed

    Right its like this....
    I can now get my data from my database (no small victory in itself. Thanx to all those that gave assistance). One of the fields contains HTML code
    <p>blah blah etcWhen the jsp displays the output it is actually showing the HTML code, not the rendered output... viewing source shows that it has been written to the response as
    & lt;p & gt;blah blah blah.....(needed the spaces to show it correctly!)
    Any clues as to why and what I can do to about it?
    Thanks
    Elija

    do a replaceAll.., if you are using Java 1.4
    String str = orig.replaceAll("& lt;", "<").replaceAll("& gt;", ">");
    You might need escapes for some of those chars for the regex parser. Or this older code I had laying around:
          * Decodes any entities in the specified string with their character
          * equivalents. 
          * @param  str  the encoded string
          * @return  the decoded string
         private String decodeEntities(String str) {
              if(str == null) {
                   return null;
              StringBuffer sb = new StringBuffer(str);
              String[] ents = {     // list of entities to replace
                   "&",      "<",      ">",      "&apos;", """
              String[] chars = {     // list of characters to replace with
                   "&",      "<",      ">",      "\'",      "\""
              int len = Math.min(chars.length, ents.length);
              int k = 0;
              for(int i = 0; i < len; i++) {
                   for(int j = 0; j < sb.length(); j++) {
                        k = j + ents.length();
                        if(k >= sb.length()) {
                             break;
                        if(sb.substring(j, k).equals(ents[i])) {
                             sb.replace(j, k, chars[i]);
              return sb.toString();

  • PS Scheduling via Windows Task Scheduler

    Hi All,
    I have been pulling my hair out trying to schedule my APIWSUSCleanup.ps1 file from this thread (http://social.technet.microsoft.com/Forums/en-US/eee88f8a-57de-46db-8d60-efb0e72d57b9/running-5-commands-using-array-elements-and-waiting-between?forum=winserverpowershell)
    to run as a scheduled task. Running interactively from a remote PS session the script file runs fine and produces the log file that it should.
    I have tried so many different combinations (including nonsensical just to be certain and rule them out) that I'm sure I have started going around in circles, there doesn't seem to be a definitive answer out there so hopefully someone on here can see what
    I'm doing wrong for my situation.
    I cldn't find any references for WSUS Management Shell cmdlets so I'm assuming that there isn't one that needs to be passed for the script to work like Exchange requires?
    Environment: Server 2012 WSUS Core install being administered with Server Manager from a GUI Server 2012 install. Scheduled task being added via Computer Management. I have setup the script
    execution using "set-executionpolicy remotesigned" from a Remote Powershell session, assuming that this sets it for x64 and x86? I did see one comment stating that is doesn't.
    Task: Run as SYSTEM (have tried local admin account), Run whether logged on or not, Run with highest privileges, Configure for Server 2012, Run on demand enabled.
    Task Action:
    Program: Have tried
    powershell
    powershell.exe
    %windir%\system32\WindowsPowerShell\v1.0\powershell.exe
    %windir%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
    Arguments: Here goes
    (The c:\powershell has been substituted by .\ when "start in" populated also as a test and I have also tried the shorthand version of commands such as -c instead of -command)
    All of the below have been run prefixed with nothing, -file and then -command (not at the same time)
    C:\Powershell\APIMonthlyWSUSCleanup.ps1
    "C:\Powershell\APIMonthlyWSUSCleanup.ps1"
    ("C:\Powershell\APIMonthlyWSUSCleanup.ps1")
    {C:\Powershell\APIMonthlyWSUSCleanup.ps1}
    "{C:\Powershell\APIMonthlyWSUSCleanup.ps1}"
    {"C:\Powershell\APIMonthlyWSUSCleanup.ps1"}
    &{C:\Powershell\APIMonthlyWSUSCleanup.ps1}
    &"C:\Powershell\APIMonthlyWSUSCleanup.ps1"
    &'C:\Powershell\APIMonthlyWSUSCleanup.ps1'
    {&"C:\Powershell\APIMonthlyWSUSCleanup.ps1"}
    &{"C:\Powershell\APIMonthlyWSUSCleanup.ps1"}
    (&"C:\Powershell\APIMonthlyWSUSCleanup.ps1")
    (&{C:\Powershell\APIMonthlyWSUSCleanup.ps1})
    "&{C:\Powershell\APIMonthlyWSUSCleanup.ps1}"
    "& "C:\Powershell\APIMonthlyWSUSCleanup.ps1"
    "& 'C:\Powershell\APIMonthlyWSUSCleanup.ps1'"
    ". 'C:\Powershell\APIMonthlyWSUSCleanup.ps1'"
    Start in: Have tried
    C:\Powershell\
    C:\Powershell
    Last Run Result: 0x0 & 0xFFFD0000
    History - Action Completed with return: 0, 1, 4294770688 & 2147746132
    It would be much appreciated if someone out there can help me to save my sanity.
    If there is one command that you think should work please let me know so I can try it and post back the exact result for that command.
    FYI - I have also tried to run this using CMD and parsing the powershell.exe in the arguments; I'm not keen on doing it that way though due to the string length limitations for future usage.
    Cheers

    There was  two ) ) after param ([String]str$))
    Here is corrected version (Add line to show the date)
    Param ([string]$p) # Parameter for test.ps1
    function LogParameter {
    param ( [string]$str) Add-Content "C:\PowerShell\Test.Txt" (Get-Date)
    Add-Content "C:\Powershell\Test.txt" $str
    LogParameter -Str $P # body of test.ps1
    I tested with a domain\user with domain admins rights. (Selected Run whether user is logged on or not)
    I set the task to run every 5 minutes indefinitely
    At the bottom the page of the Settings tab, I selected "Stop the existing instance" from the list.
    I checked c:\Powershell\test.txt and it shows it is going every 5 minutes.
    In the task manager details page, I can see taskeng.exe running for the doman\user

  • Webpage $webClient.DownloadString only retrieve 10% of codes

    Here are my codes
    $webClient = New-Object Net.WebClient
    $data = $webClient.DownloadString("http://www.msn.com/en-gb/video")
    $data
    Not sure why it only grab 400+ lines as compared when I view the source code of this website via IE or Firefox it returns 4000+ lines. Is the command above only able to retrieve a certain number of lines? Is there a better method that I can do this
    so that $data will have the same lines of codes as what I see from the browsers?
    Thanks

    That answer is what butnot why.  WHy doo you need this.  What is it that is not there that you need?
    ¯\_(ツ)_/¯
    I managed to find out the reason why.
    If you visit the link  http://www.msn.com/en-gb/video and go to the section that has "Most Watched" closest to the end of the page. If you click on the video
    section and you noticed that there are 1 of 6 pages to be navigated. The fact that we use the browser view source, it will expand all the html from page 1 of 6 to 6 of 6. I am not sure what is the exact URL to parse to powershell so that it will display the
    correct page to grab the html code. I would think that the url would be something like
    http://www.msn.com/en-gb/video?&currentpage=2" or something like that to force it to the next page. What do you think?
    Not the cause.  The content is downloaded by executing JavaScript against XML.  IE generates this.  THe WebClient does not execute the script on the page.
    The little "....." are at the end of each row of pictures to show that the row can be scrolled.  There are no pages.  All activity in the page is managed by JavaScript and HTML5.
    ¯\_(ツ)_/¯

  • Parse XML file with regex

    Hi,
    Is that possible to parse a xml file using regular expressions....if s what is the API needed
    thanx in advance

    Is that possible to parse a xml file using regular
    expressions....if s what is the API neededI'm sure it can be done. Here's the regex API:
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html
    http://www.javaregex.com/tutorial.html
    But that's not where regex is for. Better have a look at this:
    http://java.sun.com/xml/

  • Parse log file using powershell

    Hi,
    Am pretty new to Powershell and would require anyone of your assistance in setting up a script which parse thru a log file and provide me output for my requirements below.
    I would like to parse the Main log file for Barra Aegis application(shown below) using powershell.
    Main log = C:\BARRALIN\barralin.log
    Model specific log = C:\BARRALIN\log\WG*.log
    Requirements :
    1. scroll to the bottom of the log file and look for name called "GL Daily" and see the latest date which in the example log below is "20150203"
    note : Name "GL Daily" and date keep changing in log file
    2. Once entry is found i would like to have a check to see all 3 entries PREPROCESS, TRANSFER, POSTPROCESS are sucess.
    3. If all 3 are success i would like to the script to identify the respective Model specific log number and print it out.
    E.g if you see the sample log below for "GL Daily", it is preceded by number "1718" hence script should append the model log path with "WG00" along with 1718, finally it should look something like this  C:\BARRALIN\log\WG001718.log.
    4. If all 3 items or anyone of them are in "failed" state then print the same log file info with WG001718.log
    Any help on this would be much appreciated.
    Thank You.
    Main log file :
    START BARRALINK            Check Auto Update                                                1716  
    43006  20150203 
        Trgt/Arch c:\barralin                                               
        PREPROCESS           success   0 preprocessor: no error                   
        TRANSFER             success   1 Host success: files received             
        POSTPROCESS          success   0 Postprocessor: no error                  
        CONFIRMATION         success   2 No Confirm needed                        
    STOP  43105  20150203 
    START Aegis                GL Monthly                                                    
      1716   43117  20150203 
        Trgt/Arch K:\barraeqr\aegis\qnt\gleqty                              
        PREPROCESS           success   0 preprocessor: no error                   
        TRANSFER             success   1 Host success: files received             
        POSTPROCESS          success   0 Postprocessor: no error                  
        CONFIRMATION         success   2 No Confirm needed                        
    STOP  44435  20150203
    START Aegis                UB Daily                                                    
      1717   43107  20150203 
        Trgt/Arch K:\barraeqr\aegis\qnt\gleqty                              
        PREPROCESS           success   0 preprocessor: no error                   
        TRANSFER             success   1 Host success: files received             
        POSTPROCESS          success   0 Postprocessor: no error                  
        CONFIRMATION         success   2 No Confirm needed                        
    STOP  44435  20150203 
    START Aegis                GL Daily                                                    
        1718   44437  20150203 
        Trgt/Arch K:\barraeqr\aegis\qnt\gleqty                              
        PREPROCESS           success   0 preprocessor: no error                   
        TRANSFER             success   1 Host success: files received             
        POSTPROCESS          success   0 Postprocessor: no error                  
        CONFIRMATION         success   2 No Confirm needed                        
    STOP  50309  20150203 
     

    Hi All,
    I was writing a function in power shell to send email and i was looking to attach lines as and when required to the body of the email. but am not able to get this done..Here's my code
    Function Email ()
    $MailMessage = New-Object System.Net.Mail.MailMessage
    $SMTPClient = New-Object System.Net.Mail.SmtpClient -ArgumentList "mailhost.xxx.com"
    $Recipient = "[email protected]"
    If ($MessageBody -ne $null)
    $MessageBody = "The details of Barra $strsessionProduct model is listed below
    `rHostName : $localhost
    `r Model Run Date : $Date
    `r Model Data Date : $DateList1
    `r`n Click for full job log"+ "\\"+$localhost+"\E$\Local\Scripts\Logs "
    $MailMessage.Body = $MessageBody
    If ($Subject -ne $null) {
    $MailMessage.Subject = $Subject
    $Sender = "[email protected]"
    $MailMessage.Sender = $Sender
    $MailMessage.From = $Sender
    $MailMessage.to.Add($Recipient)
    If ($AttachmentFile -ne $null) { $MailMessage.Attachments.add($AttachmentFile)}
    $SMTPClient.Send($MailMessage)
    $Subject = "Hello"
    $AttachmentFile = ".\barralin.log"
    $MessageBody = "Add this line to Body of email along with existing"
    Email -Recipient "" -Subject $Subject -MessageBody $MessageBody -AttachmentFile $AttachmentFile
    as you can see before calling Email function i did add some lines to $MessageBody and was expecting that it would print the lines for $MessageBody in Email Function along with the new line. But thats not the case.
    I have tried to make $MessageBody as an Array and then add contents to array
    $MessageBody += "Add this line to Body of email along with existing"
    $MessageBody = $MessageBody | out-string
    Even this didnt work for me. Please suggest me any other means to get this done.
    THank You

Maybe you are looking for

  • How to generate .txt file from data in internal table

    Hi I am using the program below to load .txt file into SAP table. I am moving the records from a .txt file into internal table final and then into ZOUT_CCFOBS table. How do I load records from internal table final back to another .txt file with the s

  • Need a record from second query which is not a part of main query.

    I have this Query which Leads me to two Rwos of Data select papf.employee_number E_CODE ,to_char(paaf1.effective_start_date,'DD-MON-RRRR') EFFECTIVE_START_DATE ,DECODE(to_char(paaf1.effective_end_date,'DD-MON-RRRR'),'31-DEC-4712',NULL,to_char(paaf1.e

  • Dynamic parameters in function module

    Hi. I need to write a program that can call various different function modules based on what the user inputs. For example, if the user chooses "BAPI_USER_GET_DETAIL" I need to then call that function module. There is a list of about 30 functions they

  • "Conditions" button at the material master - Change the related condition

    There is "Conditions" button at the material master ("Sales: sales org. 1" tab). We can make condition record of PR00 by this button but at our system the condition for the material price is different (it isZPR0 at our system). How can I change the r

  • Need to deactivate task that generates workflow items not needed anymore

    Hi, Some users are currently getting workflow items with the error message: "Header del.date/Qty different than line item;..." for inbound orders. The users don't want to receive this error message anymore on their inboxes. I found out this error mes