Quantcast
Channel: VMware Communities : Discussion List - VMware PowerCLI
Viewing all 14549 articles
Browse latest View live

performance graph needs to export using powercli

$
0
0

Hi All,

 

   I required to share the performance report of some of the VM's  with my client. Currently I am manually generating the report  (  select the VM in  vCenter ==> select the reports ==> export the performance ) . I need to generate this report daily . Please let me know if this can be automated with powercli.

 

Thanks in Advance.


Vsantrace service stop?

$
0
0

All,

  Does anyone know how to possibly stop a service that is not currently supported by powercli using powercli instead of SSH?  I am trying to stop the vsantrace service.

PowerCli - scripted Storage vMotion

$
0
0

Hi

 

I'm looking to script some storage vmotion activity and I am new to VMware PowerCLI

 

I am using the script below

 

          Import-Csv c:\cla\clatest.csv | Foreach {Get-VM $_.Name | Move-VM -DiskStorageFormat Thin -Datastore $_.NewDatastore -RunAsync}

 

and I have the .csv file mentioned with the following content

 

NameNewDatastore
cla_vm01cla_datastore02

 

this VM and this datastore exist

 

I connect to my vCenter server and when i run the command from PowerCLI i don't get an error but nothing happens - any help would be great

 

these commands work perfectly so i know the PowerCLI session is logged in correctly etc

 

          Get-Datastore "cla_datastore01" | Get-VM | Move-VM -DiskStorageFormat Thin -Datastore "cla_datastore02" –RunAsync

 

          Get-Datastore "cla_datastore02" | Get-VM | Move-VM -DiskStorageFormat Thin -Datastore "cla_datastore01" –RunAsync

 

Thanks

 

Chris

PowerCLI Script to list all VM's disk type and OS

$
0
0

Hi

 

I wonder if you can help me.

 

I need a script to list all VM's Harddisk type and OS.

 

I can do one or another (using cli) but not both on the same report.

 

Thanks, Maelito

vm report per folder

$
0
0

Hi,

 

If i do

 

Get-VM xxx |Select Name,@{N="Folder";E={$_.Folder.Name}},PowerState,    NumCpu,    MemoryGB,    UsedSpaceGB,    ProvisionedSpaceGB |export-csv c:\temp\vm.cvs

 

works well

 

but when i do

 

Get-VM -Name (import-csv c:\temp\vm.csv)  |Select Name,@{N="Folder";E={$_.Folder.Name}},PowerState,    NumCpu,    MemoryGB,    UsedSpaceGB,    ProvisionedSpaceGB |export-csv c:\temp\vm1.cvs

 

gives error

 

Get-VM : 9/3/2014 1:00:33 PMGet-VM    VM with name '@{vm=}' was not fou

nd using the specified filter(s).

At line:1 char:8

+  Get-VM <<<<  -Name (import-csv c:\temp\vm.csv)  |Select Name

+ CategoryInfo      : ObjectNotFound: (:) [Get-VM], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimA

   utomation.ViCore.Cmdlets.Commands.GetVM

 

can someone Please adivce

Script to check for Orphaned Files and Invalid Snapshots

$
0
0

Hi All

 

I have created a Powershell script that checks for Orphaned Files and Invalid Snapshot images.

The Orphaned Files part of the check is using Luk Dekens function for finding and removing phantom files available here.

The other part of the script checks for servers that are using snapshots that do not exist in snapshot manager or servers which have a Consolidated Helper snapshot.

 

We currently run this script daily and it sends us an email if it finds any problems.

 

Simply alter the variables in the top part of the script and it should be able to run in any environment that has PowerCLI installed.

POWERCLI Script Resize VMFS Datastore

$
0
0

Hi,

 

 

I have a problem when expanding datastores in 5.0.U1, U2, U3 versions. When large disk cabin, ESXi recognizes the new size, but in "Properties" Datastorage the button "Increase" this is disabled:

1.JPG

 

I have opened a case with vmware and was told that is a workaround for versions 5.0.X and 5.1.x and  in the 5.5.x version is corrected. He sent me this link: VMware KB:    Cannot grow VMFS datastore, the Increase button is disabled  but I can not apply because it involves service stop.

I found this KB VMware KB:    Growing or expanding a VMFS volume or datastore  and following the steps sometimes allows me to do the expansion, I enable the "Increase", but  many times the button  not working, continues disabled.

 

I found thisl post "Scripted resize of VMFS datastores" but the script fails me, I can not make it work.

 

The script is this:

$ds = Get-Datastore -Name "Volume05"
$dsscsi = get-datastore $ds | get-scsilun
$dscanonical = $dsscsi.CanonicalName
$esx = Get-View $ds.ExtensionData.Host[0].Key
$storSys = Get-View $esx.ConfigManager.StorageSystem
$dsSys = Get-View $esx.ConfigManager.DatastoreSystem
$vmfsPath = $ds.ExtensionData.Host[0].MountInfo.Path
$storSys.RescanAllHba()
$extent = $dsSys.QueryVmfsDatastoreExpandOptions($ds.ExtensionData.MoRef)
$spec = New-Object VMware.Vim.HostScsiDiskPartition
$spec.diskName = $dscanonical
$spec.partition = "1"
if($extent.Count -ne 0){  $storsys.ExpandVmfsExtent($vmfspath,$spec)
}

 

The error I get is:

2.JPG

Excepción al llamar a "ExpandVmfsExtent" con los argumentos "2": "A specified parameter was not correct.
"
En E:\Resize_VMFS_01.ps1: 15 Carácter: 3
+   $storsys.ExpandVmfsExtent($vmfspath,$spec)
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException    + FullyQualifiedErrorId : VimException

 

Please can someone help me?

 

Regards

Daniel

Copy-VMGuestFile fails with large payload

$
0
0

I'm trying to copy a hyperic agent .msi installer payload from local to guest but it fails with the 381MB file. The error returned is:

 

Exception of type 'System.OutOfMemoryException' was thrown.
At line:1 char:76
+ get-item "C:\Hyperic\hyperic-hqee-installer-4.6.0.1.msi" | Copy-VMGuestFile <<<<  -Destination "C:\Hyperic" -VM "IIGCF-Win2k8-Test2" -LocalToGuest -GuestCredential $cred
    + CategoryInfo          : NotSpecified: (:) [Copy-VMGuestFile], ViError
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_UploadFileToGuest_UploadError,VMware
   .VimAutomation.ViCore.Cmdlets.Commands.CopyVMGuestFile

 

Out of Memory... I tried a smaller .zip payload of 67MB, and it began to copy, but ultimately failed 1/3 in to it. Here is the error message now:

 

Copy-VMGuestFile : 1/26/2012 5:40:51 PM    Copy-VMGuestFile        The request was aborted: The request was canceled.
At line:1 char:78
+ get-item "C:\Hyperic\hyperic-hqee-agent-4.6.0.1-win32.zip" | Copy-VMGuestFile <<<<  -Destination "C:\Hyperic" -VM "IIGCF-Win2k8-Test2" -LocalToGuest -GuestCredential $cred
    + CategoryInfo          : NotSpecified: (:) [Copy-VMGuestFile], ViError
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_UploadFileToGuest_UploadError,VMware
   .VimAutomation.ViCore.Cmdlets.Commands.CopyVMGuestFile

 

If I try to copy a small text document, the command works as intended. So my question is, how does one copy a "large" payload package to a guest VM, via powerCLI?

 

Thanks


Trying to copy clusters from one virtual center to another

$
0
0

Hello,

 

I am new to the windows world and have to migrate from a older 5.1 virtual center to 5.5.  I am running into a problem with copying clusters from the older virtual center to the new one using powercli and was hoping someone on this list can help.  Here is what I am trying to do:

 

(please let me know if there is a even better way to clone the cluster information from one virtual center to another)

--

$SourceClusters = Get-Datacenter RWC -server vc01 | Get-Cluster -Server vc01

 

foreach ($SourceCluster in $SourceClusters) {

New-Cluster -Name $SourceCluster.Name -Location "RWC" -Server vc02 -DRSEnabled -DRSautomationlevel "PartiallyAutomated" -confirm:$false

}

--

 

However when I run this I am getting the following error messages:

 

a) Could not find VIContainer with name RWC -- which I know exists and is my Datacenter name

b) New-Cluster VIContainer parameter: Could not find any of the objects specified by name.  I do know that the first get-datacenter command returns the valid cluster names so not sure why this is showing as empty.

 

Anything that I am missing here.

 

Thanks,

-Sim

Can we write "PowerCLI Script" to get HP RAID Card Details (Firmware & Driver) ???

$
0
0

Can we write "PowerCLI Script" to get HP RAID Card Details (Firmware & Driver)

For Example : Below ESX Native Command shows desired output for me.

But we needed equal PowerCLI script to below ESX command

 

 

# cat /proc/driver/cciss/cciss0

 

cciss0: HP Smart Array P400i Controller

Board ID: 0x3235103c

Firmware Version: 7.22# cat /proc/driver/hpsa/hpsa0

