- Details
- Written by: Senka
- Category: Exchange Server
- Hits: 1167
# export photo
$a= Get-ADUser USERNAME -Properties thumbnailphoto
$a.thumbnailphoto | Set-Content c:\path\photo.jpg -Encoding byte
# have photo
$date = (Get-Date).AddDays(-90)
Get-ADUser -Filter {lastlogontimestamp -gt $date -and EmailAddress -like '*' -and thumbnailphoto -notlike '*'} -property * | Select Name,SamAccountName,EmailAddress,Department,@{Name="Disabled"; Exp={$_.useraccountcontrol -band 2}}| ?{$_.Disabled -eq 0} | Sort-Object name | export-csv nophoto.csv -Delimiter ";" -NoTypeInformation -Encoding Default
Get-ADUser -Filter {lastlogontimestamp -gt $date -and EmailAddress -like '*' -and thumbnailphoto -like '*'} -property * | Select Name,SamAccountName,EmailAddress,Department,@{Name="Disabled"; Exp={$_.useraccountcontrol -band 2}}| ?{$_.Disabled -eq 0} | Sort-Object name | export-csv photo.csv -Delimiter ";" -NoTypeInformation -Encoding Default
# import photo
param ($name)
$login="$name@domen"
Import-RecipientDataProperty -Identity $login -Picture -FileData ([Byte[]]$(Get-Content -Path "f:\tasks\exchange_photo\photo\$name.jpg" -Encoding Byte -ReadCount 0))
To remove a photo use the following:
Set-Mailbox USERNAME -removepicture
- Details
- Written by: Senka
- Category: Exchange Server
- Hits: 1039
Смотрим результат, сколько удалит:
Search-Mailbox $mailbox -searchquery 'Получено:<18/05/2013' -EstimateResultOnly:$true
Удаляем:
Search-Mailbox $mailbox -searchquery 'Получено:<18/05/2013' -DeleteContent
- Details
- Written by: Senka
- Category: Exchange Server
- Hits: 1063
$list = Get-Content "dg.txt"
Foreach ($i in $list) {
$i
$grp = get-distributiongroup $i
$manage = $grp.managedby
$newuser = get-user k.tsvetkova
$newmanage = $manage + $newuser
Set-distributiongroup $grp -managedby $newmanage -bypasssecuritygroupmanagercheck
}
Вид файла CSV:
#user,#groupname
#$list = import-csv AddDistributionGroupOwnerList.csv
#Foreach ($i in $list) {
# $grp = get-distributiongroup $i.groupname
# $manage = $grp.managedby
# $newuser = get-user $i.user
# $newmanage = $manage+$newuser
# Set-distributiongroup $grp -managedby $newmanage -bypasssecuritygroupmanagercheck
#}
- Details
- Written by: Senka
- Category: Exchange Server
- Hits: 1047
$mailboxs = Get-Mailbox -server Mail
'Name;PrimarySmtpAddress;Received;Sent' > mbald.csv
foreach ($mailbox in $mailboxs)
{
$received = Get-TransportServer | Get-MessageTrackingLog -ResultSize unlimited -Start (Get-Date).AddDays(-7) -End (Get-Date) -EventId "RECEIVE" -Recipients $mailbox.PrimarySmtpAddress | Measure-Object
$sent = Get-TransportServer | Get-MessageTrackingLog -ResultSize unlimited -Start (Get-Date).AddDays(-1) -End (Get-Date) -EventId "RECEIVE" -Sender $mailbox.PrimarySmtpAddress | Measure-Object
'"' + $mailbox.name + '";"' + $mailbox.PrimarySmtpAddress + '";"'+ $received.count + '";"'+ $sent.count + '"' >> mbald.csv
}
- Details
- Written by: Senka
- Category: Exchange Server
- Hits: 1218
param ($i,$f,$mail)
$match = [regex]::Match($mail,"^([a-z]+\.[a-z]+)@.+$")
$alias = $match.groups[1].value
New-MailContact -ExternalEmailAddress SMTP:$mail -Name "$i $f" -Alias $alias -FirstName "$i" -Initials '' -LastName "$f" -OrganizationalUnit 'Domen/Mail_contacts/OU'