Jump to content
Sign in to follow this  
nkspeed

Failover clustering PowerShell

Recommended Posts

Φοβερό post σχετικά με τη διαχείριση του cluster με powershell.

http://powershelldistrict.com/failover-clustering-powershell/

 

 

How to get all the nodes of a cluster using PowerShell?

Import-Module FailoverCluster -Force
$Cluster = get-cluster -name $env:computername

How to get All the VM’s present on a node from HyperV failover cluster with powershell?

$Nodes = Get-ClusterNode -Cluster $Cluster.Name
 
write-log "Cluster $($Cluster.Name) contains $($Nodes.count) nodes."
 
foreach ($node in $nodes){
    Write-Log "Cluster Node $($Cluster.Name) contains the following VMs"
    $Vms = get-vm -ComputerName $Node.Name
       Foreach ($Vm in $Vms){
          write-Log "$Vm.Name"
       }
     
}

How to get the VM state on a failover cluster using powershell

write-log "Starting state changes operations on node: $($node.Name)"
        Foreach ($vm in $VMs){
 
            if ($vm.Name -like $DataServerName){
                write-log "The DATA server $($vm.Name) is skipped until all machines have been saved or are stopped."
            }else{
                switch ($vm.state){
                    "Running"{
                                write-log "Saving VM $($VM.name) state."
 
                                try{
                                    Save-VM -ComputerName $Node.Name -Name $vm.name -ErrorAction Stop
                                    write-log "--> Successfully saved"
                                }catch{
                                    write-log $_
                                }
                    }
                    "Stopped"{
                                write-log "The VM $($VM.name) is already in stoped state. No action done."
                    "Saved"{
                                write-log "The VM $($VM.name) is already in saved state."
                    }
                    default{
                        Write-log "The current state $($vm.state) could not be defined. Skipping VM."
                        continue
                    }
             
                }#End switch
            }#End If *data*
        }#End foreach VM

Failover clustering: How to stop a cluster resource (the Quorum) using PowerShell?

##Quorum operations
 write-log "Starting Quorum operations"
     
 $Quorum = Get-ClusterQuorum -ErrorAction stop
 
 write-log "Attempting to set Quorum $($Quorum.QuorumResource) offline."
 
 Stop-ClusterResource -Name $Quorum.QuorumResource.name

Failover clustering: How to set Clustered share volumes in maintenance mode using Powershel

##Cluster shared volume operations
           write-log "Starting operations: Setting cluster share volumes into maintenance mode."
 
           $CSVs = Get-ClusterSharedVolume -Cluster $Cluster
 
           write-log "There are $($CSVs.count) clustershared volumes identified on $($Cluster)."
 
           foreach ($csv in $CSVs){
 
               try{
 
                   if (!($csv.name -eq $Quorum.QuorumResource.name)){
 
                       Suspend-ClusterResource -Name $csv.name -force -ErrorAction stop | Out-Null
 
                       write-log "Successfully set clusterSharedVolume $($csv.name) into maintenance mode."
                   }
 
               }catch{
                   write-log $_
               }
           }

Failover clustering: How to stop a cluster resource using powershell?

##Cluster operations
            $ClusterNodeToshutdown = Get-ClusterNode | where {$_.name -ne $env:COMPUTERNAME}
            write-log "Attempting to stop the cluster $($Cluster.Name)."
 
            Stop-Cluster -Cluster $Cluster.Name -Force -ErrorAction stop
 
            write-log "The cluster resource $($Cluster.Name) has been successfully stopped."

Failover clustering: How to stop a cluster node using powershell?

$ClusterNodeToshutdown = Get-ClusterNode | where {$_.name -ne $env:COMPUTERNAME}
 
##Shutting down other cluster Node
     
 
    write-log "Attempting to shutdown the cluster node $($ClusterNodeToshutdown.Name)."
    Stop-Computer -ComputerName $ClusterNodeToshutdown.name -Force

ΝΚ

Share this post


Link to post
Share on other sites

Επειδή φτιάχνομαι άσχημα μετο Powershell (ήθελα βέβαια σε ένα Event να δείξω πως φτιάχνω το Lab σε Private Cloud ) έχω σχεδόν τελειώσει την δικιά μου έκδοση του Powershell Deployment Toolkit, αυτό είναι το Script που φτιάχνει τον πρώτο Node στο SQL Cluster!,

 

Κάνει Join το Node στο Domain, βάζει ονόματα στις κάρτες , παίρνει τους δίσκους (που είναι Shared VHDX) τους βάζει στο Cluster ,κάνει Form το Cluster και Test :)

