Set PageVerify in Sql Server via Powershell

Quick post on how to set the page verification level in sql server with powershell.  This script will set all the user database page verification option to CheckSum if they’re not already set that way.  It’s best practice (and the safest option) to have this set to CheckSum.  For a more in-depth description of page verification, see here.  This uses SQLPSX.

Import-Module SqlServer

Get-SqlDatabase -sqlserver $(Get-SqlServer -sqlserver 'ServerName' -username 'UserName' -password 'Password') | where{-not $_.IsSystemObject} |%{
	if($_.PageVerify -ne [Microsoft.SqlServer.Management.Smo.PageVerify]::Checksum){
		$_.PageVerify = [Microsoft.SqlServer.Management.Smo.PageVerify]::Checksum
		$_.Alter();
	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: