Skip to content

Commit

Permalink
DSC によるインストールを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
MasayukiOzawa committed Sep 22, 2016
1 parent d1f3bf3 commit b5f9769
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions PowerShell/DSC/Install-SQLServer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# https://github.com/PowerShell/xSQLServer
# C:\Program Files\WindowsPowerShell\Modules に DSC Resource を配置

if(!(Test-Path (Join-Path $ENV:ProgramFiles "WindowsPowerShell\Modules\xSQLServer\ja-jp"))){
Copy-Item (Join-Path $ENV:ProgramFiles "WindowsPowerShell\Modules\xSQLServer\en-us") (Join-Path $ENV:ProgramFiles "WindowsPowerShell\Modules\xSQLServer\ja-jp") -Recurse
}
$Password = "M@sterEr0s"

Configuration LCM
{
LocalConfigurationManager
{
AllowModuleOverwrite = $true
DebugMode = "ForceModuleImport"
RebootNodeIfNeeded = $true
}
}

Configuration SQLServer
{
Import-DscResource -Module xSQLServer

Node $AllNodes.NodeName
{
xSqlServerSetup SQLServer
{
SourcePath = $Node.SourcePath
SourceFolder = $Node.SourceFolder
SetupCredential = $Node.SetupCredential
InstanceName = $Node.InstanceName
Features = $Node.Features
SQLSysAdminAccounts = $Node.SQLSysAdminAccounts
InstallSharedDir = $Node.InstallSharedDir
InstallSharedWOWDir = $Node.InstallSharedWOWDir
InstanceDir = $Node.InstanceDir
InstallSQLDataDir = $Node.InstallSQLDataDir
SQLUserDBDir = $Node.SQLUserDBDir
SQLUserDBLogDir = $Node.SQLUserDBLogDir
SQLTempDBDir = $Node.SQLTempDBDir
SQLTempDBLogDir = $Node.SQLTempDBLogDir
SQLBackupDir = $Node.SQLBackupDir
}
xSQLServerFirewall SQLFirewall
{
DependsOn = "[xSqlServerSetup]SQLServer"
InstanceName = $Node.InstanceName
Features = $Node.Features
SourcePath = $Node.SourcePath
SourceFolder = $Node.SourceFolder
}
}
}

$SetupCredential = New-Object System.Management.Automation.PSCredential ("Administrator", (ConvertTo-SecureString -String $Password -AsPlainText -Force))

$ConfiguraionData = @{
AllNodes = @(
@{
NodeName = '*'
PSDscAllowPlainTextPassword = $true
SourcePath = "D:\"
SourceFolder = ""
},
@{
NodeName = "localhost"
InstanceName = "MSSQLSERVER"
Features = "SQLENGINE,FULLTEXT,REPLICATION"
SetupCredential = $SetupCredential
SQLSysAdminAccounts = ".\administrator"
InstallSharedDir = "C:\Program Files\Microsoft SQL Server"
InstallSharedWOWDir = "C:\Program Files (x86)\Microsoft SQL Server"
InstanceDir = "C:\Program Files\Microsoft SQL Server"
InstallSQLDataDir = ""
SQLUserDBDir = ""
SQLUserDBLogDir = ""
SQLTempDBDir = ""
SQLTempDBLogDir = ""
SQLBackupDir = ""
TCPPort = "1433"
}
)
}

LCM -OutputPath C:\temp
Set-DscLocalConfigurationManager -Path c:\temp
Get-DscLocalConfigurationManager

SQLServer -OutputPath (Join-Path "C:\temp" "Mof") -ConfigurationData $ConfiguraionData -Verbose
Start-DscConfiguration -Path (Join-Path "C:\temp" "Mof") -Verbose -Wait -Force
Get-DscConfiguration

0 comments on commit b5f9769

Please sign in to comment.