#Arm the variables
#Domain name and OU
$domain="iqlab"
$Suffix="gr"
$DomainFQDN=$domain + "." + $Suffix

#Enter the node and cluster name
$Node="iQLSQL1"
#Enter the  host Address
$HostDomainAddress="192.168.3.12"
#Enter the Cluster host Address
$HostClusterAddress="172.16.24.10"
#Enter the default GW
$GW="192.168.3.254"
#Enter the default DNS Server
$DNS="192.168.3.1"
#Cluster Name
$ClusterName="SCSQL"

#Arm the IP's on each net adapter
Get-NetAdapter -Name "Ethernet 2" | New-NetIPAddress  -AddressFamily IPv4 -IPAddress $HostDomainAddress -PrefixLength 24  -DefaultGateway $GW
Get-NetAdapter -Name "Ethernet 2" | Set-DnsClientServerAddress -ServerAddresses $DNS
Get-NetAdapter -Name "Ethernet" | New-NetIPAddress  -AddressFamily IPv4 -IPAddress $HostClusterAddress -PrefixLength 24 

#Check to see if we have a winner, else change IP address and names on the NICs
sleep 5
$PingDNSResult=Test-Connection $DNS -Count 1 -ErrorAction SilentlyContinue

#Did it ping?
If ($PingDNSResult.Statuscode -eq 0)
{
#Simply rename , we had it on the first place
$PublicAdapter=Get-NetIPAddress |Where {$_.IPAddress -match "192.168.3*"}| select InterfaceAlias -ExpandProperty InterfaceAlias
$ClusterAdapter=Get-NetIPAddress |Where {$_.IPAddress -match "172.16.24.*"}| select InterfaceAlias -ExpandProperty InterfaceAlias

Rename-NetAdapter $PublicAdapter -NewName "Public Data"
Rename-NetAdapter $ClusterAdapter -NewName "Cluster Data"

}
else {
#No.... :( OK start from scrach , change the nics , continue and rename
Get-NetAdapter| Remove-NetIPAddress -Confirm:$False


Get-NetAdapter -Name "Ethernet 2" | New-NetIPAddress  -AddressFamily IPv4 -IPAddress $HostClusterAddress -PrefixLength 24  
Get-NetAdapter -Name "Ethernet" | New-NetIPAddress  -AddressFamily IPv4 -IPAddress $HostDomainAddress -PrefixLength 24 -DefaultGateway $GW
Get-NetAdapter -Name "Ethernet" | Set-DnsClientServerAddress -ServerAddresses $DNS

$PublicAdapter=Get-NetIPAddress |Where {$_.IPAddress -match "192.168.3*"}| select InterfaceAlias -ExpandProperty InterfaceAlias
$ClusterAdapter=Get-NetIPAddress |Where {$_.IPAddress -match "172.16.24.*"}| select InterfaceAlias -ExpandProperty InterfaceAlias

Rename-NetAdapter $PublicAdapter -NewName "Public Data"
Rename-NetAdapter $ClusterAdapter -NewName "Cluster Data"

}

#Join the computer to the domain!
Add-Computer -DomainName $DomainFQDN -NewName $Node -OUPath "OU=Member Servers,OU=Infra,DC=iqlab,DC=GR"

#Please Reboot!!!
#----------------------------------------------------------------#

#Part Two - Form the Cluster
$Node="iQLSQL1.iqlab.gr"
#Cluster Name
$ClusterName="SCSQL"

#Online the Disks
Get-Disk |where {$_.OperationalStatus -eq "Offline"} | set-disk -IsOffline $False

