Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasayukiOzawa/60cd9bfaf9e095d7b767 to your computer and use it in GitHub Desktop.
Save MasayukiOzawa/60cd9bfaf9e095d7b767 to your computer and use it in GitHub Desktop.
$cred = Get-Credential
$Node = @("10.200.0.6", "10.200.0.7", "10.200.0.9")
$script = {
if((Get-WindowsFeature -Name Failover-Clustering).InstallState -ne "Installed"){
Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools
}else{
Write-Output "Failover-Clustering Feature has Installed"
}
$PSFile = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\FailoverClusters\Microsoft.FailoverClusters.PowerShell.psm1"
if(Test-Path $PSFile){
$PSFileACL = (Get-ACL -Path $PSFile)
$CurrentACL = New-Object -TypeName System.Security.Principal.NTAccount($PSFileACL.Owner)
$AdminACL = New-Object -TypeName System.Security.Principal.NTAccount("BUILTIN\Administrators")
$AdminFull = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule($AdminACL,
[System.Security.AccessControl.FileSystemRights]::FullControl,
[System.Security.AccessControl.InheritanceFlags]::None ,
[System.Security.AccessControl.PropagationFlags]::None,
[System.Security.AccessControl.AccessControlType]::Allow)
$PSFileACL.SetOwner($AdminACL)
$PSFileacl.AddAccessRule($AdminFull)
Set-ACL -Path $PSFile -AclObject $PSFileACL
Copy-Item $PSFile "$(Split-Path -Path $PSFile -Parent)\$([System.IO.Path]::GetFileNameWithoutExtension($PSFile))_old.psm1"
$PSContent = Get-Content $PSFile
<#
[System.BitConverter]::ToString(([System.Text.Encoding]::UTF8.GetBytes('”')))
[System.BitConverter]::ToString(([System.Text.Encoding]::UTF8.GetBytes('“')))
$PSContent = (Get-Content $PSFile) -replace [System.Text.Encoding]::UTF8.GetString([byte[]](0xe2, 0x80, 0x9c)), '"'
$PSContent = (Get-Content $PSFile) -replace [System.Text.Encoding]::UTF8.GetString([byte[]](0xe2, 0x80, 0x9D)), '"'
#>
$PSContent[73] = @'
$Message = $Message + " – cmdlet was cancelled"
'@
$PSContent[95] = @'
ShowError("Wrong OS Version - Need at least Windows Server 2012 R2 or Windows 8.1. You are running '" + $OS.Name + "'")
'@
Set-Content -Path $PSFile -Value $PSContent -Encoding Unicode
$PSFileACL.SetOwner($CurrentACL)
Set-ACL -Path $PSFile -AclObject $PSFileACL
}else{
Write-Output "$PSFile not existing"
}
$DNSSuffix = "wsfc.local"
Set-ItemProperty registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters -Name "NV Domain" -Value $DNSSuffix
Register-DnsClient
}
Invoke-Command -ComputerName $Node -ScriptBlock $script -Credential $cred
Invoke-Command -ComputerName $Node -ScriptBlock {Restart-Computer -Force} -Credential $cred
<#
#Azure VM 向け (証明書チェックを外している)
Invoke-Command -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -ComputerName $Node -ScriptBlock $script -Credential $cred
Invoke-Command -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) -ComputerName $Node -ScriptBlock {Restart-Computer -Force} -Credential $cred
#>
New-Cluster -Name WSFC-CNO -node $Node -AdministrativeAccessPoint Dns
Set-ClusterQuorum -CloudWitness -AccountName <ストレージアカウント名> -AccessKey <ストレージアカウントキー>
<#
$StaticIP = "10.110.0.1"
New-Cluster -Name WSFC-CNO -StaticAddress $StaticIP -node $Node -AdministrativeAccessPoint Dns
#Azure 向け
$cred = Get-Credential
$Node = @("SQL2016-01","SQL2016-02")
$Script = {
$DNSSuffix = (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE).DNSDomain
Set-ItemProperty registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters -Name "NV Domain" -Value $DNSSuffix
Register-DnsClient
}
Invoke-Command -ComputerName $Node -ScriptBlock $script -Credential $cred -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
Invoke-Command -ComputerName $Node -ScriptBlock {Restart-Computer -Force} -Credential $cred -UseSSL -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
Get-ClusterResource "Cluster IP Address" | Get-ClusterParameter
Get-ClusterResource "Cluster IP Address" | Set-ClusterParameter -Multiple @{Address="169.254.1.1";SubnetMask="255.255.255.255";OverrideAddressMatch=1;EnableDhcp=0}
Start-ClusterGroup -Name "Cluster Group"
Get-ClusterGroup
Get-ClusterNode
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment