English 中文(简体)
具有约束力的北草坪会议大楼对一个接口
原标题:Binding NLB to an interface

我已经安装和安装了北草坪会议大楼。我得到的接口数据是这样的:

Get-NlbClusterNodeNetworkInterface



InterfaceName       : quanet
   NlbBound            : False
   Cluster             :
   DhcpEnabled         : False
   InterfaceIP         : 10.165.250.206
   InterfaceSubnetMask : 255.255.0.0
   ClusterPrimaryIP    :
   ClusterSubnetMask   :

   InterfaceName       : cluster
   NlbBound            : False
   Cluster             :
   DhcpEnabled         : False
   InterfaceIP         : 172.16.1.206
   InterfaceSubnetMask : 255.255.255.0
   ClusterPrimaryIP    :
   ClusterSubnetMask   :

我想用Powershell来将Nlbbbound设定为真实。 不用说设置地产无效,例如:

   $x = Get-NlbClusterNodeNetworkInterface
   $x[1].nlbbound = $true
   $x = Get-NlbClusterNodeNetworkInterface
   echo $x[1].NlbBound
   False

I want to avoid having to explicitly set the property in the Network adaptor settings because this functionality will live in a script. I d also like to avoid using WMI if possible.

根据Get-member cmdlet, Nlbound 地产是可以设置的:

Get-Member -InputObject $x[1]

   TypeName: Microsoft.NetworkLoadBalancingClusters.PowerShell.NetworkInterface

Name                MemberType Definition
----                ---------- ----------
Equals              Method     bool Equals(System.Object obj)
GetHashCode         Method     int GetHashCode()
GetType             Method     type GetType()
ToString            Method     string ToString()
Cluster             Property   System.String Cluster {get;set;}
ClusterPrimaryIP    Property   System.String ClusterPrimaryIP {get;set;}
ClusterSubnetMask   Property   System.String ClusterSubnetMask {get;set;}
DhcpEnabled         Property   System.Boolean DhcpEnabled {get;set;}
InterfaceIP         Property   System.String InterfaceIP {get;set;}
InterfaceName       Property   System.String InterfaceName {get;set;}
InterfaceSubnetMask Property   System.String InterfaceSubnetMask {get;set;}
NlbBound            Property   **System.Boolean NlbBound {get;set;}**
最佳回答
Import-Module ServerManager

# Interface cards should be named the same and have a fixed IP
$interfaceName = "NLB"
$clusterName = "NLB-Cluster"
$clusterIpAddress = "1.2.3.0"
$clusterSubnet = "255.0.0.0"

# Install Network Load Balancing and Tools
Write-Host "Install Network Load Balancing and Tools"
Add-WindowsFeature NLB, RSAT-NLB
Import-Module NetworkLoadBalancingClusters

# If the cluster hasn t been created yet then create it
if (!(Get-NlbCluster -HostName $clusterIpAddress -ErrorAction SilentlyContinue))
{
    Write-Host "Creating NLB Cluster: $clusterName" -ForegroundColor yellow 

    # Create Cluster (default unicast)
    New-NlbCluster -InterfaceName $interfaceName -ClusterName $clusterName -ClusterPrimaryIP $clusterIpAddress -SubnetMask $clusterSubnet 

    # Remove defaults
    Write-Host "Removing default port rules" -ForegroundColor yellow 
    Get-NlbClusterPortRule | Remove-NlbClusterPortRule -Force

    # Create port rules
    Get-NlbCluster | Add-NlbClusterPortRule -StartPort 80 -EndPort 80 -Protocol TCP -Affinity None | Out-Null
    Get-NlbCluster | Add-NlbClusterPortRule -StartPort 443 -EndPort 443 -Protocol TCP -Affinity None | Out-Null 
}
else
{
    Get-NlbCluster 
}

# if this node isn t already a member of a cluster then add it
if(!(Get-NlbClusterNode -HostName $env:COMPUTERNAME))
{
    # Add node to cluster
    Write-Host "Adding node to cluster: $clusterName" -ForegroundColor yellow 
    Get-NlbCluster -HostName $clusterIpAddress | Add-NlbClusterNode -NewNodeName $env:COMPUTERNAME -NewNodeInterface $interfaceName
}
else
{
    Get-NlbClusterNode
}
问题回答

暂无回答




相关问题
Mutually exclusive powershell parameters

SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...

Run a program from PowerShell with timeout

I ll write a script that runs a program and wait for it finished. But if the program is not finished within a specified time I want that the program is killed.

How to transpose data in powershell

I have a file that looks like this: a,1 b,2 c,3 a,4 b,5 c,6 (...repeat 1,000s of lines) How can I transpose it into this? a,b,c 1,2,3 4,5,6 Thanks

Powershell v2 remoting and delegation

I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

热门标签