#Initialize , format and ready the disks!
Get-Disk |where {$_.Size -match "107374182400" -and $_.IsBoot -eq $False} |Initialize-Disk -PartitionStyle GPT 
Get-Disk |where {$_.Size -match "107374182400" -and $_.IsBoot -eq $False} |New-Partition -DriveLetter S  -UseMaximumSize 
Get-Partition -DriveLetter S |Format-Volume  -FileSystem NTFS -NewFileSystemLabel "SQL Data" -AllocationUnitSize 64KB -Confirm:$False

Get-Disk |where {$_.Size -eq "85899345920"}|Initialize-Disk -PartitionStyle GPT 
Get-Disk |where {$_.Size -eq "85899345920"}|New-Partition -DriveLetter L -UseMaximumSize
Get-Partition -DriveLetter L |Format-Volume  -FileSystem NTFS -NewFileSystemLabel "SQL Logs" -AllocationUnitSize 64KB -Confirm:$False


Get-Disk |where {$_.Size -eq "53687091200"}|Initialize-Disk -PartitionStyle GPT  
Get-Disk |where {$_.Size -eq "53687091200"}|New-Partition -DriveLetter T -UseMaximumSize
Get-Partition -DriveLetter T |Format-Volume  -FileSystem NTFS -NewFileSystemLabel "SQL Temp" -AllocationUnitSize 64KB -Confirm:$False

Get-Disk |where {$_.Size -eq "1073741824"}|Initialize-Disk -PartitionStyle GPT  
Get-Disk |where {$_.Size -eq "1073741824"}|New-Partition -DriveLetter Q -UseMaximumSize
Get-Partition -DriveLetter Q |Format-Volume  -FileSystem NTFS -NewFileSystemLabel "Quorum" -AllocationUnitSize 64KB -Confirm:$False



#Install the cluster tools
Add-WindowsFeature Failover-clustering
Add-WindowsFeature RSAT-Clustering-MGMT

sleep 5

#Form the cluster
New-Cluster -Name $ClusterName -Node $Node -StaticAddress 192.168.3.99

#Add the disks to the cluster and name them!
$DataDiskName=Get-ClusterAvailableDisk  |where {$_.Size -match "107374182400"} |select Name -ExpandProperty Name
Get-ClusterAvailableDisk  |where {$_.Size -match "107374182400"} |Add-ClusterDisk -Cluster SCSQL 
(Get-ClusterResource $DataDiskName ).name="SQL Data Disk"

$LogDiskName=Get-ClusterAvailableDisk  |where {$_.Size -match "53687091200"} |select Name -ExpandProperty Name
Get-ClusterAvailableDisk  |where {$_.Size -match "53687091200"} |Add-ClusterDisk -Cluster SCSQL
(Get-ClusterResource $LogDiskName ).name="SQL Log Disk"

$TempDiskName=Get-ClusterAvailableDisk  |where {$_.Size -match "85899345920"} |select Name -ExpandProperty Name
Get-ClusterAvailableDisk  |where {$_.Size -match "85899345920"} |Add-ClusterDisk -Cluster SCSQL
(Get-ClusterResource $TempDiskName ).name="SQL Temp Disk"

$QuorumDiskName=Get-ClusterAvailableDisk  |where {$_.Size -match "1073741824"} |select Name -ExpandProperty Name
Get-ClusterAvailableDisk  |where {$_.Size -match "1073741824"} |Add-ClusterDisk -Cluster SCSQL
(Get-ClusterResource $QuorumDiskName ).name="Quorum"


#Now that we have disks  , configure Quorum
Set-ClusterQuorum -NodeAndDiskMajority "Quorum"

#Name the networks so u do not get lost set cluster comms on Subnet Public
(Get-ClusterNetwork | where-object {$_.Address -eq "192.168.3.0"}).Name = "Public Data"
(Get-ClusterNetwork | where-object {$_.Address -eq "172.16.24.0"}).Name = "Cluster Data"
(Get-ClusterNetwork “Cluster Data”).Role =1


