Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Remote PowerShell - Validating new 2008 Cluster

$
0
0

 

Hi,

If it a possible, I need an advice, about remote installation MS Cluster 2008 with PowerShell.

 

I run following script by PowerShell remote to remote machine (Windows 2008 R2), this script only validate a cluster requirements before installing it.

 

## Open remote session connection with Domain Admin user

Function OpenRemoteSessionConnection($osHostname) {

            $domainUser = "vasa"

            $domainUser_Password = "pass!!pass"

            $osDomain = "repa"

 

            $domainPASS = (ConvertTo-SecureString $domainUser_Password -AsPlainText -Force)

            $domainCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList"$osDomain\$domainUser",$domainPASS

 

            $remoteSessionConnection = New-PSSession -ComputerName $osHostname -Credential $domainCredential

            ## Invoke-Command -Session $remoteSessionConnection {hostname}

            ## Remove-PSSession $remoteSessionConnection

           

            return $remoteSessionConnection

}

 

## Close remote session connection

Function CloseRemoteSessionConnection($remoteSessionConnection) {

            Remove-PSSession $remoteSessionConnection

}

 

[ScriptBlock] $global:Remote_ValidatFailoverCluster_ScriptBlock = {

            param($Node01_IP, $Node02_IP)

                       

            Write-Host -ForegroundColor yellow "Validate Windows 2008 R2 Cluster…"

           

            $Node01_HostName = [System.Net.Dns]::gethostentry($Node01_IP)

            $Node02_HostName = [System.Net.Dns]::gethostentry($Node02_IP)

 

            $Node01 = [string]$Node01_HostName.HostName

            $Node02 = [string]$Node02_HostName.HostName

           

            Write-Host -ForegroundColor red "Node-01 IP: $Node01_IP --> HostName: $Node01" ## | Out-File -FilePath C:\aa.txt -append

            Write-Host -ForegroundColor red "Node-02 IP: $Node02_IP --> HostName: $Node02" ## | Out-File -FilePath C:\aa.txt -append

           

            Import-Module FailoverClusters

            Test-Cluster -Node $Node01, $Node02 -Ignore "Storage"

}

 

Function Remote_ValidatFailoverCluster_ScriptBlock($remoteSessionConnection, $Node01, $Node02) {

            Invoke-Command -Session $remoteSessionConnection -ScriptBlock $Remote_ValidatFailoverCluster_ScriptBlock -argumentlist $Node01, $Node02

}

 

$Node01_DB_01 = "172.21.27.14" ## (DC_01 Master DH) DB_01 (Node A)

$Node02_DB_01 = "172.21.27.15" ## (DC_01 Master DH) DB_01 (Node B)

 

$remoteSessionConnection = OpenRemoteSessionConnection $Node01_DB_01

 

 

Remote_ValidatFailoverCluster_ScriptBlock $remoteSessionConnection $Node01_DB_01 $Node02_DB_01

CloseRemoteSessionConnection $remoteSessionConnection

 

I failed on “Test-Cluster” command, I get an error:

 

OpenService'RemoteRegistry' failed.

    The handle is invalid

    + CategoryInfo          : NotSpecified: (:) [Test-Cluster], ClusterCmdletException

    + FullyQualifiedErrorId : Test-Cluster,Microsoft.FailoverClusters.PowerShell.TestClusterCommand

 

 

User “vasa” - Domain Admin

Service “RemoteRegistry” – Run by default with “Local service” account

If I run locally on remote machine this work OK.

 

 Please advice .

 

 

 


Viewing all articles
Browse latest Browse all 10624

Trending Articles