Showing posts with label Windows 2012. Show all posts
Showing posts with label Windows 2012. Show all posts

Thursday, May 14, 2015

Managing Windows Server 2012 R2 Using PowerShell : Part-3 : Getting and Setting Server Name.

 

    1. Part 1 : Windows Server 2012 R2 Installation.
    2. Part 2 : Exploring PowerShell Default Settings.

5-14-2015 12-24-07 PM

Part - 3 { Information - Server Names }

In the pervious blog post, we explored few default settings and configurations of the PowerShell on the newly installed "Windows Server 2012 R2". Today we are going to explore it a little bit more.

Getting Server Name

The first thing after installing server is to either check it's computer name, or, set it's name. You must be thinking that, there should be some PowerShell cmdlet , to check the name of the server.

Arrr! No, you are wrong! There is no cmdlet to check Server name. We have a cmdlet to rename server name, but not to check the current name.

5-14-2015 12-35-03 PM

Now the question arise, "How will check the server name?",  There are two-three ways to check the existing name of the server.

  1. By using  $env:COMPUTERNAME variable in the PowerShell console. this variable stores the name of the machine.
  2. 5-14-2015 12-44-00 PM
  3. The another way to find is to run the Hostname.exe command.
  4. 5-14-2015 12-54-08 PM
  5. The another way to use the WMI, the WMI class name Win32_ComputerSystem , has a Name property which contains the name of the server .
  6. (Get-WmiObject Win32_ComputerSystem).Name
  7. 5-14-2015 12-57-29 PM

Renaming Server Name

After getting the name of the server, what is my next step is ? Guess! Guess!?, my next step is to rename the server name to something logical, and off-course, we are going to set computer name using PowerShell.

We are going to change the name of the server from "WIN-FOUM1FCL4JB" to "Del-2k12"

To rename the computer name , we do use the Rename-Computer cmdlet. To rename the server name, I have used the below command. In parameter -NewName we have provided the new desired name for our server.

Rename-Computer -NewName 'Del2k12'

5-14-2015 1-05-01 PM

In the above screenshot you can see that our command has run successfully and it is asking to restart the computer to change to take effect.

We can restart the server, but, restart it with a  PowerShell cmdlet Restart-Computer .

5-14-2015 1-05-35 PM

Once the computer is restart and I logged in again and when I checked the name of the server, it is set to "DEL-2k12"... Great!

5-14-2015 1-06-54 PM

That's all for today's blog post, we will see and do more in the next blog post.

Take care!

816

 

Regards.
Aman Dhally
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube” channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.

Friday, February 14, 2014

Part – 5 :PowerShell and DHCP : Getting Information on leased IP Addresses

 

 

Part – 1 : PowerShell and DHCP : Installing DHCP Server Role on Server 2012

Part – 2 :PowerShell and DHCP : DHCP Post-Install Configuration

Part – 3 :PowerShell and DHCP :  Configuring the DHCP Scope

Part – 4 :PowerShell and DHCP :   Setting DHCP server’s “Server Options”

 

 

Information and Reporting on DHCP Server.

In my previous post we had configured DHCP server’s “Server Options”.

Now our basic DHCP server is fully functional and providing the IP address to the dhcp clients.

Our next step is gathering information of the DHCP clients and the IP addresses leased by the server.

 

Check DHCP server Statistics

To get the quick statistics of the DHCP server, we can use the                                                         “Get-DhcpServerv4Statistics” cmdlet and it will show us the quick statistics of the server.  

In these statistics you can see the total number of used and free IP address available.

 

clip_image001[4]

 

IP Address leases

To check the leased IP address those are given to the DHCP clients by DHCP server, we can use the “Get-DhcpServerv4Lease” cmdlet.

To use this cmdlet we have to use –ScopeID parameter. In our case ,our scope id is “192.168.1.0”

Get-DhcpServerv4Lease -ScopeId 192.168.1.0  -AllLeases

clip_image003[4]

clip_image005[4]

 

 

Getting list of available free IP Addresses

 

To know about next available free IP Address we can use                                                   “Get-DhcpServerv4FreeIPAddress” cmdlet.

Just run the cmdlet with –scopeID parameter and if you want to know the list 10, or 50 next of available free IP then you can use the – NumAddress parameter.

By running the below command we can see the next 10 available free IP addresses for the scope id of 192.168.1.0

Get-DhcpServerv4FreeIPAddress -ScopeId 192.168.1.0 -NumAddress 10

clip_image006[4]

 

That’s all for now. See you in our next blog post.

Regards

Aman Dhally

clip_image017 clip_image018 clip_image019 clip_image020  clip_image021