#Test the Cluster
Test-Cluster -Cluster $ClusterName

Share this post


Link to post
Share on other sites

Και αυτό είναι το πρώτο HVNode πριν το Cluster :P

Αλλάζει μερικές παράμετρους και στήνει το Storage Space

#------------------------------------------------------------------------------------------------------------#
#Configure basic Hyper V Host configuration
$ComputerName="iQLHV1"
$ISOFile="c:\setup\iso\en_windows_server_2012_r2_with_update_x64_dvd_4065220.iso"
#Enable RDP 
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\terminal server' -Name "FdenyTSConnections" -Value 0
#Enable Rules for RDP
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
#Set time zone to GTB (Greece,Turkey,Belarus) , this is actually a dos command
tzutil /s "GTB Standard Time"
#Disable IE Esc
Set-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}” -Name “IsInstalled”  -Value 0
Set-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}” -Name “IsInstalled”  -Value 0
#Configure updates
cscript c:\Windows\system32\scregedit.wsf /au 4
Set-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update” -Name “AUOptions”  -Value 3
Set-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update” -Name “IncludeRecommendedUpdates”  -Value 1
Set-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update” -Name “CachedAUOptions”  -Value 3
Restart-Service wuauserv

#Rename the computer
Rename-Computer -NewName $ComputerName

#Let's install the roles and features needed
#Mount the iso, get the letter name to set to source variable
$Source=Mount-DiskImage -ImagePath $ISOFile -PassThru|Get-Volume | select DriveLetter -ExpandProperty DriveLetter

Install-WindowsFeature Hyper-V -IncludeManagementTools
Install-WindowsFeature NET-Framework-Core -Source "$Source\sources\sxs"
Install-WindowsFeature Failover-Clustering 
Install-WindowsFeature Multipath-IO
Install-WindowsFeature SNMP-Service -IncludeAllSubFeature

#Reboot please

#------------------------------------------------------------------------------------------------------------#
#Prepare the Storage Pool that will store the VM's

#Get the disks first!
$Disks=Get-PhysicalDisk -CanPool $True
#Find the storage subsystem (which is local on our case)
$StorageSubSystem=Get-StorageSubSystem | Select UniqueId -ExpandProperty UniqueId
#Create the Storage Pool
New-StoragePool -FriendlyName "VM Volume"  -StorageSubSystemUniqueId $StorageSubSystem -PhysicalDisks $Disks


#Create the Virtual Disk on the Space
#Get the Storage Pool id
$StoragePoolId=Get-StoragePool -FriendlyName "VM Volume" | Select UniqueId -ExpandProperty UniqueId
#Create the Vdisk
New-VirtualDisk -FriendlyName "HyperV" -StoragePoolUniqueId $StoragePoolId -UseMaximumSize  -ProvisioningType Fixed -ResiliencySettingName "Parity"

#Online the Vdisk and format it 
#Find the disk , keep its number in a variable for the rest of the operations
$Disk=Get-Disk | where {$_.OperationalStatus -eq "Offline"} |select Number -ExpandProperty Number
#Bring the disk Online
Get-Disk -Number $Disk | Set-Disk -IsOffline $False
#Initialize disk in GPT
Get-Disk -Number $Disk | Initialize-Disk -PartitionStyle GPT
#Create new partition on it
Get-disk -Number $Disk | New-Partition -DriveLetter H  -UseMaximumSize 
#Format the Partition to NTFS
Get-Partition -DriveLetter H |Format-Volume  -FileSystem NTFS -NewFileSystemLabel "HyperV"  -Confirm:$False

#------------------------------------------------------------------------------------------------------------#

#Configure temporary Networking ,we will use VMM later on

#Enter the Switch name that will be used for domain access
$SwitchName1="DomainTemp"
#Enter the Switch name that will be used for client private communication
$SwitchName2="ClusterTemp"
#Enter the HyperV host Address
$HVHostDomainAddress="192.168.3.10"
#Enter the default GW
$GW="192.168.3.254"
#Enter the default DNS Server
$DNS="192.168.3.1"

