Archive for the ‘PowerShell’ Category
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
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
For Quick see what my nic is doing I give them names
Now that I added the features I can open the MMC and right click to create a new cluster
now that we create a new cluster We type in the IP adress of the first NLB node name
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
Now we can create the cluster IP choose ADD and fill in the IP address that will be used for the CLUSTER NLB
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
Now I choose a FQDN for the NLB cluster name
I don’t want to balance all the ports , just the ports that I need in this case port 80.
Now that the cluster is ready ( one node ) we can do the properties of the cluster
I add a second IP to the cluster
as you can see I use a different port for this IP
Now that I have two IP’s and on different ports I’m ready to go.
Now a second nlb node
Now that the clusternode is joined you can see here the cluster nlb IP’s
Both nodes are now joined to the nlb cluster and we can build a nlb website
as you can see the site runs only on port 80.
Now your NLB cluster is ready for productions
If you are Building a Webfarm you need often Test websites and all the Sites needs to be the same
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"
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"