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

Comparing 2 objects in PowerCLI

I apologies if the question is not quite right, as I'm not sure of the correct wording / syntax for this question... Get-View -ViewType VirtualMachine | Where { $_.Guest.GuestFullname} | Sort Name |Select-Object Name,…
StackUser_py
  • 173
  • 1
  • 1
  • 6
2
votes
2 answers

Error converting object array to hashtable

Quick Overview: Script has two functions, one gets a two lists of roles and puts them in a hash table, then returns that hash table. Process-Roles then accepts a hash table, and does some comparisons on it. $RoleTable is supposed to be a hash table,…
kxf951
  • 155
  • 1
  • 2
  • 11
2
votes
3 answers

For VIServer and PowerCLI, how to prompt for Credentials only the first time in PowerShell, then store credentials and use them for next script run?

I want to be able to log into VIServers using PowerShell and have it ask for the credentials the first time the script runs, then save those credentials in the password.txt file and have the VIServer just use that password.txt file stored locally on…
2
votes
1 answer

Clone.Vm using Vestris.VMWareLib

I'm trying to clone a Virtual Machine using VVMWareLib. The code I'm using is the following using System; using Vestris.VMWareLib; namespace QsBuild.Blocks.VmWare { public interface ICloneVmBlock { void CloneVm(string filename); …
AutDev
  • 65
  • 8
2
votes
2 answers

Removing PowerCLI list truncation

I have the following snippet Get-VM | select name, @{ Name = "IP Addresses"; Expression = { $_.Guest.IPAddress }} | Format-List This outputs a fantastic list of servers and IP addresses however i notice some iPV6 addresses are truncated. Name …
StackUser_py
  • 173
  • 1
  • 1
  • 6
2
votes
2 answers

How do I query vSphere for an existing virtual machine?

Using the VMware.Vim library (part of PowerCLI I believe) I'm trying to find a specific machine that exists in vSphere. My code looks like this: using VMware.Vim; var client = new…
Paul
  • 2,698
  • 22
  • 27
2
votes
2 answers

Invoke powershell script from java

I am trying to invoke some powercli script from Java and it fails. I am working with VMWare esx This is my Java code: String command = "cmd.exe C:\\Users\\mayan\\Desktop\\scriptPS.ps1"; Process powerShellProcess =…
maya
  • 53
  • 6
2
votes
2 answers

Add and Remove Snapshots with PowerCLI for multiple servers

I am trying to get a snapshot from multiple servers with PowerCLI. Connect-VIServer -server 192.168.0.1 -user acconut -password xxx $vmlist = Get-Content C:\Users\Desktop\Test\Servers.txt foreach($VM in $VMlist) { New-Snapshot -VM $vm -Name…
rozbeh85
  • 37
  • 2
  • 3
  • 7
2
votes
1 answer

Powershell : unable to add the members to collections

I face a problem in following test script. I expect the following result as the output of it. VM Name vCPU Memory ------- ---- ------ …
2
votes
1 answer

VMware PowerCLI - Mass Revert Snapshot

I'm trying to revert an array of VM's (created from C:\esx\vmlist.txt) to snapshot "test" (all were snapshot at the same time with a snapshot named "test"). Here's my script: Add-PSSnapin VMware.VimAutomation.Core Connect-VIServer -Server…
l0sts0ck
  • 373
  • 1
  • 4
  • 10
2
votes
1 answer

How to get DataStore's location using PowerCli

Using Get-DataStore cmdlet we get the name of datastore as Datasore1. But I need path of that datastore on ESX. Which is something like /vmfs/volumes//.
VarunVyas
  • 1,357
  • 6
  • 15
  • 23
2
votes
1 answer

Write-Host vs Write-Output - Newlines

I am having difficulty outputting a variable on the same line as a string of text. It works when I use Write-Host, but not Write-Output. I want to use Write-Output because it is seemingly the best practice (keeping things in the pipeline), but…
user3253260
  • 23
  • 1
  • 3
2
votes
1 answer

Powershell - Create new line for multiple array objects using Export-csv

I have an odd one that I haven't seen much writing on. Anyway, here goes. I'm trying to build an array and export it to CSV. The problem is, if there is more than one result returned, I can't figure out how to add it to the CSV as a new line. I am…
John
  • 99
  • 2
  • 4
  • 10
2
votes
2 answers

powercli Get-VM NOT matching Tag

I am using Tags to filter VM / identify special configuration. Get-VM -Tag TEST Now I want to get all VMs NOT matching a tag .... Is there a way to do that without an extra loop to remove all items matching the Tag ?
anael
  • 23
  • 1
  • 7
2
votes
1 answer

How to get a file from a VM runing on a VMware ESXi5.0

I have a question: How to get a file from a VM runing on a VMware ESXi5.0 Examples: i have a file Test.txt in folder C:\Test in 'myVM'. This myVM running on a vSphere server run windowserver 2008R2. I want to get this file to my local computer. I…
John
  • 2,015
  • 5
  • 23
  • 37