Matt Bloomfield

Forum Replies Created

Viewing 15 posts - 31 through 45 (of 429 total)
  • Author
    Posts
  • Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    I recommend using regex101.com to test and build your regular expressions:

    https://regex101.com/

    It’s not clear if you want the RequestId and Order in the same string or not?

    Would match the whole string up to the end of the order number.

    Would match just the order portion.

    For the users, you just need to find a regular expression that matches your examples.

    Would match User, followed by any character, followed by 1 or more digits.

     

     

    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    You could try Select-String which is usually faster than Get-Content:

    in reply to: Multivalued Array – concatenate double values #278889
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    If it’s only two columns, you could import the CSV into a hashtable and see if the key (column 1) already exists, if it does, add it to existing key (hashtables can’t contain duplicate keys).

     

    in reply to: Question on Unicode characters display in PS native console. #278817
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    Windows Terminal is what you’re after.  Unicode support and much, much more besides:

    Introducing Windows Terminal

    https://aka.ms/terminal

    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    For sure.  Just add the variable at the top of the script:

    Then modify the export section:

     

     

    in reply to: Regex in Powershell, line by line from txt-file? #278727
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    Just a case of looping over the files in $FileBrowser.FileNames

     

     

    in reply to: Set-expirationdate delay #278697
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    Specify the same domain controller with the -Server parameter for both cmdlets.  You’re probably hitting a different DC when you run Set-ADAccountExpiration and the new account hasn’t replicated.

    in reply to: Regex in Powershell, line by line from txt-file? #278577
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    It’s \b \b to set the boundary, not /b /b.

    That works OK for me:

    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    In that case, I would match the tag as well then use multiple counters:

     

    • This reply was modified 1 month, 2 weeks ago by Matt Bloomfield. Reason: Reformatted a long line for readability
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    Select-String should accept an array of strings for the Pattern, although that didn’t seem to work.  However, you can put two patterns in the regex which is what I’ve done.

    I also added a Select-Object -Unique so that the count matches the replacement value if there’s more than one of the same value.

    To keep the changes, I opted to use a custom object and export it to a CSV file as it’s easy to read.

     

    in reply to: Flip words in textfile OR make it work anyway? #277977
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    Can be done on one line but I’ve split it at the | for readability on the forum.

     

    • This reply was modified 1 month, 2 weeks ago by Matt Bloomfield. Reason: Formatting
    in reply to: 503 Service Unavailable Error #277941
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    Thanks for reformatting, it’s working OK now.

    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

     

    in reply to: active directory department issue #277131
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    -contains is for checking if a collection contains a object, it’s not meant for string comparisons.  Try changing your statement to

    if ($user -notlike ‘*.adm’) {}

    Looks like your variables are mixed up in the else statement too.

    • This reply was modified 1 month, 2 weeks ago by Matt Bloomfield. Reason: Added a missing word
    • This reply was modified 1 month, 2 weeks ago by Matt Bloomfield. Reason: Changed a word for clarity
    Participant
    Topics: 4
    Replies: 429
    Points: 770
    Helping Hand
    Rank: Major Contributor

    If the button is missing, you can either switch to Text view and use the CRAYON button or refresh the page a few times.  Usually after two or three refreshes the <> comes back for me.

Viewing 15 posts - 31 through 45 (of 429 total)