Posts Tagged 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 »


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\
$adate =get-date
#Site collection location
$sitecoll = “
#daily filename
$bkupfile = $bkupLoc+”{0:ddMMMyyyyhhmm}”-f$adate+”.bak”
Backup-SPSite -Identity $sitecoll -Path $bkupfile

Leave a Comment

Moving a SharePoint 2010 Host Header Site Collection to a new server in a new domain.

This example describes how to move a SharePoint 2010 Host Header (HHURL) site collection from a server in domaina to a new server in domainb. The example also deals with migrating users within the HHURL site collection from domaina to domainb.

The existing HHURL site collection is currently on hosta and Content Database is existingDB.
Create a new HHURL site collection on on hostb and Content Database is mynewscDB.
Ensure your DNS record for the new HHURL site collection is mapped correctly i.e. you can get to it from the outside world.
Login to the new site collection and verify.
Backup the existing site collection on hosta to scbackup.bak file using Central Admin > Backup & Restore > Granular Backup > Perform a Site Collection Backup. Read the rest of this entry »

Comments (3)