Monday, May 8, 2017

Get multipath information of a windows machine




 (gwmi -Namespace root\wmi -Class mpio_disk_info).driveinfo | % {Write-host "Name: $($_.name) Paths: $($_.numberpaths)"}

Tuesday, April 11, 2017

Set vm cpu socket*core through powercli

Think of the scenario where vm is running with hardware version 10, edit option is grayed out in VC 5.5.
The only way to do it was from web client and that was also not opening due to some issue.
I have written a Powershell script and performed this activity without any issue.
Script :
#================
get-vm -name vmname1

stop-vmguest -VM vmname1-Confirm:$false

set-vm -vm vmname1-MemoryGB 32

    $proccount = 10

    $corecount = 1

    
    $spec = new-object -typename VMware.VIM.virtualmachineconfigspec -property @{'numcorespersocket'=$corecount;'numCPUs'=$proccount}

    (Get-VM –Name vmname1).ExtensionData.ReconfigVM_Task($spec)
start-vm -VM vmname1-Confirm:$false


#=================

Search vm in vCenter Datastore


Think of a situation when your vm is down , you tried to search it in vCenter but didn't find it.
you have multiple datastore more than 200 luns and now your task is to find the vm
Manual method is to check each datastore one by one but that is time consuming activity
Below script will let you search the from multiple luns



$dstore=Get-Datastore #this command will pull the list of lun from vCenter
clear
foreach($dss in $dstore) #adding for loop will perform below activity for all the luns
{
write-host $dss.Name # writing names for output

$vm=Get-ChildItem -Path vmstore:\"DStr1"\$dss |select name #getting list of folders which are there in the datastore , DStr1 is the datacenter name which you need to hardcore here and inside the datacenter $dss is the lun

    foreach($fol in $vm)# perform below activity for each vm folder
    {
    write-host $fol.Name
    $file=$fol.Name

    Get-ChildItem  -Path vmstore:\"DStr1"\$dss\$file|Select-String -Pattern "vm_name" #this will print the file name and so called vm name you can get as output
  
    }
}



There is another method to search it, if you have an environment where at least one esxi host is there who can see all the luns presented to the vc then you can just take a putty session and use below command to get the details, it will show you the lun id and the file name



find /vmfs/volumes -name servername.vmx

Content of this blog has been moved to GITHUB

Looking at current trends and to make my content more reachable to people, I am moving all the content of my blog https://tech-jockey.blogsp...