[Quick Links] |
Search Site

Site Details

rendered in 0.0428 secs

Captain's Log | Tuesday 19th of April 2016

Exchange management shell commands
get all mailbox names and size
Get-Mailbox -ResultSize unlimited
find what object an e-mail address is assigned to
get-recipient dave@sillysods.com
To export list of mailbox rights to csv not including (self) permissions
Get-Mailbox | Get-MailboxPermission | where {$_.user.tostring() -ne "NT AUTHORITY\SELF" -and $_.IsInherited -eq $false} | Select Identity,User,@{Name='Access Rights';Expression={[string]::join(', ', $_.AccessRights)}} | Export-Csv -NoTypeInformation mailboxpermissions.csv
add calendar rights
Add-MailboxFolderPermission JoyGateley:\Calendar –User AmeyCorlett –AccessRights Editor
View existing calendar permissions
Get-MailboxFolderPermission JoyGateley:\Calendar
remove user permission
remove-MailboxFolderPermission shaunsomers:\Calendar -User Allanwinn
remove a user from all mailboxes
$calendars = get-mailbox
$calendars | ForEach-Object {Remove-MailboxFolderPermission $_":\Calendar" -User SimonWallace}

To hide a mail contact or mailbox you will need to run the following commands:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
>>enter the administrative login details
Import-PSSession $Session
Set-MailContact -Identity contactemailaddress -HiddenFromAddressListsEnabled $true
Or
Set-Mailbox -Identity mailboxemailladdress -HiddenFromAddressListsEnabled $true

365 export license
Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv c:\111\licensedUsers.csv

email tracking


Source “SMTP” means it’s an external email and “STOREDRIVER” means processed internally
Edit the properties of the powershell window to make it 400×300.
Get-Messagetrackinglog -Sender: test.user@testdomain.com -Start "Nov 2 2015" -End "Nov 4 2015" |ft Timestamp, Source, Sender, Recipients, MessageSubject | out-file C:\test_sent.txt
The one below was handy when tracing an incoming email that is going missing/not being delivered, the convert to html also provides additional debug information.
Get-MessageTrackingLog -Sender: getting.lost@fromthisuser.com -Start "04/18/2016 09:00:00" -End "04/19/2016 09:10:00" | Sort TimeStamp | ConvertTo-Html > "C:\message track.html"
  • you can output to html by changing ft to convertto-HTML and the file extention to .html. I think you can output to CSV by changing the same parameter to select, then out-file to Export-Csv and the extention to .csv
  • you can add times by changing -Start "Nov 2 2015" to -Start "Nov 2 2015 11:00:00 PM"
  • you can filter for failed emails by adding -EventID “FAIL”. I also use to filter for -EventID “RECEIVE” but found it was missing some emails I know were delivered

Add Inbox Rule for All Mailboxes
get-MailboxDatabase
Get-MailboxDatabase -identity “Mailbox Database 0413960841” | Add-ADPermission -user adminaccount -AccessRights GenericAll
$Mailboxes = Get-Mailbox
$mailboxes | % { New-InboxRule -Name AVG_JUNK -Mailbox $_.alias -SubjectContainsWords "[AVG SERVER DETECTED AS SPAM]" -MoveToFolder "$($_.alias):\Junk E-Mail" }

get permissions for all mailbox
$OutFile = "C:\Temp\PermissionExport.txt"
"DisplayName" + "^" + "Alias" + "^" + "Full Access" + "^" + "Send As" | Out-File $OutFile -Force
$Mailboxes = Get-Mailbox -RecipientTypeDetails usermailbox -ResultSize:Unlimited | Select Identity, Alias, DisplayName, DistinguishedName
ForEach ($Mailbox in $Mailboxes) {
$SendAs = Get-ADPermission $Mailbox.DistinguishedName | ? {$_.ExtendedRights -like "Send-As" -and $_.User -notlike "NT AUTHORITY\SELF" -and !$_.IsInherited} | % {$_.User}
$FullAccess = Get-MailboxPermission $Mailbox.Identity | ? {$_.AccessRights -eq "FullAccess" -and !$_.IsInherited} | % {$_.User}
$Mailbox.DisplayName + "^" + $Mailbox.Alias + "^" + $FullAccess + "^" + $SendAs | Out-File $OutFile -Append
};

view existing whitelists
(Get-ContentFilterConfig).ByPassedSenders
(Get-ContentFilterConfig).ByPassedSenderDomains

To whitelist a domain e.g. justfen.com you’d do the this:
$WhiteDomain = (Get-ContentFilterConfig).BypassedSenderDomains
$WhiteDomain.add(“justfen.com”)
Set-ContentFilterConfig -BypassedSenderDomains $WhiteDomain

