Followers

Simple Powershell Script to Send Email on Windows Server 2012

Sending an email from Server 2012 using Powershell is a VERY simple process.
Below is a very simple example of sending an email using a powershell script.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
$message = @"                          
Hello,
I have bad news.  It's not tragic, but you will have to do a small amount of work.
You only have 10% of space left on your hard drive.
You need to do some disk cleanup!!
Thank you,
Your Faithful Web Serving Machine
"@      
$smtpserver="smtp-server-name"
$emailTo = "sample@example.com"
$emailFrom = "administrator@example.com"
$subject="WARNING | WWW | Low Disk Space"
$msg = new-object Net.Mail.MailMessage
$msg.To.Add($emailTo)
$msg.From = $emailFrom
$msg.Subject = $subject
$msg.Body = $message
$smtp=new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($msg)

Deploy Printers via Group Policy on Windows Server 2008 R2

Every office has printers, and they all need to be connected.  If you have an office with a Windows Server domain, you can easily connect your printers using Group Policy.   Your printers and print drivers for your various operating systems must be installed and shared on the server before you begin.
This example is shown using Windows Server 2008 R2. To deploy your printers using Group Policy, you first need to install the Print and Document Services Role.  Open Server Manager, right click Roles, and choose Add Roles.  Select the Print and Document Services role. When installing the role, you need only choose Print server.
Pic1
After you have installed the Role services, go back into Server Manager and browse to Roles\Print and Document Services\Print Management\Print Server\\Printers.  Right-click on the printer you want to deploy, and choose Deploy with Group Policy
Pic2
After you have chosen Deploy with Group Policy, Click Browse to select the Group Policy you want to use, then select it.  After choosing the policy, click the check boxes to assign the printer on a user or computer basis (either per user or per machine).  Then click Add
Pic3
After you click Add, you can see the Printer name, the GPO that you assigned it to, and the Connection Type (per user or per machine).  You can add the printer to as many policies as you want.
 Pic4
Your users should not be administrators of their machines, which means that when your printers attempt to install themselves, it won’t work.  There are some changes that need to be made to the GPO assigning the printers so that non-administrator users can install them.  Open the GPMC (Group Policy Management Console) in Administrative Tools and browse to:
Computer Configuration | Policies | Administrative Templates | Printers
Right-Click Point and Print Restrictions and choose Properties.  Click Enabled.  Clear the checkboxes (if checked) that say “Users can Only point and print to these servers” and “Users can only point and print to machines in their forest”.  In the “When installing drivers for a new connection” box, select “Do not show warning or elevation prompt”.  These settings only apply to Vista and later.  If you are running Windows XP, hang your head in shame, because it’s no longer supported.
Your printers will now be deployed, and installed, on your clients.
Happy printing.
 
Published By
S.G.Godwin Dinesh.MCA
Sr.System Administrator

Windows 2012 : Network Load Balancing (NLB) implementation (GUI)


In this post I will the steps for Network Load Balancing implementation.

- NLB is a technology for LBFA ( Load Balancing / Fail Over)  for IP stateless applications (web applications : HTTP , HTTPS, FTP , ...).
- NLB can detect server failure but not app failure.
- NLB can contain 2 to 32 nodes.

*******************************************************************************
I have 2 identical servers, both joined to Domain. Each server has 2 NICs :

NLBServerA  :
           NIC1 => Management Network , IP : 192.168.0.141
           NIC2 => NLB Cluster ,  IP : 192.168.0.142


NLBServerB  : NIC1 => Management Network , NIC2 => NLB Cluster
           NIC1 => Management Network , IP : 192.168.0.143
           NIC2 => NLB Cluster ,  IP : 192.168.0.144





