≡ Menu

In this post I will show you how to disable Server Manager Start up during user logon on Windows Server 2008 R2 and Server 2012

Server Manager start-up during Windows User logon on Windows Server 2008 R2 server Operating system is the most frustrating thing for System administrators who manage the boxes. We know that it exists and how to launch so we would like to get it disabled from user logon start-up.

First we will see how we can solve this problem in different ways and then we will come to the topic where each one should be used.

There are two methods using which we can disable Server Manager launching from Start at the time of user login.

Registry Method:

There are two registry keys to be modified to address this problem.

Set the value of below key to 1

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\DoNotOpenServerManagerAtLogon

And set the value of below key to 0

HKEY_CURRENT_USER\Software\Microsoft\ServerManager\CheckedUnattendLaunchSetting

The HKLM key prevents the Server Manager start-up for any new logins to the server. For existing logins, the second HKCU key helps. That means, if you already have some user profiles created on the server then you should consider deploying the above HKCU to the respective user hives. While deploying the HKLM key can be done via Powershell script (discussed at this 4sysops article), deploying HKCU should be done via Group Policy preferences or logon scripts.

Group Policies Method:

Server Manager Start-up can be done via Group Policies as well.

The policy “Do not display server manager automatically at logon” is under “Computer Configuration\Administrative Templates\System\Server Manager” container in group policy editor. You can either create a new policy or use existing policy to add this new setting based on the scope and other requirements. Once the policy is configured deploy it to required servers. Unlike Registry method, this group policy method works for both new users logging into the server as well as existing users.

What is preferred approach?

In my opinion, the Group Policy approach is much appropriate and suitable deploying to multiple computers. It is easy to deploy or revert since the Group policy modification is matter of seconds. The registry method also works but you need to come up with custom scripts to deploy HKLM keys and other alternatives to deploy HKCU keys which is not an easy task.

Hope this helps and happy learning.

{ 4 comments }

Start a Hyper-V virtual Machine using Powershell

In this post, I will show you how to start one or more virtual machines residing on Microsoft Hyper-V using Powershell commands.

Microsoft Hyper-V module for Powershell has 164 cmdlets on Windows Server 2012 to install, configure and manage Hyper-V environment, VMs, v-switches and other components of MS virtualization.

In this article I primarily focusing on how to start one or more virtual machines using Powershell. The Hyper-V module has a cmdlet called Start-VM(similar to Start-VM in VMwareCli) to start Virtual Machines on MS Hyper-V server. This cmdlet has two important arguments named -ComputerName and -Name. The ComputerName parameter refers to Name of the Hyper-V server where the Virtual machines are hosted and Name parameter refers to actual name of the Virtual Machine that you want to start. Here please note that you should pass display name of the virtual machine that you see in Hyper-V Manager UI, not the actual Operating System name of the virtual Machine.

First of all we need to import the Virtual Machine. We can do this by executing below command from a Powershell window.

Import-Module Hyper-V

Once imported, use Start-VM cmdlet to start the Virtual Machine.

Start-VM –Name Infra1

In the above example, I haven’t provided any Hyper-V server name because by default the cmdlet tries it on local server. In my case, I am executing these commands from a shell on Hyper-V server where my VM is located.

To start a VM hosted on remote Hyper-V server, you can specify the name of remote Hyper-V server to the ComputerName parameter. See below example.

Start-VM –ComputerName MyHyperv2 –Name Infra1

Similarly you can start multiple Virtual machines by specifying their names to Name parameter as shown below.

Start-VM –ComputerName MyHyperv2 –Name Infra1,Infra2

Hope this helps and happy learning.

{ 2 comments }

Enable Wireless connection in Windows Server 2012

In this post, I will show you how to enable Wireless connection in laptop after installing Windows Server 2012.

After a failure attempt to install Vmware server on my laptop, I decided to switch to Hyper-V as my hypervisor to host VMs. I downloaded VHD file of Windows sever 2012 and booted my laptop from that(I will cover this boot from VHD in a upcoming posts) downloaded VHD. Everything was fine, except my server OS is not coming into network. The wireless connection was not working and in disabled state like shown in below picture.

Since Network connection is very much required for my lab setup, I decided to explore it more. One option is, I can use a Wired connection to get internet and network but that will defeat the purpose of laptop. So I checked why wireless connection is not working. While exploring the features list via “Add roles and features wizard” in server manager I stumbled on the feature called “Wireless LAN service”. I quickly enabled the feature using the below powershell commands.

Import-Module ServerManager            
Add-WindowsFeature -Name Wireless-Networking

and the output is something like below and I restarted my laptop to finish the installation.

After rebooting the laptop I verified the status of my wireless connection again, and to disappoint me, it is in the same disabled state. Then after some googling, I went into device manager on my windows server 2012, and tried upgrading the wireless card drivers and it worked like a champ.