#Add the switches
New-VMSwitch -Name "$SwitchName1" -SwitchType Internal 
New-VMSwitch -Name "$SwitchName2" -SwitchType Private 
#Set the IP address on the net adapters
Get-NetAdapter -Name "vEthernet ($SwitchName1)" | New-NetIPAddress  -AddressFamily IPv4 -IPAddress $HVHostDomainAddress -PrefixLength 24  -DefaultGateway $GW
Get-NetAdapter -Name "vEthernet ($SwitchName1)" | Set-DnsClientServerAddress -ServerAddresses $DNS


#------------------------------------------------------------------------------------------------------------#

#Configure Basic Host Options

#Enter the path that will be used for HyperV VM's
$Path="h:\"

#Set the default VM path and Enhanced Session Mode to True
set-vmhost -VirtualHardDiskPath $Path -VirtualMachinePath $Path -EnableEnhancedSessionMode $True 


Share this post


Link to post
Share on other sites

Άντε ας βάλω άλλο ένα , αυτό είναι το SQL VM Preparation, στο οποίο παίρνω το Template VHDX και το ετοιμάζω με ένα νέο Unattend για να πάει στη θέση του έτσι ώστε να στήσω το SQL Cluster παρακάτω , θέλω κάποια στιγμή να το δείξω αυτό πως παίζει! :)

#Arm the name and the HDD's to be added
#Cpu Cores in the VM
$CpuCount=6
#Ram Size
$RAMCount=10GB
#VMName , will also become the Computer Name
$Name="iQLSQL1"
#Domain IP
$IPDomain="192.168.3.11"
#Cluster network IP
$IPCluster="10.20.30.100"
#Default Gateway
$DefaultGW="192.168.3.254"
#DNS Server for Domain Access
$DNSServer="192.168.3.1"
#DNS Domain Name
$DNSDomain="iQLab.gr"
#Switches for domain Communication and cluster comms
$SwitchNameDomain="DomainTemp"
$SwitchNamePrivate="ClusterTemp"
#Mac Address for nics
$MacAddressDomain="00-15-5D-65-99-11"
$MacAddressCluster="00-15-5D-65-99-12"
#Username,password and org info
$AdminAccount="Administrator"
$AdminPassword="P@ssw0rd"
$Organization="iQ Labs"
#This ProductID is actually the AVMA key provided by MS
$ProductID="Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW"
#Where are the folders with prereq software ?
$StartupFolder="C:\Setup\Prerequisites"
$TemplateLocation="C:\Setup\Prerequisites\template.vhdx"
$UnattendLocation="C:\Setup\Prerequisites\unattend.xml"
$Path= Get-VMHost |select VirtualMachinePath -ExpandProperty VirtualMachinePath 
#Folder and file name path for SQL HDD's
$VHDPath=$Path + $Name + "\" + $Name + ".vhdx"
$DataDisk1=$Path + $Name + "\" + $Name +"_SQLDataDisk" + ".vhdx"
$LogDisk1=$Path + $Name + "\" + $Name + "_SQLLogDisk" + ".vhdx"
$TempDisk1=$Path + $Name + "\" + $Name + "_SQLTempDisk" + ".vhdx"
$Quorum=$Path + $Name + "\" + $Name + "_Quorum" + ".vhdx"
$TempVHD=$Path + $Name + "\" + $Name + "_Temp.vhdx"



#Start!-----------------------------------------------------------------------####

#Create the VM
New-VM -Name $Name -Path $Path -SwitchName $SwitchNameDomain -MemoryStartupBytes $RAMCount   -Generation 2 -NoVHD 

#Add a second adapter for cluster comms
Add-VMNetworkAdapter -VMName $Name  -SwitchName $SwitchNamePrivate

#Get network adapters and set mac addresses, will add these to the unattend.xml file later on
$ArmedDomainMAC=$MacAddressDomain -replace "-",""
$ArmedClusterMAC=$MacAddressCluster -replace "-",""