Now I'm going to install IIS and Network Load Balancing Features on both servers (with default settings) :
Now we can open the "Network Load Balancing Manager" in 2 different ways :
1) In System Manager => Tools Menu => Network Load Balancing 
2) or you can open it by running "nlbmgr.msc" command :
The next step is create a New Cluster and add the Hosts to it : 
Type the Host name and click on Connect to see the list of Interfaces available for configuring a new cluster and select the one for clustering :
In the next Window accept the default settings and click on Next :
* Priority (Unique Host Identifier) : This parameter specifies a unique ID for each host. The host with the lowest numerical priority among the current members pf cluster handles all of the cluster's network traffic that is not covered by a port rule. You can override these priorities or provide load balancing for specific ranges of ports by specifying rules on the Port Rules tab of the Network Load Balancing Properties dialog box.
In the next window click on "Add" to enter the Cluster IP address : 
In "Cluster Parameters" window, accept the default settings and leave the Cluster Operation mode as "Unicast" :
* In Unicast mode , the MAC address of the cluster is assigned to the network adapter of the computer,and the built-in MAC address of the network adapter is not used.
** Microsoft recommends to accept the unicast default settings.
In the Port Rules window, you can accept the defaults or Remove the default one and create new Rules for Port 80 , Port 443 or any other port you need :
Click on Finish and after few seconds the first node in Cluster will be ready :
To add the second Host to Cluster, Right click on Cluster and select "Add Host To Cluster" :
Next steps will be exactly the same as before :
Now it's time to create a test page under a new site in IIS :
Create a new folder on C drive (New_Site) and a new text file with some text in it , save it and change the extension of file to "html" :
In IIS , Add a new Website :
Also you need to set the Default Document in IIS and point it to "TestPage.html"
And do the same thing on the second server and create the new site.
The next step is creating a "www" record in DNS and point it to cluster IP address (192.168.0.145 in this example) :
OK, everything is ready and in place now. Just need to do a quick test and show you how NLB Cluster works .
On another machine open the Browser and go to "http://www.NLBCluster.com" :
As you can see it will shot the page on NLBServerB . 
Let's Stop the "NLBServerB" Host  in Network Load Balancing Manager first :
If you refresh the page on the third machine :
It's pointing to the other server up & running in NLB Manager (NLBServerA) and it means NLB Cluster is working find and everything is done successfully :)
*********************************************************************************
To Configure NLB Manager Log Settings :
1) From the Option menu select "Log Settings"
2) check Enable Logging and specify a name and location for the log file :
*********************************************************************************
To Remove a Host from NLB Cluster :
1) Select the Host , right click and first select "Drainstop" , then "Stop"
2) Right click the host and select "Delete Host"

********************************************************************************
If you like to do all these steps with the PowerShell cmdlets, you can go to this link and see the full list of commands and examples :
Source:
http://technet.microsoft.com/en-us/library/ee817138.aspx

You can write a script to automate all these steps and use over and over in your environment if you need.
 
Published By
S.G.Godwin Dinesh.MCA
Sr.System Administrator

Introduction to Python Programming in Ubuntu Linux


Introduction to Python Programming in Ubuntu Linux
 
Python is one of a handful of modern programming languages gaining a lot of traction in the development community. It was created by Guido von Rossum in 1990, named after – you guessed it – the comedy, “Monty Python’s Flying Circus”. Like Java, once written, programs can be run on any operating system.
Python ProgrammingI began programming many years ago, and admittedly once I got into networking, turned away from my first love. But for those of you who would like to begin trying your hand at a new language, Python is excellent to start with. Supporters tout its low learning curve and elegant coding system.

Python Installation

Ubuntu makes starting easy, as it comes with a command line version pre-installed. In fact, the Ubuntu community develops many of its scripts and tools under Python. You can begin the process with either the command line version or the graphical Interactive Development Environment (IDLE).

Python Programming From the Command Line

Open a terminal window and type ‘python’ (without the quotes). This opens python in interactive mode.
Python Programming
While this mode is good for initial learning, you may prefer to use a text editor (like Gedit, Vim or Emacs) to write your code. As long as you save it with the .py extension, it can be executed in the terminal window.
Ready to write your first program? Many a road to programming excellence began with the old standby – the Hello World program. So that’s where we’ll begin.
At the prompt, type in print “Hello World!” (with the quotes) and hit enter. You’ll see the command printed on the next line.
Python Programming
To run a script from the command line, type: python my_script.py. To exit the command line, type exit() or hit ctrl+d

Python Programming with IDLE

Can’t imagine writing a long program from the command line? Me either. In that case, you can try IDLE. Open a terminal window and type: ‘idle’. (without the quotes). You’ll see the python graphical shell loaded.
Python Programming
To write a Python script, click on File > New Window. This will open a sort of Notepad type editor. Type in the following code:
#linuxversion.py
#Have user input version and print response
name = raw_input(“What Linux release do you use?”)
print “I also like”, name, ” – Linux rules!”
Couple things going on here. The first 2 lines, preceded by the # sign are just comments. One of my earliest programming lessons was to always comment your work, not only for your own sanity, but for those who may need to edit the code after you. The third statement uses the input gathered from the raw_input function and assigns it to a variable, name. Finally, the print statement will return the result.
Save the file, with a .py extension, then click on Run > Run Module from the menu to run the program.
Python Programming

A Word of Caution

Many programming languages typically ignore whitespace – that is the spacing in your code. But in Python, improper use of spacing can generate syntax errors. As an organization nut of sorts, I can appreciate the simplicity and readability of properly aligned code, but for some this takes a bit of getting used to.

Python Programming Resources

Now that you have Python up and running, you’ll undoubtedly want to move to on to a bit more complex programs. One of the best resources is the main Python website. Here are a few additional recommendations:

Conclusion

I hope you enjoyed this brief glimpse into Python. This is a language supported by a wide community and used by Google, NASA, Ubuntu and others. Give it a try for your next development project. Happy coding!
Ready to test your skills in Python? See how they stack up with this assessment from Smarterer, the newest addition to the Pluralsight family. Start this Python test now.
 
Published By
S.G.Godwin Dinesh.MCA
Sr.System Administrator