POWERCLI

– Bypas PowerCLI security warnings “Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your computer. Do you want to run –.ps1? [D] Do not run [R] Run once

set-executionpolicy bypass

Connect to vCenter or ESX host by using an encrypted password

– Store credentials in XML file. The password is encrypted

New-VICredentialStoreItem -Host server -Password PASSWORD -User beerensi -file C:\"PowerCLI\vicredentials.xml"

– Connect to vCenter by using the XML file

$creds = Get-VICredentialStoreItem -file C:\"PowerCLI\vicredentials.xml"
Connect-VIServer -Server $creds.Host -user $creds.User -password $creds.Password

Running a schedule task

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe "& 'C:\PowerCLI\snapshot.ps1'"

Change root password VMware ESX(i) host

Connect-VIserver servername
Set-VMHostAccount -UserAccount root -Password Password

Change multipath policy to RoundRobin for HP LeftHand (naa.6000eb*) datastores

get-vmhost servername | Get-ScsiLun -CanonicalName 'naa.6000eb*' | Set-ScsiLun -MultipathPolicy "RoundRobin"

HP LeftHand = naa.6000*
HP EVA = naa.6001*
NetApp = naa.60a9*

Update VMware tools VM

get-vm VNNAME | update-tools

Get the total amount of vRAM used by the powered on VMs

Get-VM | where {$_.PowerState -eq "PoweredOn"} | Measure-Object -Property MemoryMB -Sum

3 thoughts on “POWERCLI

  1. Hey Ivo!

    Voor het script Change multipath policy to RoundRobin for HP LeftHand (naa.6000eb*) datastores:
    Werkt geweldig, alleen ik denk dat naa.6001* geldt denk ik voor een HP EVA 4400 (?), maar bij een HP EVA 4000 is het naa.6005*.

    Ter info, thnx voor je script!

  2. I am looking for a way to pull all the NIC details from all our our VMs. For instance, I need to gather foe following info:
    Server Name
    NIC Name
    Link Speed
    MTU
    TCP Offloaded
    Chimney

    Can you help me with a script to gather this info?

    Thank you!

  3. Hello – I am trying to write the output of the AMS versions to csv and it’s not liking it for some reason. When I first ran the script you published, I did get an error where I had to remove the ‘FT’ from the script, and I see the results displayed perfectly. I just need to export to csv – can you help? Here is what I have:
    #####################

    #Connect to vCenter
    $creds = Get-VICredentialStoreItem -file c:\creds\mycreds.xml
    connect-viserver -Server $creds.Host -User $creds.User -Password $creds.Password

    $GetHosts = Get-VMHost -Location ‘My Cluster’

    ForEach ($VMHost in $GetHosts) {

    $ESXCLI = Get-EsxCli -VMHost $VMHost

    #Write-Host $VMHost -ForegroundColor Green

    $ESXCLI.software.vib.list() | Where {$_.Name -eq “hp-ams”} | Select Name,Vendor,Version | export-csv c:\ams.csv

    # Disconnect session vCenter

    Disconnect-VIserver -Confirm:$false

Leave a Comment