Tag: Scripts

How to clear WINS from Network Adapter Configuration with Powershell

Hello Guys…!!!

Here is the simple script to clear the WINS entry from multiple servers with powershell script.

$servers=gc C:\ServerList.txt
foreach($server in $servers){
$adapters=Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $server
foreach($adapter in $adapters){
Write-Host "=======Before Making the WINS NULL=========" -ForegroundColor White
Write-Host $adapter.Description,$adapter.WINSPrimaryServer,$adapter.WINSSecondaryServer

Script to Get Datastore Path Information

Hello guys…!!!

Here is script developed to get the No Of Paths per DS and Type of path selection policy and to which VMHBA it is connected.

PowerShell Scrip:

Connect-VIServer -Server servername -User username -password password
#Get list of ESXi Hosts
$esxihosts=gc C:\hosts.txt
For($i = 1; $i -le $esxihosts.count; $i++)
ForEach ($esxihost in $esxihosts) {
 $esxi = Get-VMHost -Name $esxihost
 $hbas = $esxi | Get-VMH

 ForEach ($hba in $hbas) {
 $scsiluns = $hba | Get-ScsiLun
 ForEach ($scsilun in $scsiluns) { 
 $exportDSPaths=New-Object PSObject
 $scsipaths =$scsilun | Get-Scsilunpath |Select-Object *
 $DS=Get-Datastore |Get-View |Where-Object {$_.Info.vmfs.Extent.DiskName -eq $LunNaaID}
 #Write-Host $DS.Name,$LunNaaID,$LunPathPolicy,$PathCount,$hba.Name,$esxi.Name
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "EsxiHost" -Value $esxi.Name
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "DatastoreName" -Value $DS.Name
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "LunNAAID" -Value $LunNaaID
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "MultipathPolicy" -Value $LunPathPolicy
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "LunPathCount" -Value $PathCount
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "VmHBA Connected" -Value $hba.Name
 Write-Progress -Activity “Now Scaning $datastore in $hba on $esxi” -status “Found $countofESXi esxi hosts and working on $esxi” -PercentComplete ($i / $esxihosts.count*100)
$expotDSPathCount| Export-Csv -NoTypeInformation 'DSPathCountInformation.csv'

Sample Out PutDSPathInfo

Script to Get the Path Count of VMHBA

Hello guys…

Here is the script  to get the Number of Paths for each and every VMHBA in esxi and the out put will be saved in CSV Files…Thanks to Lucd…


Connect-VIServer -Server vcenterservername -User vcenterusername -password vcenterpassword
$esxs=gc C:\Users\TIRU\hosts.txt
foreach($esxi in $esxs){
$esx = Get-VMHost -Name $esxi
foreach($hba in (Get-VMHostHba -VMHost $esx ))
$target = ($hba.VMhost.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -eq $hba.Key}).Target
$luns = Get-ScsiLun -Hba $hba 
$nrPaths = ($target | %{$_.Lun.Count} | Measure-Object -Sum).Sum
$exportObject=New-Object PSObject 
$exportObject |Add-Member -MemberType NoteProperty -Name "HostName" -Value $esx
$exportObject |Add-Member -MemberType NoteProperty -Name "HBAName" -Value $hba.Device
$exportObject |Add-Member -MemberType NoteProperty -Name "NumberOfPaths" -Value $nrPaths
$exportData| Export-Csv -NoTypeInformation 'ESXiStoragePathInformation.csv' 

Sample Output:

SampleOutput Of Script