I need to create a Powershell script to create a MSMQ resource on a failover cluster. One of the things I need is to set the IP address using DHCP. Using the UI interface is simple, select the network, click DHCP enabled, click apply. You would think you can do the same thing in Powershell, but it has to work like this:
$clusterGroup = Add-ClusterGroup -InputObject $cluster -Name "MsmqCluster"
# create cluster IP address
$IPClusterResource = add-ClusterResource -InputObject $ClusterGroup -Name "${clusterGroup}-IP" -ResourceType "IP Address"
# find the network name
$ClusterParam = get-ClusterResource "Cluster IP Address"|get-ClusterParameter Network
$NetworkName = new-object Microsoft.FailoverClusters.Powershell.ClusterParameter $IPClusterResource,Network,$ClusterParam.Value
# have to fake an ipaddress and subnet mask
$address = new-object Microsoft.FailoverClusters.Powershell.ClusterParameter $IPClusterResource,address,"10.16.12.101"
$subnetmask = new-object Microsoft.FailoverClusters.Powershell.ClusterParameter $IPClusterResource,subnetmask,"255.255.255.0"
# have to bundle the parameters together and set the parameters in one shot
$setParams = $NetworkName,$address,$subnetmask
$setParams|set-clusterParameter
# now you have to enable NetBIOS before you can Enable Dhcp
set-ClusterParameter -inputObject $IPClusterResource -Name EnableNetBIOS -Value 1
set-ClusterParameter -inputObject $IPClusterResource -Name EnableDhcp -Value 1
No comments:
Post a Comment