It is possible to replace "\"

Welcome Forums General PowerShell Q&A It is possible to replace "\"

This topic contains 3 replies, has 2 voices, and was last updated by

5 years, 5 months ago.

  • Author
  • #11415

    Points: 0
    Rank: Member

    Hello together
    I habe a array which contains "\Hofdo" and i want to replace the "\" with "" but if i try to replace it with the code:
    $Owner -replace "\", "" it doesn't work

    How can i replace it ?

  • #11416

    Points: 0
    Rank: Member

    PowerShell's -replace operator takes a regular expression as the first argument, and backslashes are special characters. On a side note, when the second argument is an empty string, it's optional, so you can do it like this:

    $Owner -replace '\\'
  • #11417

    Points: 0
    Rank: Member


  • #11419

    Points: 0
    Rank: Member

    Hello again
    i try to find out the E-Mail-adress from an owner of a folder.
    I have a list with Owner of folders and i have already a script where i can search the e-mail of a single person but i want to search the e-mail of several person.
    Here is the script foreach-object{
    if($Owner -ne "Extra"){
    $User = Get-WmiObject -Query "SELECT * FROM ds_user where ds_sAMAccountName='$Owner'" -Namespace "root\Directory\LDAP"
    $Email = $user.DS_mail


    And the contain of the list is so:

The topic ‘It is possible to replace "\"’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort