62
Part I: Laying the Foundations
}
#Add current user as SysAdmin
$command += (' /SQLSYSADMINACCOUNTS="{0}"' -f
[Security.Principal.WindowsIdentity]::GetCurrent().Name)
#Set the database collation
$command += (' /SQLCOLLATION="{0}"' -f $SqlCollation)
#Enable/Disable the TCP Protocol
if ($NoTcp)
{
$command += ' /TCPENABLED="0"'
}
else
{
$command += ' /TCPENABLED="1"'
}
#Enable/Disable the Named Pipes Protocol
if ($NoNamedPipes)
{
$command += ' /NPENABLED="0"'
}
else
{
$command += ' /NPENABLED="1"'
}
if ($PSBoundParameters['Debug'])
{
Write-Output $command
}
else
{
Invoke-Expression $command
}
}
After you download Listing 3-1 from the companion website, save it to a folder, for example
c:\scripts. Because this is a fi le that you download from the Internet, you may be
required to right-click the fi le and unblock it. When downloaded, execute this function by
following these steps.
- Launch the PowerShell command line with elevated Administrator privileges by
right-clicking the PowerShell executable and selecting Run as Administrator. The
PowerShell command line opens.
LISTING 3-1 (continued)
c03.indd 62c03.indd 62 7/30/2012 4:10:08 PM7/30/2012 4:10:08 PM
http://www.it-ebooks.info