And to Whitelist a sender e.g. me@justfen.com you’d do this:
$WhiteSender = (Get-ContentFilterConfig).BypassedSenders
$WhiteSender.add(“SJLWood@aol.com”)
Set-ContentFilterConfig -BypassedSenders $WhiteSender
Office 365 block / black list mailflow rule1.Sign in your portal(https://login.microsoftonline.com/), click admin -> Exchange.
2.Click mail flow -> rules.
3.Click “+” to add a new rule.
4.Click more options in the new window.
5.”*Apply this rule if…” -> “The sender…” -> “is this person” -> manually entryh the email address you want to block and select check names.
6.”*Do the following…” -> “block the message” ->“Delete the message without notifying anyone”

see all attachment limits, found for 2010, may work with other
get-transportconfig | ft maxsendsize, maxreceivesize
get-receiveconnector | ft name, maxmessagesize
get-sendconnector | ft name, maxmessagesize
get-mailbox |ft Name, Maxsendsize, maxreceivesize

OUT OF OFFICE
Set-MailboxAutoReplyConfiguration AliceShaw -AutoReplyState enabled -ExternalAudience all -InternalMessage "I am out of the office until Thursday 14th August 2014. I will reply on my return but if your query is urgent please contact the office on 0800 1 444 111." -ExternalMessage "I am out of the office until Thursday 14th August 2014. I will reply on my return but if your query is urgent please contact the office on 0800 1 444 111."
exchange 2010/2013 mailbox repair (scan check)
New-MailboxRepairRequest -Mailbox big.dave -CorruptionType SearchFolder,AggregateCounts,ProvisionedFolder,FolderView
then to view the status of the repair: (exchange 2013+ only, otherwise you need to check the application event log for the completion status. In my experience it completes < 10 minutes)
Get-MailboxRepairRequest -Mailbox big.dave | FL


Other
mail que queue directory
C:\\Program Files\\Microsoft\\Exchange Server\\V14\\TransportRoles\\data\\Queue
remove 3rd party transport hooks exchange
C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\Shared\agents\edit config file hereExport mailbox to PST and check statusnew-mailboxexportrequest -mailbox big.dave -filepath "\\server\share\bigDave.pst" -badlimit 50 -acceptlargedataloss
get-mailboxexportrequest
If you ever need to export just the recoverable deleted items, and the retrievable purged items, for a mailbox you can run the following command in EMS 2010 onwards:New-MailboxExportRequest -mailbox USER.NAME -FilePath \\servername\folderlocation\MUSTSPECIFYPSTNAME.pst -IncludeFolders "Recoverable Items"See if a mailbox has been moved to quarantine (outlook disconnected for one user)Get-Mailbox | Get-MailboxStatistics | Where {$_.IsQuarantined –eq $True}
If it is quarantined then to remove it, at speed, you will need to delete the registry key located here - HKLM\SYSTEM\CCS\Services\MSexchangeIS\Servername\Private-dbguid\Quarantined Mailboxes\ {Mailbox GUID}

Then dismount and remount the information store.

archive a mailbox using powershell

new-mailboxexportrequest -mailbox USERSALIAS -filepath "\\mustbe\a\UNC\path\user.pst"

Update UPN in office 365 once it has been updated in AD Active Directory and a manual sync has ran

Set-MsolUserPrincipalName -UserPrincipalName old@upn.address -NewUserPrincipalName new@upn.address


Captain's Log | Friday 1st of April 2016

Issues with print spooler crashing | stopping add printer Windows Microsoft

Reset the whole spooler component

How to disable the gui login screen for Ubuntu MATE? | start up boot src

systemctl set-default multi-user.target --force
systemctl disable lightdm.service --force
systemctl disable graphical.target --force
systemctl disable plymouth.service --force

how to get the battery % percent from the terminal? | ubuntu status src

cat /sys/class/power_supply/BAT0/capacity

how to run grep on a Windows system using powershell | shell src

Select-String -Path C:\temp\*.log -Pattern "Contoso"

php won't upgrade | the following packages have been kept back php can't

apt-get install <list of packages kept back>

how to export / dump users from a mysql server to another | src

  server to take user and permissions from
MYSQL_CONN="-uroot -ppassword"
pt-show-grants ${MYSQL_CONN} > MySQLUserGrants.sql

  server to import user and permissions into
mysql -uroot -p -A < MySQLUserGrants.sql
This is a waste of time, when I imported the users to another table, the username had changed from USER to USER.DATABA - yes, not even the full database name as it ran out of chars.

Test UPS Procedure | APC

sudo vim /etc/apcupsd/apcupsd.conf
-BATTERYLEVEL 5
+BATTERYLEVEL 99
:wq
sudo service apcupsd restart
  pull the power, confirm you get an email, as root should be redirecting to local user mail for terminal, then marry this email shutdown notification time with a clean shutdown state by running the command below. Once all confirmed, revert the BATTERYLEVEL change above

You can also check the logs for a clean shutdown with:
last -x | grep shutdown | less
Also, you can check the UPS event log: /var/log/apcupsd.events
Another also, check current status with:
apcaccess

Find missing mail to root | not receiving

cd /var/mail
ls -lah

If your mail is going to nobody, you can tell by last modified date, then read below:
src | OK. Here is the deal. After researching, postfix is built around security. Hence, the author doesn't like the fact one would log in as root to view root mail. Thus, it won't run anything as root and won't send root mail. It seems to default to sending the mail to user "nobody." One must edit /etc/aliases and add a line like this:root:   NON_PRIVALAGED_USER_NAME
:wq
sudo newaliases