Category Archives: Scripting

Detach LUNs from Multiple ESXi Hosts Using Powercli

Hi there

Migrating an old VMWare Vcenter environment to newer vcsa 6.5 can be challenging. In the process I found myself doing other tasks like converting RDMs (Mapped Raw LUN) to .vmdk files.

Migrating RDMs attached to virtual machines on my Vcenter 5.5 environment to .vmdk disk files appeared like a tedious handy task especially when you have these LUNs attached to many ESXi hosts. With the help of powershell and Powercli the task becomes much easier.

I found it comfortable and safer to detach each LUN from all ESXi servers, so this script answers my current need and may be modified as needed. Im aware that it can still be improved and I hope to publish new and improved versions later.

The script asks for the “LUN canonicalName” and performs a Detach action on each Host from the list you provide.

You can find the LUN canonicalName here:LUN canonical name

Prepare a text file with the ESX servers list in c:\temp\esxList.txt, one in each line like so:


Run the script and enter the LUN canonicalName like seen in the above picture.

$CanonicalName = Read-Host "Enter LUN canonicalName"
vcName = "enter vcenter name here"
#get list of hosts
$hostslist = Get-Content "c:\temp\esxList.txt"

# Load VMware PowerShell Module (PowerCLI):
If ((Get-Module VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null)
    Import-Module VMware.VimAutomation.Core

#check if connected to VC and connect if not
$viserver = $global:defaultviserver.Name
if ($viserver -ne $vcName) {
Connect-VIServer -Server vc55

#Start looping ESXi hosts and detach LUNs
foreach ($vmhost in $hostslist){

    write-host “Starting $vmhost”
    $esx = get-vmhost $vmhost
        $storSys = Get-View $esx.Extensiondata.ConfigManager.StorageSystem
        $lunUuid = (Get-ScsiLun -VmHost $VMHost | where {$_.CanonicalName -eq $CanonicalName}).ExtensionData.Uuid
        "Detaching $lunUuid"

How to Ping a List of Computers

Many times It happens that we need to check if a list of computers is active, so how do you ping multiple computers at once?

Use this Powershell script to test connectivity to your list of computers. it will produce two lists of Bad (unresponsive) and Good(Responsive) computers.

You need to change “D:\scripts\list.txt” to the path where your saved your computers list file(.txt).

Also, you can un-comment  #Write-Host $name… to view the list of computers with different colors Continue reading How to Ping a List of Computers

How to run python script on notepad++

How to  Configure Notepad++ to run a python script via python IDLE

If you are learning python and want to use notepad++ as a free as well as simple and easy to use editor, follow these simple steps:

Install python (2.7.x)

First thing: Download the python 2.7.x (current is 2.7.13) windows installer from using the default settings. It should install python in the folder: C:\Python27. You can use a different version of python, just substitute out the version number wherever you see 27. Continue reading How to run python script on notepad++

Create SCCM Distribution Point with Powershell

Hi Sysadmins

You need to create multiple SCCM 2012 Distribution points fast and accurate!

Maybe you decided on upgrading your  environment to SCCM 2012 or your company purchased another organisation. In any case,

The reasonable way will be to use a script, and not use the GUI to do the task over and over.

The preferred scripting environment is Powershell, since it already has many Configuration Manager commandlets that can be helpful.

You do have to work with at least SCCM 2012 sp1 version for the following script to work.

The below Powershell script will read the names of the Distribution points servers from a file. See example for the file Here 

Continue reading Create SCCM Distribution Point with Powershell

How to install IIS features on SCCM 2012 Distribution Point with command line

Hi SysAdmins

Did you ever wonder how SCCM 2012 install a DP remotely from the CM console?

DISM.exe (Deployment Image Servicing and Management tool) is a command line tool that you can use to enable or disable Windows features.

In this case we use it to install all the necessary IIS features for a SCCM 2012 DP.

Command line to install IIS on DPs:

Continue reading How to install IIS features on SCCM 2012 Distribution Point with command line