hpsa0: HP Smart Array P410i Controller

Board ID: 0x3245103c

Firmware Version: 5.70

Driver Version: HP HPSA Driver (v 5.0.0-17vmw)

Foreach loop help excluding a VM

$
0
0

I need to shutdown all the VMs in a particular vCenter due to work being done on the underlying storage.  I have a script that would normally do this, but in this case, the vCenter is virtual.  I need the foreach loop to skip it. 

I thought I could do a nested loop but my tests aren't working...  Any pointers or suggestions? 

 

Thanks in advance!

----------------------------------------

 

Connect-VIServer $server

 

 

# Gets the list of all VMs in a specific folder

$vms = Get-datacenter -Name "DATACENTER" | Get-VM

 

 

# Shuts down the VMs in the datacenter that are in a powered on state.

Foreach ($vm in $vms){

if ($vm.PowerState -eq "PoweredOn"){

  if ($vm.name -ne "vcenter01") {

  $vmMOR = $vm|Get-View

  if($vmMOR.Config.Tools.ToolsVersion -ne "0"){ 

  #gracefully shutdown

  Shutdown-VMGuest -VM $vm -Confirm:$false

  sleep -Seconds 60

  }

  #forcefully stopping VM

  Stop-VM -VM $vm -Confirm:$false

  }

  }

}

sleep -seconds 60

Shutdown-VMGuest -VM vcenter01 -Confirm:$false

Storage vMotion multiple VM's to NFS

$
0
0

Hi Guys

 

Very new to powercli im afraid so this is prob a simple question

 

I want a script to storage vmotion 6 vm's from local storage on two hosts (3 on each) to NFS shared datastores

 

This is what i have so far  -- this relocates one test vm called mike but it doesnt change the format from thin to thick ? When i do this manually and select thich eager zeroed then it works fine ?

 

Also, whats the bets way to run this for multiple vm's that will be on two different hosts and split them up to two NFS datastores ?  SHould i index ?

 

param(

 

 

 

 

 

 

  $vCenter = "10.73.44.201",

  $VMhost = "*",

  $clusterName = '*',

  $vm1 = "Mike",

    $DS1 = "AMP-NFS-BCK-02",

    $DS2 = "NFS-02"

 

)

#End Setting Paramters for Scripts

 

 

#Connect to vCenter

Write-Verbose "Connecting to vCenter"

$server = Connect-VIServer $vCenter -credential $(get-credential)

 

 

#Storage vMotion VMs

 

 

Get-VM $vm1 | move-vm -DiskStorageFormat Thick2GB -Datastore $DS1

 

 

#Disconnect from vCenter

Disconnect-VIServer $server -confirm:$false

uncheck keep vmdk together on multiple datastore clusters

$
0
0

uncheck keep vmdk together on multiple datastore clusters

Get-VIEvent "vSphere HA restarted virtual machine"

$
0
0

Hi floks

 

Can anyone help me to complete this script

 

Get-Cluster "test" |Get-VM | Get-VIEvent |Where-Object {$_.FullFormattedMessage -LIKE 'vSphere HA restarted virtual machine *'} |select ObjectName,@{N="IP addr";E={($_.Guest.IpAddress)}},CreatedTime,FullFormattedMessage

 

Out put :

 

ObjectName                          IP addr                             CreatedTime                        FullFormattedMessage             

----------                          -------                             -----------                        --------------------             

VM1                                                         05-Sep-14 4:14:29 PM               vSphere HA restarted virtual ma...

VM2                                                           05-Sep-14 4:14:25 PM               vSphere HA restarted virtual ma...

VM3                                                       05-Sep-14 4:14:25 PM               vSphere HA restarted virtual ma...

 

Unable to get ipaddress on this script.

pls provide if any good script to get vSphere HA restarted event  when host failure.

Get-VMHostHba doesn't return WWNs?

$
0
0

Hi PowerCLI community,

 

How come Get-VMHostHba  returns an HBAs world wide names in a bogus format?  I.e.:

 

NodeWorldWideName : 2305843171164295343

 

and

 

NodeWorldWideName : 2305843171164295343

 

whereas if you view this information in the vSphere client you actually see a WWN formatted as one would expect:

20:00:00:25:b5:02:10:af 20:00:00:25:b5:b2:10:5f

 

Is there a way to make Get-VMHostHba return WWNs in the 'normal' format?

 

Thanks!


OS Customization Error

$
0
0

I have a script that I run againt my Production and Development Environments to automate the build of servers from a template.

The code is:

 

$vcenter = Connect-VIServer $vcenterName

 

