Archive for the ‘PowerShell’ Category

Windows 2012 Clustering : Network Load Balancing (NLB) ,How To , Step by Step

Now that Windows 2012 is here and you want to test if the OS is as good as you want and see if the application is still running on windows 2012.

In this case We build a NLB website easy with just the basic steps any one can do this.

First we add the roles and features to the servers that we are going to use for the NLB.

Select the Features “ Network Load Balancing ” only this you need for NLB

 

 

clip_image002

After this I look at my NIC’s most important that you use two nic’s in a VM this is easy in a physical box now days there are at least 2 nic’s in the server. use them.

I gave the Nic’s an IP that is not in the same subnet as the production lan, and also you can use a different VLAN for the NLB traphic but if you want to use it on your lan than you need routing !

NLB node 01

clip_image004 clip_image006 For Quick see what my nic is doing I give them names

clip_image008  clip_image010

Now that I added the features I can open the MMC and right click to create a new cluster

image now that we create a new cluster We type in the IP adress of the first NLB node name

clip_image014 There are two IP addresses , one public IP and One NLB IP

Remember this is not the Cluster NLB IP but the node IP , Select the IP and choose Next

 

clip_image016  clip_image018

Now we can create the cluster IP choose ADD and fill in the IP address that will be used for the CLUSTER NLB

clip_image020 clip_image022

You can use multiple IP’s the work in the NLB , that way you can run multi sites on one NLB management but all on different IP’s / FQDN names / DNS. and on different ports. or settings

clip_image024 Now I choose a FQDN for the NLB cluster name

clip_image026 clip_image028 clip_image030

I don’t want to balance all the ports , just the ports that I need in this case port 80.

clip_image032 clip_image034 Now that the cluster is ready  ( one node ) we can do the properties of the cluster

image clip_image038

I add a second IP to the cluster

clip_image040 clip_image042

clip_image044 clip_image046

as you can see I use a different port for this IP

clip_image048 clip_image050

clip_image052 Now that I have two IP’s and on different ports I’m ready to go.

image Now a second nlb node

clip_image056clip_image058clip_image060

 

Now that the clusternode is joined you can see here the cluster nlb IP’s

clip_image062 clip_image064

clip_image066 

Both nodes are now joined to the nlb cluster and we can build a nlb website

image clip_image068

 

image as you can see the site runs only on port 80.

 

Now your NLB cluster is ready for productions

Posted June 20, 2012 by Robert Smit in PowerShell, Windows 2012 NLB

Create IIS NLB Copy Full Website Resource Windows 2008R2 With Powershell

If you are Building a Webfarm you need often Test websites and all the Sites needs to be the same Winking smile

Well below is a powershell Scripts that copy the Site and Creates a new one On the Same Server.

 

# NAME: Copy-Website.ps1
#
# AUTHOR: Robert Smit
# EMAIL: robert.smit@aca-computers.nl
#
# COMMENT: Script to create a Copy-Website.
#   
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the creator, owner above has no warranty, obligations,
# or liability for such use.
#
# VERSION HISTORY:
# 1.0 4.06.2011 – Initial release
#
###########################################################################
ImportSystemModules
#Importing Microsofts PowerShell-modules

#Set ExecutionPolicy
#Set-ExecutionPolicy -scope LocalMachine RemoteSigned –force

#Importing Microsofts PowerShell-module for administering IIS
Import-Module WebAdministration

#List website
Write-Host "List IIS Website…" -ForegroundColor yellow
get-Item IIS:\Sites\*

#Variables for creating the new Website
#
#
$sourceweb = Read-Host "Enter the Website to Copy"
$destinationweb = Read-Host "Enter the New Websitename"
$ChangedDemoSiteBinding = Read-Host "Enter the Hostheader of the website"
$LogDir = Read-Host "Enter the website path of the new website"

#Copy website
Write-Host "copy IIS Website…" -ForegroundColor yellow
copy-Item IIS:\Sites\$sourceweb -destination IIS:\Sites\$destinationweb

#Create Application pool
Write-Host "Create Application pool…" -ForegroundColor yellow
New-WebAppPool $destinationweb

#Link Application pool
Write-Host "Link Application pool…" -ForegroundColor yellow
get-ItemProperty IIS:\Sites\$destinationweb
Set-ItemProperty IIS:\Sites\$destinationweb -name applicationPool -value "$destinationweb"

#Set nieuwe Host name
Write-Host "Set nieuwe Host name…" -ForegroundColor yellow
get-Item IIS:\Sites\$destinationweb
Set-ItemProperty IIS:\Sites\$destinationweb -Name bindings -Value @{protocol="http";bindingInformation="192.168.123.1:80:$ChangedDemoSiteBinding"} #change the IP here

#Set new Path
Write-Host "Set new Path…" -ForegroundColor yellow
get-Item IIS:\Sites\$destinationweb
Set-ItemProperty IIS:\Sites\$destinationweb -Name physicalPath -Value "$LogDir"

#Scopy site
#Write-Host "Scopy site …" -ForegroundColor yellow
#Copy-Item "C:\Put your folder here\*" $LogDir # change The Filepath here

#Set user account
Write-Host "Set user account…" -ForegroundColor yellow
Set-ItemProperty IIS:\Sites\$destinationweb -Name Username -Value "Username"
Set-ItemProperty IIS:\Sites\$destinationweb -Name Password -Value "Password"

Create Services Cluster Resource Windows 2008R2 With Powershell

In a Cluster You can cluster Services this can be done by the wizzard Or with Powershell.

Below a easy powershell script to create a clustered services.

In my case I used the altiris Services You can adjust this whit any services You like.

Add-ClusterGroup -Name AltirisGroup
Add-ClusterResource -Name Altiris -Resourcetype "Generic Service" -group AltirisGroup
Get-ClusterResource -Name Altiris |Set-ClusterParameter -Name ServiceName -value "Altiris Deployment Agent"
Get-ClusterResource -Name "Altiris" |Set-ClusterParameter -Name StartupParameters -value "C:\Program Files\Altiris\Dagent\dagent.exe"

  • Tag