Wednesday, June 27, 2012

Powershell oneliner to find large files on all local drives

There are many different tasks that can be achieved with Windows Powershell on one line only (aka oneliner). One of this tasks is to retrieve all the largest files on all your local disks. Let's build together this script one step at the time.

First of all we have to get a list of the local hard drives. There are two ways to get a list of the drives on your local computer:

- Get-PSDrive cmdlet
- Get-WmiObject -class Win32_LogicalDisk

With Get-PSDrive all of you local and network locations are listed plus the registry, the certificate store and some other containers:
Get-PSDrive

Name    Used (GB)  Free (GB) Provider      Root
----    ---------  --------- --------      ----
A                            FileSystem    A:\
Alias                        Alias
C           53,29      26,61 FileSystem    C:\
cert                         Certificate   \
D                            FileSystem    D:\
E             ,13      79,87 FileSystem    E:\
Env                          Environment
Function                     Function
HKCU                         Registry      HKEY_...
HKLM                         Registry      HKEY_...
Variable                     Variable
WSMan                        WSMan
X           14,29      25,61 FileSystem    X:\
Unfortunately the Provider (System.Management.Automation.ProviderInfo Provider) property doesn't make the difference between 'C' which is a local hard drive, and 'X', which is a network mapping. Both are reported as FileSystems.

Monday, June 25, 2012

Hybrid SSD with ReRAM

It looks like that a group of Japanese researchers have found a way to push SSD disks performance even farther. They have implemented an algorithm called MRU (most recently used) which moves frequently used data from the NAND cells of the SSD drive to the 8GB of a memristor based RAM added to the drive itself.

The main advantages of this technology is the fact that it allows faster performance and an extended MTBF, the latter being the main weakness of SSD.

For more information on this technology news, have a look at these sites:
NAND vs ReRAM
For an overview of SSD technology, check my detailed post here:

Friday, June 22, 2012

How to change WInRM 3.0 listener port

Today I encountered an issue with WinRM 3.0 when opening a 1-to-1 shell session against a remote host on a different VLAN. It didn't take me long to find out the the remote port was blocked by a network Firewall, so, instead of asking for an exception in the filtering rules, I preferred to reconfigure WinRM to listen on another allowed port.

The command to retrieve the complete configuration of the Remorting service is: 'winrm enumerate winrm/config/listener'.

The output is the following:

Listener
    Address = *
    Transport = HTTP
    Port = 5985
    Hostname
    Enabled = true
    URLPrefix = wsman
    CertificateThumbprint
    ListeningOn = 192.168.155.239, 127.0.0.1


As you can see, port 5985 is the one used by default when launching 'Enter-PSSession -computername remotehost' on PowerShell 3.0 (for your information, port 5986 is the one used when you specify the -UseSSL switch: 'Enter-PSSession -UseSSL -computername remotehost', but you must first create a listener on that port because it isn't done automatically).

To change this port configuration, run these commands:

Winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="1025"}

Listener
    Address = *
    Transport = HTTP
    Port = 1025
    Hostname
    Enabled = true
    URLPrefix = wsman
    CertificateThumbprint    ListeningOn = 192.168.155.239, 127.0.0.1

I hope this post helps you if you have found the same issue using WinRM in a firewalled environment. Do not hesitate to comment and tell your experience with PowerShell 3.0/WinRM 3.0.

Wednesday, June 20, 2012

How to install PowerShell 2.0 on Windows 2003 R2 SP2 32 bit

This is a post to explain how you can install PowerShell 2.0 on Windows 2003 R2 SP2 32bit (which, by default, has no PowerShell at all). As you might have noticed, yesterday I published a blog post explaining the steps to install PowerShell 3.0 on Windows 2008 R2 box. Unfortunately you cannot install the last version of this package on operating systems older than Windows 2008 because the code is different and you won't be able to launch the MSU installer (Windows6.1-KB2506143-x86.msu) because Windows 2003 simply can't read it. So, due to the lack of anything better, let's focus on PowerShell 2.0.

Here's what I did.

Downloaded and installed DotNet 4 (dotNetFx40_Full_x86_x64.exe, approximately 50 MB). Easy install, no reboot.

Now download and install the Windows Management Framework 2.0 (WindowsServer2003-KB968930-x86-ENG.exe, approximately 6 MB) from here. This package contains WinRM 2.0 and Windows PowerShell 2.0.

Go through the installation and there you are: just click 'Start', 'Run' and type 'PowerShell' then press 'Enter'. Check the value of the '$host' variable by simply entering it and pressing 'Enter' and you should get the expected output telling you that PowerShell 2.0 is up and running:
$host
Name             : ConsoleHost
Version          : 2.0
InstanceId       : ddb04dd1-7a4b-4a66-8f71-8b925c7210b4
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace
The next step is to enable Remoting, with the help of the 'Enable-PSRemoting' cmdlet. Execute this cmdlet and press 'A' to confirm.

