Monthly Archives: February 2017

SharePoint – Render HTML files in the browser

Published / by / Leave a Comment

SharePoint 2013 web applications have browser handling level set to strict. This setting prevents browser from rendering HTML files. HTML files are one example file type that you may want to have open directly in the browser rather downloading and then opening. Use the below script to add HTML and HTM Mime types to Web Application.

$webApplication = Get-SPWebApplication "http:/contoso"
//HTML Files 
//HTM Files

AWS Lambda Function for Snapshots

Published / by / Leave a Comment

You can back up the data on your EBS volumes to Amazon S3 by taking point-in-time snapshots. Lambda function can be used to automate this for daily or weekly backups. Using Lambda is best option than running a machine with Bash or PowerShell scripts. This function also deletes the snapshots that are 30 days or old.

import boto3
 import collections
 import datetime
 import logging
 logger = logging.getLogger()
#Retention for 30 days - Change accordingly
retention_days = 30
def _getRegions():'Getting list of regions')
 ec2Client = boto3.client('ec2')
 regions = []
 for region in ec2Client.describe_regions().get('Regions', []):
 return regions
 except Exception as e:
 raise e
 def lambda_handler(event, context):
count = 0
 regions = _getRegions()
 for region in regions:'RegionName', ''))
 ec = boto3.client('ec2',region_name=region.get('RegionName', ''))
 reservations = ec.describe_instances()['Reservations']
 for reservation in reservations:
 for instance in reservation['Instances']:
 count = count + 1
 # retention_days = [int(t.get('Value')) for t in instance['Tags'] if t['Key'] == 'Retention'][0]
 # retention_days = 14
 instance_name = [str(t.get('Value')) for t in instance['Tags'] if t['Key'] == 'Name'][0]
 #logger.error("Name not defined for " + instance['InstanceId'])
 instance_name = str(instance['InstanceId'])
for dev in instance['BlockDeviceMappings']:
 if dev.get('Ebs', None) is None:
 vol_id = dev['Ebs']['VolumeId'] + '-' + str(dev['DeviceName']) + '-' +"%Y-%m-%d-%H:%M"))'Found EBS volume %s on instance %s' % (vol_id, instance['InstanceId'])
 snap = ec.create_snapshot(VolumeId=vol_id,)
 value = instance_name + '-' + str(dev['DeviceName']) + '-' + datetime.datetime.utcnow().strftime("%Y:%m:%d:%H:%M")
 ec.create_tags(Resources=[snap['SnapshotId'],],Tags=[{'Key': 'Name', 'Value': value },])
 delete_date = datetime.datetime.utcnow() - datetime.timedelta(days=retention_days)
 delete_date = delete_date.strftime('%Y-%m-%dT%H:%M:%S.000Z')'Deleting snapshots older than %d days (before %s) in region %s' % (retention_days, delete_date, regionname) )'setting date to delete:' + str(delete_date))
 snapshotsobject = ec.describe_snapshots(OwnerIds=['XXXXXXXXXXX'])
 snapshots = snapshotsobject['Snapshots']
 for snapshot in snapshots:
 start_date = snapshot['StartTime'].strftime('%Y-%m-%dT%H:%M:%S.000Z')
 if start_date < delete_date:
 try:'Deleting snapshot: snapshotid-' + snapshot['SnapshotId'] +' createddate-'+str(snapshot['StartTime'] ))
 logger.error('error deleting snapshot: snapshotid-' + snapshot['SnapshotId'] +' createddate-'+str(snapshot['StartTime'] ))
return 'success'

Your Intranet in Your Pocket: The SharePoint mobile app

Published / by / Leave a Comment

Microsoft launched SharePoint for iOS, its first mobile SharePoint app. The tool gives you access to the files, portals, sites and teams that you’re used to on the desktop. It’s also smart enough to hop between apps depending on what you’re accessing. It’ll jump to OneDrive if you’re peeking at the company’s document library, for instance, or switch to one of the Office apps if you’re opening a recent file.