$vHost = Get-VMHost -Name $vmHost
Get-OSCustomizationSpec -Name $osCustomization | New-OSCustomizationSpec -Name "oscustTEMP" -Type NonPersistent
Get-OSCustomizationSpec -Name "oscustTEMP" | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $ipAddress -SubnetMask $subnetMask -DefaultGateway $defaultGateway -Dns $dns
$vTemplate = Get-Template -Name $vmTemplate
$vDatastore = Get-Datastore -Name $vmDatastore
$vFolder = Get-Folder -Name $vmFolder


New-VM -Name $vm -Template $vTemplate -OSCustomizationSpec "oscustTEMP" -Location $vFolder -VMHost $vHost -Datastore $vDatastore -Confirm:$false
Start-VM -VM $vm -RunAsync

 

Disconnect-VIServer $vcenterName -Confirm:$false

 

 

When I run this against Production Environment the VM builds fine, but when I run it against my Development Environment and after the vim.event.CustomizationSucceeded I get the following error on the VM:

 

"Windows could not parse or process unattend answer file [C:\Windows\Panther\unattend.xml] for pass [oobeSystem]. The settigns specified in the answer file cannt be applied. The error was detected while processing settings for component [Microsoft-Windows-Shell-Setup]."

 

However, when I manually do a deploy from template and select the same OS Customization I do not get the above error and it works. It seems as if it may be an issue with the New-OSCustomizationSpec?

 

Any assistance would be greatly appreciate, please let me know if I need to supply any more details. Both environments are vCenter 5.1., 1123961.

Get-View and New-Object - how does it work?

$
0
0

I'm a bit desperate now - i have been trying to figure the framework options out, using get-view commands, and the API SDK reference site.

As an exercise for myself, i set out to learn how to change linkspeed on a pnic, using the get-view commands. My problem is that i have no idea about where to find those informations, im not sure how to navigate the SDK, and when to use new-object.

 

Here is an example of how far i get:

 

$HS = Get-View -ViewType "HostSystem" -Filter @{"Name" = "ESXSERVER"}.ID

$mod = $HS.ConfigManager.NetworkSystem

$networkConfig = New-Object VMware.Vim.HostNetworkConfig

$networkconfig

 

The $networkconfig turns out empty (I would expect to see som kind of info on what is included in the HostNetworkConfig), and im not sure how to drill down to choosing the pnic i want to make the changes to.

 

When writing $HS value to the screen, i can drill down thrue the different options, but how do i know when to use New-Object to define settings?

 

Im pretty much grasping at straws here...

 

I would like to get an understanding of the methods beyound using cmdlets, but im kinda stuck...

Get-VM | Get-VIEvent -- How can i get folder info ?

$
0
0

My script for getting vm created info works well, But when i tried to add coloum "folder" it is not workig.

 

Get-VM | Get-VIEvent -Start (Get-Date).adddays(-2) | `

where { $_.Gettype().Name -eq "VmCreatedEvent" -} | `

select @{N=”VMname”; E={$_.Vm.Name}},

@{N=”Host”; E={$_.Host.Name}}

 

  ..

ConvertTo-Html ...

 

How can i add "folder Name" in that ? I tried,

 

@{N="Folder";E={$_.vm.Folder.Name}}

 

But it gives blank info... 

How to get "Display Name" from RAW LUNs with PowerCLI

$
0
0

Hi,

 

I have a question:

 

We have many RAW LUNs and I have changed the Display Name in vCenter.

 

How can I get all the changes as Output in an csv file with PowerCLI?

 

Many Thanks

Running "Get-VMGuestNetworkIn terface -VM vmname" gives error info as "Unable to parse script output"

$
0
0

Hi,

 

When i run "Get-VMGuestNetworkInterface -VM kumar" command, getting the below mentioned error info message.

Can anyone help in resolving this problem.

 

 

 

PS C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> Get-VMGuestNetworkIn

terface -VM kumar

Get-VMGuestNetworkInterface : 5/17/2013 2:59:20 AM    Get-VMGuestNetworkInterfa

ce        Unable to parse script output.

At line:1 char:28

+ Get-VMGuestNetworkInterface <<<<  -VM kumar

    + CategoryInfo          : InvalidArgument: (:) [Get-VMGuestNetworkInterfac

   e], ViError

    + FullyQualifiedErrorId : Client20_VmHostServiceImpl_GetVmGuestNetworkInte

   rface_UnableToParse,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVmGues

  tNetworkInterface

 

 

 

Thanks,

Pravin

Viewing all 14549 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>