$DomainNic=Get-VMNetworkAdapter $Name |where {$_.SwitchName -eq $SwitchNameDomain} |Set-VMNetworkAdapter -StaticMacAddress $MacAddressDomain
$ClusterNic=Get-VMNetworkAdapter $Name |where {$_.SwitchName -eq $SwitchNamePrivate} |Set-VMNetworkAdapter -StaticMacAddress $MacAddressCluster
 
#Copy the template and add the disk
Copy-item $TemplateLocation -Destination  $VHDPath
Set-VM -Name $Name -ProcessorCount $CpuCount -AutomaticStartAction Start -AutomaticStopAction ShutDown -AutomaticStartDelay 90  

#Create the SQL Data drives
Add-VMHardDiskDrive -VMName $Name -ControllerType SCSI -Path $VHDPath
New-VHD -Path $DataDisk1 -Dynamic -SizeBytes 100GB 
Add-VMHardDiskDrive -VMName $Name -ControllerType SCSI -Path $DataDisk1 -SupportPersistentReservations 
New-VHD -Path $LogDisk1 -Dynamic -SizeBytes 50GB
Add-VMHardDiskDrive -VMName $Name -ControllerType SCSI -Path $LogDisk1 -SupportPersistentReservations 
New-VHD -Path $TempDisk1 -Dynamic -SizeBytes 80GB
Add-VMHardDiskDrive -VMName $Name -ControllerType SCSI -Path $TempDisk1 -SupportPersistentReservations 
New-VHD -Path $Quorum -Dynamic -SizeBytes 1GB
Add-VMHardDiskDrive -VMName $Name -ControllerType SCSI -Path $Quorum -SupportPersistentReservations 

#Set first boot device
$Drive=Get-VMHardDiskDrive -VMName $Name | where {$_.Path -eq "$VHDPath"}
Get-VMFirmware -VMName $Name | Set-VMFirmware -FirstBootDevice $Drive

#Prepare the unattend.xml file to send out, simply copy to a new file and replace values
Copy-Item $UnattendLocation $StartupFolder\"unattend"$Name".xml"
$DefaultXML=$StartupFolder+ "\unattend"+$Name+".xml"
$NewXML=$StartupFolder + "\unattend$Name.xml"
$DefaultXML=Get-Content $DefaultXML
$DefaultXML  | Foreach-Object {
    $_ -replace '1AdminAccount', $AdminAccount `
       -replace '1Organization', $Organization `
       -replace '1Name', $Name `
       -replace '1ProductID', $ProductID`
       -replace '1MacAddressDomain',$MacAddressDomain `
       -replace '1DefaultGW', $DefaultGW `
       -replace '1DNSServer', $DNSServer `
       -replace '1DNSDomain', $DNSDomain `
       -replace '1AdminPassword', $AdminPassword `
       -replace '1IPDomain', $IPDomain `
    } | Set-Content $NewXML

#Mount and send the configuration items to unattend.xml on the boot vhd!!!


$vhdsize = 1GB
New-VHD -Path $TempVHD -Dynamic -SizeBytes $vhdsize | Mount-VHD -Passthru |Initialize-Disk -Passthru |New-Partition -DriveLetter X -UseMaximumSize |Format-Volume -FileSystem NTFS -Confirm:$false -Force 
Dismount-VHD $TempVHD

mount-vhd -path $TempVHD
#Copy the new unattend
Copy-Item  $NewXML -Destination x:\unattend.xml
#Eject VHD
Dismount-VHD $TempVHD

#Mount this drive to the scsi channel
Add-VMHardDiskDrive -VMName $Name -ControllerType SCSI -Path $TempVHD


#Enable Remote Connections to this VM
Set-Item WSMan:\localhost\Client\TrustedHosts  –Value * -Force


#Start the VM
Start-VM $Name

#Phase 1 Complete---------------------------------------------------------------------#
#Start Phase 2 Configure the VM


#Let's Connect
$password = ConvertTo-SecureString $AdminPassword -AsPlainText -Force
$cred= New-Object System.Management.Automation.PSCredential ($AdminAccount, $password )
Enter-PSSession $IPDomain -Credential $cred


