Questions tagged [powercli]

VMware vSphere PowerCLI is a set of Windows PowerShell snap-ins that provide cmdlets to automate vSphere and vCloud virtual environments.

VMware vSphere PowerCLI contains snap-ins of cmdlets based on Microsoft PowerShell for automating vSphere and vCloud administration. It provides C# and PowerShell interfaces to VMware vSphere and vCloud APIs.

(VMware vSphere PowerCLI Cmdlets Reference)

PowerCLI provides hundreds of cmdlets "for managing, monitoring, automating, and handling lifecycle operations for vSphere and vCloud Director components" (VMware vSphere PowerCLI User's Guide).

References:

540 questions
2
votes
1 answer

Issue getting pssessions to loop properly for multiple servers listed in a txt file

I start with a txt file named vms.txt. It contains 2 servers like so: server1 server2 When I run the script shown below, the command that is invoked to install VMware tools only runs on server2 and server1 gets skipped. Does anyone have any…
jeff4765
  • 21
  • 4
2
votes
1 answer

correct syntax for putting a powershell script into a variable with double quotes

I have a need to put a PowerShell script into a variable with double quotes like so. However I am not aware of the correct syntax for this as I see syntax errors with $script variable when I try this. $script = "Invoke-Command -ComputerName…
1JS1-2
  • 23
  • 2
2
votes
2 answers

Is it possible to autocomplete a Read-Host prompt with previous Get command output. Without saving an output file

I am writing a script to deploy VM hosts and I want to run a Get command to show them available options and then use their input with autocomplete from previous GET command. I do this because I want to avoid any typos that can be made during manual…
2
votes
2 answers

For vSphere and vCenter automation, is PowerCLI cmdlets or VIX API the better approach?

http://www.vmware.com/support/developer/vix-api/ has VIX docs and says it is useful for automation of interactions with ESXI and vCenter vSphere PowerCLI is a command-line and scripting tool based on PowerShell that provides useful functionality for…
Jai
  • 319
  • 2
  • 9
  • 30
2
votes
2 answers

Issues with Registering PSRepository and Installing VMWare PowerCLI Module

My Setup: Windows 10.17134, PowerShell 5.1.17134.407 When trying to Register a new PSRepository using the Code below…. Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy…
Armin
  • 21
  • 1
  • 1
  • 3
2
votes
2 answers

PowerCli Command

I am trying to use a PowerCli commandlet to create a new virtual machine New-VM -ResourcePool vfcplvmh0009 -Version v11 -Name TestServer22 -Datastore 0031_A_Normal001 -DiskGB 100 -DiskStorageFormat EagerZeroedThick -MemoryGB 4 -NumCpu 2…
JRN
  • 269
  • 1
  • 3
  • 19
2
votes
1 answer

Get current CPU usage using PowerCLI

On the vSphere client host summary page, current CPU usage stats are displayed: CPU Free: 76.38 GHz Used: 4.02 GHz Capacity: 80.4 GHz I am trying to retrieve this information using PowerCLI, so far I have discovered this…
LightningWar
  • 915
  • 1
  • 19
  • 35
2
votes
2 answers

Using Export-Csv

I am having some trouble getting the formatting correct for my script. I am trying to use powercli with VMware to pull host name and IP info and from a vApp and export it to CSV. So far I have: $vapp = Get-CIVApp -name name_of_vApp $vms =…
Philosophene
  • 80
  • 1
  • 7
2
votes
1 answer

powercli / powershell import csv and nested loops

I have CSV file with multiple column from which I select 2 and 3 (just ignore 1st one) My goal is to execute command with "hash" parameter for each host. each host have 2+n hash options so I need to find a way to execute n+1 times same command with…
Eazy Snatch
  • 61
  • 1
  • 1
  • 4
2
votes
2 answers

Append a prefix to a string in PowerShell/PowerCLI

I'm trying to append a specific suffix to a list of VMs using PowerCLI, the problem is that I'm not able to match the start of the string and replace only that, instead what I'm getting is appending my prefix to every letter of the name. Here's the…
drak
  • 87
  • 1
  • 1
  • 8
2
votes
3 answers

Powershell/PowerCLI Loop, timeouts and exits

Here is the scenario - I'm remotely starting a VM via Powershell/PowerCLI (VMwares Powershell module) and once the VM is started I will be running a series of cmdlets against the VM. Currently I have this bit of code: Start-VM "my VM Name"…
TheDemonLord
  • 327
  • 1
  • 2
  • 15
2
votes
1 answer

PowerCLI: Work with VMs on multiple vCenter servers

I have a script that will power off and DeletePermanently all VMs that match a certain prefix. I use this when testing other automation tools to make it easy to reset the lab. The script connects to multiple, pre-defined vCenter servers and then…
McKenning
  • 631
  • 4
  • 20
  • 32
2
votes
0 answers

VMware vCLI Perl "who done it" script

I've been trying to do this for a while and I just can't seem to understand the vCLI SDK. I believe the MO that I want to use is ServiceContent->Task Manager, then print out the recent task. Here is my subroutine for doing it: sub TaskManager { …
2
votes
1 answer

Powershell / PowerCLI - Need more efficient method of inserting dynamic information into SQL

I've used stackoverflow for years, but today is the first time I've felt the need to ask a question. I would like to know if the following code could be made more efficient, this is because I'm writing multiple copies of the script, entering into…
Daniel
  • 129
  • 1
  • 5
2
votes
2 answers

powershell Set-variable not passing properly

I added a menu portion of my script which is using a function to set-variables for connections to vcenter servers. The problem is it isn't passing the variable. When I quit the script the variable is correct when I do a get-variable. #Main…
The Slayer
  • 25
  • 6
1 2
3
35 36