Hello,
Several times i need to get the Samaccountname , by using the emailaddress of a user.
The thing is that I do get the Samaccountname, only when I send the output to the clipboard
the output tells me that is is a Samaccountname
“@{samaccountname= accountname}” ( lucky me, that is what I need… )
Only…I am looking for the way to send it to the clipboard without the @{samaccountname= accountname} Just the “Samaccountname”
Thank you in advance for the suggestions,
MY CSV:
UserID Mail Naam
User1 user1@powershel.org User. one
$maillist = Import-Csv P:\Users\PieterB\Scripts\CSV\input.csv -Delimiter ";"
$Sam = foreach( $address in $maillist.mail){
get-aduser -server domainname -filter "emailaddress -eq '$($address)'" -Properties * |select samaccountname
}
$maillist.count
$Sam.count
$sam |Set-Clipboard