Now I have wireless enabled and working on my laptop with Windows server 2012 OS.

Hope this helps and happy learning.

{ 1 comment }

SMB (Server Message Block) — my today’s learning

Ever since I started managing Windows boxes, I am familiar with this word, SMB (Server Message Block). What it does? — it helps in accessing files on remote file System or on another windows server. What ports it uses 139 TCP, 138 UDP, 137(TCP/UDP) and 445 sometimes. So my answer to questions like what ports you need to access file shares on a server behind firewall is all aforementioned ports.

Well, that’s old story now. Today I got a chance to look much deeper into SMB protocol while helping one of my friend(and senior) to debug a problem. Let me ramble what I learned.

When Microsoft originally designed SMB, it was a wrapper on top of NetBIOS API. It used to use NetBIOS functions to access files on remote file systems over TCP. In those days, SMB used to use ports 137(tcp),138(udp) and 137(tcp&udp) for communication with other Systems. As the things improved and NetBIOS has became a legacy system. MS also want to get rid of it(not that easy at this moment I think). Since improvements to SMB are blocked by abilities of NetBIOS, they started making SMB independent of it called Direct-SMB. This Direct-SMB uses the port 445(TCP) for file sharing.

That is the story behind and now coming to the context of Windows Administrators, you need to understand which version of SMB your computer(s) are using. If the client computer has NetBIOS disabled, it tries to connect to the file server on port 445 for file access provided the file server is Windows server 2000 or above. If the client computer has NetBIOS(and WINS) enabled, the client computer uses NetBIOS and tries to contact file serve on 137(tcp),138(udp) and 137(tcp&udp) ports. Though Microsoft moved to Direct-SMB still they are supporting SMB over NetBIOS because many legacy systems are still using old APIs for data transfer. If a client tries to communicate using NetBIOS API, the server replies with same protocol.

How do you know if a computer has NetBIOS over TCP/IP enabled:

Just run the one of the below commands.

  • net config redirector
  • net config server

Verify NetBIOS over TCP/IP Status

If output contains NetBT_Tcpip, that means you have NetBIOS over TCP/IP enabled. You will see NetbiosSmb. Below is screenshot from my Windows 8 computer.

Disable NetBIOS over TCP/IP

If you want, you can disable NetBIOS over TCP/IP by following below steps.

  1. Click Start, point to Settings, and then click Network and Dial-up Connection.
  2. Right-click Local Area Connection, and then click Properties.
  3. Click Internet Protocol (TCP/IP), and then click Properties.
  4. Click Advanced.
  5. Click the WINS tab, and then click Disable NetBIOS over TCP/IP.

Conclusion:

So when anyone asks what ports required for access files share on a behind firewall server, my next question would be “Is NetBIOS over TCP/IP enabled or disabled?”.

Thanks for reading. Hope you learned some time too. Happy learning.

 

{ 0 comments }

PowerShell: Query VMware VM hard disk data store name

In this post I will show you how to query the datastore name given Virtual Machine name in VMware.

Let us see what is involved in querying the data store name of a VM hard disk. At first glance you might think that below command will give you the information you need and there is no complexity. But the actual fact is that, below command returns the datastore name where the VM is stored(that is VMX file) but not the location of hard disks.

Get-DataStore -VM (Get-VM -Name MyVM1)

So, what is the approach should be? Per my research, there is no straight forward way to get this information, but what we can do is derive this from one of the existing properties. Let us see how to do that.

The Get-HardDisk cmdlet returns array of harddisk objects and each object will have a property called filename. This file name property contains path to HDD file in the datastore. Extracting the datastore name from the FileName property is the only way to get datastore name of the hard disks.

$VM = Get-VM -Name MyVM1            
$Disks = Get-HardDisks -VM $VM            
foreach($disk in $Disks) {            
$FileName = $Disk.FileName             
$Diskname = $Disk.Name            
$datastore = $FileName.split("]")[0].split("[")[1]            
"{0} : {1}" -f $Diskname,$datastore            
}

Hope this helps… Happy learning…

{ 3 comments }

Never ignore built-in/native commands in Windows

This post is based on my today’s learning.

Before I started using Powershell, shutdown.exe was the only command that I used to shutdown multiple remote computers. But I felt really inconvenient with it because, I had to use some batch scripting to shutdown multiple  remote computers. Even till Powershell V2 I relied on this utility to shutdown multiple computers by wrapping some code around it.

Well, there is no problem with the usage, but for the first time I have seen a very useful option in this tool. That is GUI. I never knew that shutdown.exe has UI. I never knew it because, I never cared to read what this tool offers me by looking at command help. You might wonder what is so special about this UI.

So, dear system admins, The point I want to make is read the help message of a native tools carefully, they might ease your task. No need to always develop complex scripts/automation for simple tasks.

Look at the below screenshot.

