Tuesday, 14 May 2019

Message Tracking on Exchange 2013 and later

Message Tracking on Exchange 2013 and later

Microsoft in their infinite wisdom have decided to do away with the GUI for this in Exchange 2013. Now it has to be done in the exchange management powershell 

Use the following to search by sender

Get-MessageTrackingLog -resultsize unlimited -Start "05/01/2019" -End "05-10-2019" -Sender scott.sharland@molevalleyfarmers.com | export-csv c:\savefile.csv 
  
Date format is MONTH/DAY/YEAR 
  
Add -server SERVERNAME to change the server you want to search for tracking logs on. The default will be the server you are running the shell on 
  
Change -Sender to -Recipients to look for where mail has been sent to instead of from

Tuesday, 26 February 2019

Use RHEL DVD as a Yum repository


Firstly, insert your DVD and mount it to /media/cdrom (or anywhere you would normally mount it and change the path in the code below)
To get yum use the RHEL DVD as a repository, add the file ‘rhel-dvd.repo’ in /etc/yum.repos.d with the following content:
1
2
3
4
[dvd]
name=Red Hat Enterprise Linux Installation DVD
enabled=0
The baseurl needs to point to the folder which contains the repodata folder. On the RHEL7 media this is directly in the mounted directory of the disc, in this case /media/cdrom so the file above should be adjusted accordingly.This will add a repository named ‘dvd’ and is disable it so that a normal 'yum' command won't read it by default. In order to use this repository, add ‘–enablerepo=dvd’ to your command for example. You can also add --nogpgcheck if you don't have the gpg keys installed and are unable to. This is a security feature that is there to prevent the downloading of malicious packages so should only be done when the installation source is trusted
 
1
# yum install --enablerepo=dvd --nogpgcheck packagename

Tuesday, 22 January 2019

Find and move files older than 365 days in Linux


How to find and move files older than 365 days in Linux

The command:

find /sourcedirectory -iname “*file extension or part of file name*” -mtime +365 -type f -exec mv "{}" /destination/directory/ \;


The mtime command can be modified to another number which will move anything from that number of days and older. The + can also be changed to a - which will move anything newer instead. If neither a + or a - is specified then it will move just files exactly that many days old.

The '-type f' command ensures only files are moved, not directories 

Thursday, 23 August 2018

Grant a user access to view stored procedures in MSSQL

To grant access to a non admin user (assuming you have created them an SQL login imported from Active Directory), first run this command in a new query window from SSMS, substituting domain\username for the actual users credentials. Make sure you are targeting the correct database in the context menu


select 'GRANT VIEW DEFINITION ON [' + schema_name(schema_id) + '].[' + name +
       '] TO ' + '[domain\username]'
  from sys.all_objects
where type_desc = 'SQL_STORED_PROCEDURE'
   and schema_id <> schema_id('sys')


This will return a list of the commands you need to run to allow the user access to each stored procedure. Right click the table and select all then copy. Now paste this into your query window, overwriting the above command and run it. Voila, it is done.