Author Posts

November 13, 2013 at 4:23 am

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 ?

November 13, 2013 at 4:49 am

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 '\\'

November 13, 2013 at 5:30 am

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:
@{Extra}
@{Hofdo}
@{Kunfa}
@{Visne}
@{KIP}