Finding messages sent to a distribution group in Exchange message tracking.

It’s pretty easy to use the get-messagetrackinglog cmdlet to find what mail was sent to a particular mailbox and by whom but what if you wanted to search for emails sent to a distribution list to make sure they were indeed being sent there.  I had a distribution list today that someone said they weren’t receiving any emails sent to it.  It was caused by another issue but the message tracking log allowed me to get a better idea of what was actually being sent to the distribution group.

capture

So if for some reason you want to find out what is being sent to a distribution group
see the PowerShell below.

Get-MessageTrackingLog -resultsize unlimited -EventID Expand | ? {$_.RelatedRecipientAddress -like "distributiongroup@domain.com"} | ft Timestamp,Sender,MessageSubject -Autosize

Mail-enable already created distribution group.

Today I had an AD administrator create a distribution group and add all the members to it in Active Directory.  They needed it enabled in Exchange so I thought easy just go into the EAC (Exchange Administrative Center) and add an existing group.  This was the case in Exchange 2007 and 2010 but not in 2013.  In order to add an existing group so you don’t have to recreate it from the EAC and add all the users back you go into EMC (Exchange Management Console).  Then once in Powershell type in the command belowmail-enable.

Enable-DistributionGroup -Identity “groupnameinAD” -Alias “groupname”
-DisplayName “displayname"

 

 

Creating a scheduled task without being administrator

Good morning, I was working on a scheduled task that would run on a user’s PC and start a particular application when the user logged into their machine and it had to run as the user in particular logging in.  What I discovered was that if the user wasn’t administrator on the box I would get an access denied in both PowerShell and schtasks.

scheduledtask

What I figured out was that if you choose to run the task at logon (I assume this probably applies to at startup as well) it requires administrative rights but if you schedule the task as an hourly, daily, weekly, etc. task it doesn’t require administrative rights to create it.  Now this requires that what the task is running itself doesn’t need administrative rights but in my case it does not.

scheduledtask2

Now you may be asking yourself why didn’t he simply create a scheduled task through group policy.  Well, the reason for that is I wanted it to target a specific computer collection in SCCM that targeted only laptops.  I could have done it with a GPO and even filtered the GPO with WMI filtering and accomplished the same thing but the application is pushed out through SCCM and I wanted everything that went with it targeted to that collection.  Maybe slightly more work on my part but good to know nonetheless.

Simple RoboCopy Function for quick transfers

A couple of weeks ago I got to thinking, I do these little robocopy transfers all the time why not write a function so I can do a transfer and I don’t have to go looking up all the parameters.  So after a few minutes, the below script was born.  Simply run the script in Powershell, and it will prompt for the old folder (source) and the new folder (destination).  Once the copy is complete it will monitor the source directory and copy any changes until you exit the script which is great when a user is still working in the source directory such as when you need to move a home directory.  It also sticks a log file in the directory you ran the script.  Just keep in mind that this is setup to be a mirror copy and if you reverse the source and destination you will copy the blank destination to your source and end up with a blank directory.

It’s an extremely simple script but maybe it will save someone a little time.  Also in case you haven’t aren’t familiar with robocopy it is the best folder syncing tool out there and has been available since Windows Server 2003.  It won’t sync single files but will sync folders up wherever you need them, resume transfers where they left off on flaky network connections, allows throttling and much more.

function fun-robocopy {
$ScriptPath = (Get-Item -Path ".\" -Verbose).FullName
$Logfile = $ScriptPath+"\Robocopy Logfile.log"
$OLDFolder = Read-Host -Prompt 'Input Old folder to move'
$NewFolder = Read-Host -Prompt 'Input New folder to move to'
Robocopy $OldFolder $NewFolder /MIR /COPYALL /V /FP /XO /LOG+:$Logfile /TEE /Z /MON:1 /MOT:30 /W:5 /R:2
}
fun-robocopy
snip_20160531170841