Archive for PowerShell

Powershell script to send SQL Server query results via e-mail.

I schedule this script daily to notify a customer of yesterday’s database updates.
col1 is just text
col2 is a smalldate timestamp
I use GETDATE()-1 for yesterday

Read the rest of this entry »

Advertisements

Comments (2)

PowerShell script to back up a SharePoint 2010 Site Collection with a unique (date/time) filename

This PowerShell script will backup a SharePoint 2010 (Host Header URL) Site Collection to a single .BAK file with a date and time filename.

Replace the following with your own values:
bkupLoc = NTFS share that .BAK file will be written to.
sitecoll = the URL of your site collection (I’m using it for a HHURL site collection).

Add-PsSnapin Microsoft.SharePoint.Powershell
#Backup location
$bkupLoc = “\\server\share\myscbkupfolder\
#Date
$adate =get-date
#Site collection location
$sitecoll = “http://mysitecoll.mydomain.com
#daily filename
$bkupfile = $bkupLoc+”{0:ddMMMyyyyhhmm}”-f$adate+”.bak”
Backup-SPSite -Identity $sitecoll -Path $bkupfile

Leave a Comment