With 'netstat' we can now check that WinRM is effectively listening to remote requests:
netstat -abn |  find "5985"
  TCP    0.0.0.0:5985           0.0.0.0:0              LISTENING       4
For your information, TCP port 5985 is the port PowerShell 2.0 uses for incoming unencrypted connections. Older versions of WinRM use TCP port 80 (or 443 for encrypted connections) by default.

The last step is to bind PowerShell 2.0 to DotNet 4.

By default PowerShell relies on DotNet 2, which you can verify with this command: '[environment]::Version'
The output is:
Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      50727  4959
To change this, move to C:\WINDOWS\system32\WindowsPowerShell\v1.0 and create a new text document named 'powershell.exe.config', and set its content to:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <!-- http://msdn.microsoft.com/en-us/library/w4atty68.aspx -->
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
    <supportedRuntime version="v2.0.50727" />
  </startup>
</configuration>
Run again '[environment]::Version' and this time you will that PowerShell is using DotNet 4:
Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      30319  1
So, here's my conclusions:
  • easy installation
  • no need to restart
  • unfortunately no PowerShell 3.0 support on Windows 2003
  • DotNet 4 runs fine on Windows 2003
For mire details about the topics covered here you can check:
Hope this posts will help you. Do not hesitate to share you experience with PowerShell on older systems.

Tuesday, June 19, 2012

Upgrading to Powershell 3.0 on Windows 2008 R2 SP1


Having been tasked with the upgrade of Windows PowerShell from version 2.0 to version 3.0 on a bunch of Windows 2008 R2 servers, I thought I could share my experience with this kind of activity and help you not to get muddled up. I will try to be as clear as possible and detail the steps to follow as well as identify the milestones of the upgrade.

First of all know that Windows PowerShell 3.0 is part of a greater package known as Windows Management Framework (WMF 3.0). WMF contains Windows PowerShell 3.0 (of course...), WMI and WinRM. The Beta version also includes a Server Manager CIM provider. This CIM provider allows users of Server Manager in Windows Server 2012 to collect and view management data from servers with Windows Management Framework 3.0 installed.

The Beta version of WMF 3.0 is shipped in four different packages. The package we are interested to is Windows6.1-KB2506143-x64.msu, which is targeted for Windows 2008 R2 SP1. You can download it from this link.

Before we start the upgrade, check that four prerequisites are met:
  • you have SP1 ( if not, download the pretty huge (903MB) file here)
  • you are running the x64 edition (Windows 2008 R2 exists only in 64 bit...)
  • you have installed the full version of .NET 4.0 (available here for Full Windows installation and here if you have the the Server Core version of Windows 2008 R2 SP1)
  • if you are using a non-English version of Windows, you must first install the English Language Pack.

Monday, June 18, 2012

How to determine your Powershell version

Waiting for the final release of Powershell 3.0 with Windows Server 2012, I wanted to share here a quick hint on how to get to know whether the Powershell version running on your systems is 1.0, 2.0 or 3.0.

First of all, System.Management.Automation is the root namespace for Powershell, and System.Management.Automation.Internal is the namespace that contains the base classes that define members of classes found in other Windows Powershell namespaces.
Inside the namespace there is an object System.Management.Automation.Internal.Host.InternalHostUserInterface.

This object can be retrieved directly through the built-in $host variable (which is dynamic) or there also is a get-host cmdlet that will get this object for you on demand.

Introducing Windows Server 2012

After Windows NT4, Windows 2000, Windows 2003, Windows 2008 and Windows 2008 R2, Microsoft is about to release its last version of the operating system for servers: Microsoft Windows Server 2012.

To promote this event, on June 4th 2012 Microsoft announced the release of a brand new free e-book titled "Introducing Windows Server 2012" (ISBN: 978-0-7356-6679-5) by Mitch Tulloch (MVP).

The e-book has five chapters and 242 pages. The five chapters are:
  • Chapter 1 The business need for Windows Server 2012
  • Chapter 2 Foundation for building your private cloud
  • Chapter 3 Highly available, easy-to-manage multi-server platform
  • Chapter 4 Deploy web applications on premises and in the cloud
  • Chapter 5 Enabling the modern workstyle
As the author states, "Windows Server 2012 is probably the most significant release of the Windows Server platform ever. With an innovative new user interface, powerful new management tools, enhanced Windows PowerShell support, and hundreds of new features in the areas of networking, storage, and virtualization, Windows Server 2012 can help IT deliver more while reducing costs. Windows Server 2012 also was designed for the cloud from the ground up and provides a foundation for building both public and private cloud solutions to enable businesses to take advantage of the many benefits of cloud computing."

As you can see there is a strong focus on the Cloud, because Microsoft guys are trying to give a clear signal to the IT community that they have somewhat left the old server-centric model and oriented toward a new cloud-centric model.