Using this UI,

  • You can shutdown multiple computers by pasting the list after selecting add button.
  • You can shutdown all computers in a OU using a single click.
  • You can shutdown, restart, and mimic a unexpected shutdown as well.
  • You can set the timeout you want
  • You can provide the reason for shutdown and comment as well. This goes to multiple computers

 

Hope this helps.. Happy learning…

{ 2 comments }

Get VMware VM Disk size using powershell

In this post, I will talk about querying the disk size details of a VMs in VMware ESX environment.

First of all you need to connect to Virtual Center where your VMs are hosted. As you already know, use the below command from PowerCLI console.

Connect-VIServer -Server VCServer1

Once connected to VC, we need to get the VirtualMachine Object of VM that we want to query for disk size details.

$VMObj = Get-VM -Name $VMName

Above command will get the Object of Virtual Machine. In previous version of PowerCLI, the disk details are generally part of VM object returned by Get-VM cmdlet. The latest versions are a bit different, and you need to use Get-HardDisk cmdlet.

$Disks = Get-Harddisk -VM $VMObj

The Get-HardDisk cmdlet returns array of disks that are connected to the VM. To get the details of each disk, you need to loop through the returned array and get the required properties.

So, here is the complete combined code:

function Get-VMDisks {            
[cmdletbiding()]            
param(            
[string]$VMName            
)            
$VMObj = Get-VM -Name $VMName            
$Disks = Get-Harddisk -VM $VMObj            
foreach($disk in $Disks) {            

$DiskName = $Disk.Name            

$DisksizeinGB = ($Disk.CapacityKB * 1024)/1GB            

"{0} : {1}" -f $DiskName, $DisksizeinGB            

}            
}

Hope this helps…

{ 1 comment }

I got my first personal laptop last weekend. Since I want to run couple of VMs, went for a bit high configuration. While setting up VMware Server on this laptop, I experienced a problem where drivers signing is failing on Windows 8. A quick search in Google suggested that I should disable driver signature enforcement on my Windows 8 computer with the help of below commands.

bcdedit -set loadoptions DDISABLE_INTEGRITY_CHECKS
bcdedit -set TESTSIGNING ON

I went ahead with above commands but the second one is failing with below error message

An error has occurred setting the element data. The value is protected by Secure Boot policy and cannot be modified or deleted

I made sure that I am running this in elevated command prompt but it didn’t help. After some struggle I came to know that there a feature in BIOS(called as secure boot) that restricts modification to some of the boot loader features. So, I went into the BIOS and searched for some thing that represents “Secure Boot” and disabled it. After that I am able to run command without any issues.

Hope this helps..

PS: You might want to ask whether it allowed me to install VMware Server on my Windows 8 laptop. Answer is NO. I am still facing the driver signature verification issue and the installation keep failing. Vmware services are not starting after the installation. I am still troubleshooting this on my PC; will make a separate post about it.

{ 2 comments }

In past I talked about same topic in DCLocator(Part-I) & DCLocator(Part-II) posts. That time I came to that conclusion based on what I read in some blogs and my own experimeniting.  The posts are not having any pictures or anything that can make my readers understand this concept clearly. It is completely a text rambling which people might feel boared to read it unless they have a urgent need.

I recently came across a video that explains the same DC locator process in a much pictorial way. I felt this is very useful for people to understand DClocator process to some level.

Hence making this post to share with you.

Hope this helps.

{ 0 comments }

When connecting to VI server using Connect-VIServer cmdlet in VMware vSphere PowerCLI, you might notice a warning message about certificates. The warning message looks something like below.

WARNING: There were one or more problems with the server certificate:

A certificate chain processed correctly, but terminated in a root certificate which isn’t  trusted by the trust provider.

The certificate’s CN name  does not match the passed value.

Basically this warns about certificates that are installed on the VI server. This is expected behavior if you are using default(self signed) certificates. While this is a just warning message and doesn’t cause any issues to the powershell cmdlets functionality, it is not something you want to see when you run scripts. This really distracts the attention and the useful information might get burried under this lenghty warning message.

So in this post, I will show you how to suppress this message while connecting to VI server.

There are several ways available to do this.

1) Using -Force parameter

If you use -Force parameter with your Connect-VIserver cmdlet, these messages will be suppressed.

Connect-VIServer -Server VC1 -Force

2) Using -WarningAction parameter

You can suppress the warning message by setting -WarningAction parameter to SilentlyContinue(0) while calling Connect-VIServer cmdlet

Connect-VIServer -Server VC1 -WarningAction 0

3) Fixing the root cause

You are presented with a warning message because there is a problem that you should address. You need to import proper certificates into your VI server to get rid this warning message once for ever.

Please see http://www.vmware.com/pdf/vi_vcserver_certificates.pdf for the procedure to replace virtual center certificates.

Hope this helps…

{ 0 comments }