パススルーを有効にするスクリプト
あとでWhere条件式をかえてNVMeだけにする予定。
ひとまず最初にConnect-VIServer
$esxName = 'MyEsx'
$esx = Get-VMHost -Name $esxName
$ptMgr = Get-View -Id $esx.ExtensionData.ConfigManager.PciPassthruSystem
$config = @()
$ptMgr.PciPassthruInfo | where{$_.PassthruCapable -and -not $_.PassthruEnabled} | %{
    $ptConfig = New-Object VMware.Vim.HostPciPassthruConfig
    $ptConfig.Id = $_.Id
    $ptConfig.PassthruEnabled = $true
    $config += $ptConfig
}
if($config){
    $ptMgr.UpdatePassthruConfig($config)
}
else{
    Write-Host "No Passthru capable devices found"
}
ホストを再起動して、
テンプレートから仮想マシンをデプロイして、デバイスを追加
テンプレートからデプロイ
$NewVM = New-VM -Name 'VMNAME' -VMHost 'HOSTNAME' -OSCustomizationSpec 'OSTEMPLATE' -Template 'TEMPLATENAME' -Datastore 'DATASTORE'
$ESX = get-vmhost -name esxi01.aaa.local
$ScsiDevice = Get-PassthroughDevice -VMHost $ESX -Id "Uid"
Add-PassthroughDevice -VM $NewVM -PassthroughDevice $ScsiDevice
参考文献
https://thinkit.co.jp/story/2011/02/24/2008
https://qiita.com/nori4k/items/3028d4ba349bf53b63d5
https://communities.vmware.com/thread/566477