The e-book is not really a technical one, but it does a good job of reviewing all the new features of Windows Server 2012, such as SMB 3 (on page 63), Network Virtualization (page 32), Virtual Fibre Channel (on page 62), Live Storage migration (page 113), Powershell 3.0 (page 147), Resource Metering (on page 48) or Hyper-V Replica (page 69).

Of course some of these features will make you smile if you have ever worked with VMware, because most of them are just a Microsoft implementation of others editors' ideas.

Some of these features will, on the other hand, make you burn with desire of testing them, such as Powershell 3.0. This is at least true for me. In fact last week I attended the course 10325A "Automating Administration with Windows PowerShell 2.0" and I can't wait to see what Powershell 3.0 can do for me!

VCP5-IaaS

The Internet has definitively changed since its inception. The technology behind the curtains is evolving constantly and its spread is nowadays global. Cloud computing is the next level of this evolution and the big actors of the IT market know it well. At VMware (which still owns the role of the giant in the virtualization market) people are according more and more importance to the need of delivering certifications for cloud professionals. This is the reason why, according to the official VMware Education and Certification Blog, they are about to launch a new certification program: VCP5-IaaS (acronym for VMware Certified Professional 5 – Infrastructure as a Service).

Currently there is a beta-exam out there but you need to be explicitly invited to it to have a chance to get certified. It looks like this beta exam currently consists of 115 questions. As for other VMware exams there is a pre-exam survey consisting of 8 questions, but the answers you give to them has no impact on your final score. The passing score for this exam is 300.

If you'd like to become a candidate for this VCP5-IaaS certification, know that you should be comfortable with tasks such as install and configure vCloud Director (vCD) and its related components, utilize vCD to create and manage vApps and Service Catalogs. Candidates should also be able of managing cloud enabled storage providers and networking.

To get ready for the exam a four-days long preparation course exists: "VMware vCloud: Deploy and Manage the VMware Cloud (v 1.5)".

At the end of this course, you will be able of:
  • Explain the function of vCloud Director components
  • Install and manage vCloud Director
  • Configure VMware vSphere storage and networking
  • Configure and manage vApps and catalogs
  • Connect organizations with VPN tunnels and static routes
  • Link vCloud Director to LDAP (such as Microsoft Active Directory domain controllers) and understand single sign-on
  • Manage security with VMware vShield Edgefirewalls
  • Use VMware vCenter Chargeback to meter vCloud Director resources
  • Understand the interactions between VMware vSphere Distributed Resources Scheduler clusters and vCloud Director.
If you want to attend a class for this course, then check out the VMware website.

If you are interested in passing the exam and in becoming a VCP-Iaas but you haven't been invited, then subscribe to this link and VMware will let you know when the certification will be publicly released.

If you are still asking yourself what "Inrastructure a s a Service (IaaS)" is and in what way you can benefit from it, then I deeply suggest checking out Microsoft website (oh yes...) at this link, where Keith Combs will drill into the characteristics of the Cloud.

Also check the NIST definition of Cloud computing here.

Stay tuned for more information on this subject!

UPDATE June, 25 2012: Read Tomi Hakala VCP5-Iaas beta exam experience here at v-reality.info.

Wednesday, June 6, 2012

ESX 4.1 installations using PXE fails with a DHCP error message

Last week I was deploying a bunch of ESX 4.1 using PXE and the installation failed for some of them with the following console message:

"Unable to immediately obtain a dynamic address for this interface."

I checked the DHCP service (I am using a combination of Syslinux, WDS and DHCP on a Windows 2008 R2 box) and found that it was happily up and running. I am also using the IPAPPEND option in my PXE configuration file with its value set to 2. Before I continue, here's a brief explanation of the IPAPPEND option:
  • Setting IPAPPEND to 1 will tell the system to use the same MAC address for the kernel then the one used for PXE boot.
  • Setting IPAPPEND to 2 will make the ESX4 installer generate a new dynamic MAC address, which means you will have two IP address reservations in you DHCP for each ESX deployment. In fact ESX 4.1 by default uses a generated MAC address for the installation service console.
In my case my DHCP scope contained 10 IPs only, but I was simultaneously deploying 14 ESXs with IPAPPEND set to 2, which meant that I needed a range with at least 28 available IP addresses (two for each ESX). This is the reason for 9 of my ESXs being unable to obtain an IP address from the DHCP server: the IP range was quickly exhausted.

The solution is pretty simple: I switched to IPAPPEND 1 and increased the IP address scope to 14 IPs, in order to be able to serve all of my ESX installations. For sake of completeness I also shortened the lease duration to two hours.

Maybe you will never need this information, maybe you have bigger DHCP scopes, maybe you will never deploy more than 2 or 3 ESXs at once, but all the same I wanted to share... just in case someone need this.
Related Posts Plugin for WordPress, Blogger...