Powershell and Vmware PowerCLI, get-vm exception has been thrown by the target of an invocation. How to fix and add proxy in powershell. Add PSGallery as a repo.#vExpert #VMware #powershell #vmwarepowercli

Uninstall PowerCLI from VMware (we add it later from PSGallery) Start Powershell Set tls security to 1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Set http proxy [Environment]::SetEnvironmentVariable(“HTTP_PROXY”, “proxy.invid.se:3128”, [EnvironmentVariableTarget]::Machine) Set https proxy [Environment]::SetEnvironmentVariable(“HTTPS_PROXY”, “proxy.invid.se:3128”, [EnvironmentVariableTarget]::Machine) Now that we have internet connection you can try in powershell, just for confirmation. wget https://invid.se Now it is time to register PSgallery […]

Powercli Vsphere

Get VM list from a datstore Get-datastore | Where {$_.name -like ‘*DATASTORE01*’} | Get-VM Find snapshots Get-Snapshot -vm * -name “VEEAM BACKUP*” | Format-Table -property VM,Name Clear snapshots Get-Snapshot -vm * -name “VEEAM BACKUP*” | remove-snapshot   List VM and What Datastore get-vmhost |get-datastore|%{$ds=$_; $ds.Extensiondata.Vm|%{$_|select @{n=’vm name’;e={(Get-View -property name -Id $_.toString()).name}},@{n=’ds name’;e={$ds.name}} }}   List […]

Powercli 6.5 error with  add-pssnapin VMware.VimAutomation.Cor

They have chnage the way to app snapin! Get-Module -Name VMware.VimAutomation.Core -ListAvailable | Import-Module #add-pssnapin VMware.VimAutomation.Core     Error: add-pssnapin VMware.VimAutomation.Cor add-pssnapin : No snap-ins have been registered for Windows PowerShell version 3. At line:1 char:1 + add-pssnapin VMware.VimAutomation.Cor + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (VMware.VimAutomation.Cor:String) [Add-PSSnapin], PSArgumentException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand