##Connect vCenter server

$vCenterIP = Read-Host "Enter the VC IP Address/Name "

$vCenterUser = Read-Host "Enter User name"

$vCenterUserPassword = Read-Host -assecurestring "Enter Password"

$vCenterUserPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($vCenterUserPassword))

Connect-viserver ${vCenterIP} -user ${vCenterUser} -password $vCenterUserPassword -WarningAction 0 | out-null

##Import VM list which need to change SCSI controller Scsi Bus sharing mode

$vmlist = Import-CSV "C:\Temp\vmlist.csv"


foreach ($vm in $vmlist){

##Assign Variables

$vmhost = $vm.name

##Re-set VM's SCSI Controller 1 to Virtual

Get-ScsiController -vm $vmhost | where {$_.BusSharingMode -eq "physical"} | Set-ScsiController -BusSharingMode Virtual

##Get-ScsiController -vm $vmhost | where {$_.Name -eq "SCSI Controller 1"} | Set-ScsiController -BusSharingMode Virtual

}

Disconnect-viserver ${vCenterIP} -Confirm:$false #| out-null