#Rename the nics so we do not get lost , but first , try to ping to see if something went bad
#Check to see if we have a winner, else change IP address and names on the NICs
$DNSServer="192.168.3.1"
$PingDNSResult=Test-Connection $DNSServer -Count 1 -ErrorAction SilentlyContinue
#Did it ping?
If ($PingDNSResult.Statuscode -eq 0)
{
#Simply rename , we had it on the first place
$PublicAdapter=Get-NetIPAddress |Where {$_.IPAddress -match $IPDomain}| select InterfaceAlias -ExpandProperty InterfaceAlias
$ClusterAdapter=Get-NetIPAddress |Where {$_.IPAddress -match $IPCluster}| select InterfaceAlias -ExpandProperty InterfaceAlias

Rename-NetAdapter $PublicAdapter -NewName "Public Data"
Rename-NetAdapter $ClusterAdapter -NewName "Cluster Data"

}
else {
#No.... :( OK start from scrach , change the nics , continue and rename
Get-NetAdapter| Remove-NetIPAddress -Confirm:$False


Get-NetAdapter -Name "Ethernet 2" | New-NetIPAddress  -AddressFamily IPv4 -IPAddress $HostClusterAddress -PrefixLength 24  
Get-NetAdapter -Name "Ethernet" | New-NetIPAddress  -AddressFamily IPv4 -IPAddress $HostDomainAddress -PrefixLength 24 -DefaultGateway $GW
Get-NetAdapter -Name "Ethernet" | Set-DnsClientServerAddress -ServerAddresses $DNS

$PublicAdapter=Get-NetIPAddress |Where {$_.IPAddress -match $IPDomain}| select InterfaceAlias -ExpandProperty InterfaceAlias
$ClusterAdapter=Get-NetIPAddress |Where {$_.IPAddress -match $IPCluster| select InterfaceAlias -ExpandProperty InterfaceAlias

Rename-NetAdapter $PublicAdapter -NewName "Public Data"
Rename-NetAdapter $ClusterAdapter -NewName "Cluster Data"

}

Share this post


Link to post
Share on other sites

Επειδή βλέπω πως σας αρέσουν αυτά smile.png έχω να παραθέσω μερικά URLs.

 

Ben Armstrong's Big Build Script @ MVP Summit 2015

 

Στο τελευταίο MVP Summit (2015), o Ben Armstrong, Principal Program Manager στον Hyper-V, μας παρουσίασε όλες τις νέες δυνατότητες του Hyper-V που έρχεται στον Windows Server 2016, μέσω αυτού του Script που φτιάχνει .... ένα ολόκληρο DataCenter ! Η παρουσίαση είχε τίτλο "Hold My Beer while i build the Datacenter"

 

Θα πάρετε πολλές ιδέες σχετικά με την διαχείριση των images, NanoServer, Containers και θα δείτε functions που αυτοματοποιούν κάποιες εργασίες που ο Παναγιώτης αφήνει αυτόν που τρέχει το script, να κάνει manual, δηλαδή Reboot, AD Join κ.λ.π.

 

Θα ποστάρω και μιά δική μου έκδοση του Script που είναι μιά striped down version ....

Share this post


Link to post
Share on other sites

function waitForPSDirect

 

Εμείς να δεις πως περιμένουμε :) ,πέρα από την πλάκα , το script του Armstrong είναι κέντημα και ακόμη πιο κέντημα θεωρώ το DSC ,αν έχεις την όρεξη φυσικά να το φτιάξεις από το 0.

 

Στην Ελλάδα των 10Nodes max αυτά είναι πολυτέλειες και γίνονται μόνο για τη φάση μας.

Share this post


Link to post
Share on other sites

Συμφωνώ για το DSC, αλλά μην ξεχνάς οτι αυτό (DSC) είναι μιά πλατφόρμα Configuration Management και περιμένει να φτιαχτούν επάνω της εργαλεία που θα κάνουν abstract τις δυσκολίες και τις παραξενιές και θα αυτοματοποιούν τα υπόλοιπα κομμάτια.

 

Το ήξερα πως θα σ'αρέσει αυτό το Function  wink.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...