I have the following script that clones me a VM when I run it from powercli version 6.5 it works correctly but when I try from powershell version 5 it shows me the following error.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
##Clonar VM
##Variables
$vcenter_server ="ip"
$vcenter_user ="user"
$vcenter_pwd ="passwd"
$VMsource = "SRV-SERVER"
$esxi = "172.16.1.51"
$newVMclone = "$($VMsource)-clone-$((Get-Date).ToString('MMddyyyy'))"
$oldCloneName = "$($VMsource)-clone-$((Get-Date).AddDays(0).ToString('MMddyyyy'))"
$ds = Get-Datastore | where{$_.Type -eq 'VMFS' -and $_.ExtensionData.Summary.MultipleHostAccess} | Sort-Object -Property FreeSpaceGB -Descending | select -First 1
$esx = Get-Cluster -VM $VMsource | Get-VMHost | Get-Random
##Connect to vCenter
connect-viserver -server $vcenter_server -User $vcenter_user -Password $vcenter_pwd
##Elimina VM de hasta 7 dias
Get-VM -Name $oldCloneName -ErrorAction SilentlyContinue | Remove-VM -DeletePermanently:$true -Confirm:$false
##Clone VM, disco virtual tipo thick y carpeta de almacenaiento de la VM
New-VM -VM $VMsource -Name $newVMclone -VMHost $esxi -DiskStorageFormat Thin -Location "Laboratorios"
## get the .Net View object of the clone VM
$viewCloneVM = Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device -Filter @{"Name" = $sVMsource}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PS C:\Users\Marco\Desktop> .\clonacion.ps1
Get-Datastore : The term 'Get-Datastore' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Marco\Desktop\clonacion.ps1:10 char:7
+ $ds = Get-Datastore | where{$_.Type -eq 'VMFS' -and $_.ExtensionData. ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Datastore:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException