Quantcast
Channel: VMware Communities : All Content - VMware PowerCLI
Viewing all 16717 articles
Browse latest View live

Help with new-viproperty and 'datastore' object

$
0
0

Hey all

 

Was wondering if someone can help ?

 

I've been racking my brains and have come to the end of my tether as to what could be the problem. Issue is as follows :

 

New-VIProperty -ObjectType Datastore -Name _DSVersion_ -ValueFromExtensionProperty 'Info.Vmfs.Version'

New-VIProperty -ObjectType Datastore -Name _DSBlocksize_ -ValueFromExtensionProperty 'Info.Vmfs.BlockSizeMb'

 

All I'm trying to do is create a new vi-property that allows me to see the 'blocksize' and 'filesystem version' from the extensiondata object. I've done this numerous times before with other objects for other object types and they have been successful ?!?! However for this simple creation does NOT seem to be working and i cant figure it out ?!?!?

 

Any ideas anyone ?

 

Many thanks in advance

 

Munster99

 

(PS versions as below)

 

PowerCLI C:\> Get-PowerCLIVersion

 

PowerCLI Version
----------------
   VMware vSphere PowerCLI 5.0.1 build 581491
---------------
Snapin Versions
---------------
   VMware AutoDeploy PowerCLI Component 5.0 build 544967
   VMware ImageBuilder PowerCLI Component 5.0 build 544967
   VMware License PowerCLI Component 5.0 build 544881
   VMware vSphere PowerCLI Component 5.0 build 581435


Problem with New-VM "-NumCpu" and "MemoryMB" parameters

$
0
0

Greetings,

I'm trying to create a new VM, and getting a weird message:

"Parameters set cannot be resolved using the specified named parameters. At:...."

 

Code:

New-VM -VMHost $VMHost -Name $VM.NAME -Location (Get-Folder "Test") -Datastore (Get-Datastore $VM.VMFS) `

-Template (Get-template $VM.TEMPLATE) -OSCustomizationSpec (Get-OSCustomizationSpec $VM.CUSTSPEC) `

-NumCpu X -Memory Y

Tried: X = 2 , "2", $CPU = 2

         Y = 2048 , "2048", $MEMORY= 2048

 

It's working without the "NumCpu" and "MemoryMB" parameters.

 

Any ideas?

Help Finding how much space each VM is using, on each Datastore, within a folder

$
0
0

Hey Guys,

 

I need help with a script... 

 

I need to get a list of how much space each VM is using on each datastore.  I only need this from a select list of VMs.  These VMs are all in the same folder, however this folder exists under 3 differnet parent folders (Development, Staging and Production).  Each VM has a VMDK on 3 datastores and I need to see how big each VMDK is (they are thin provisioned disks.) 

 

I came up with the script below, but it only gives me totals for the different datastores and not a value for each VM...

 

get-Datastore -VM (Get-VM -Location (get-Folder Development)) | select Name,@{N="i3 Cube";E={$_.Folder.Name}} | Sort-Object Name | export-CSV "c:\Cube.csv"

 

If I do

 

Get-Datastore -VM (Get-VM -Name VMNAME) it works...  so i need to figure out the get-VM part that will pull a list of...

 

Development\FOLDER

Staging\FOLDER

Production\FOLDER

 

If I wasn't in a hurry for the info, I'd try to figure it out on my own...

 

 

Thanks in advance!!

 

- Ben

Get-ViEvent

$
0
0

I am using the vCheck 6.0 reports for out vCenter servers and I am running into a problem customizing them. Hopefully you guys can lead me in the rigt direction.

 

I like to be able to see which VMs were removed by whom but we run CommVault for backups and such and this causes issues there to be a lot of results from the commvault user account. I would like to exclude results based on the username that completed the task.

 

This is the plugin code that I am using currently:

 

# Start of Settings
# Set the number of days to show VMs removed for
$VMsNewRemovedAge =5
# End of Settings

 

$OutputRemovedVMs = @($VIEvent | where {$_.Gettype().Name -eq "VmRemovedEvent"}| Select CreatedTime, UserName, fullFormattedMessage)
$OutputRemovedVMs

 

 

I can figure out how to limit results to a specific user but I cannot seem to figure out how to simply exclude a user.

 

I have also taken a look at http://communities.vmware.com/message/1895042?tstart=515, but I am terrible with regular expressions and cannot figure out how to match the string for the VM removal events.

 

I would appreciate any help that I can get.

Thanks,

David

How to deal with certificate errors when connecting to VI-Server

$
0
0

I recently upgraded to Powershell v.5.01 and now I am seeing something new when to connect to my vCenter server.

 

$vCenter="my-cVenter-FQDN"

$vCenterCredFile = "\\path\to\vCenterCredentials.XML"
$vCenterCreds = Get-VICredentialStoreItem -Host $vCenter -File $vCenterCredFile
Write-Host "Connecting to vCenter ..."`n
Connect-VIServer $vCenter -User $vCenterCreds.User -Password $vCenterCreds.Password | Out-Null

 

and I get:

 

Connecting to vCenter ...

 

WARNING: There were one or more problems with the server certificate:

 

* The X509 chain could not be built up to the root certificate.

 

* The certificate's CN name does not match the passed value.

 

Certificate: [Subject]

  E=support@vmware.com, CN=VMware default certificate, OU="VMware, Inc.", O="VMware, Inc."

 

[Issuer]

  O=VMware Installer

 

[Serial Number]

  116C6FA5

 

[Not Before]

  6/9/2011 2:38:48 PM

 

[Not After]

  6/6/2021 2:38:48 PM

 

[Thumbprint]

  3075FD19521FBF00CDA8ACC3D2B2FBB6B454A611

 

 

 

The server certificate is not valid.

 

WARNING: THE DEFAULT BEHAVIOR UPON INVALID SERVER CERTIFICATE WILL CHANGE IN A FUTURE RELEASE. To ensure scripts are not affected by the change, use Set-PowerCLIConfiguration to set a value for the InvalidCertificateAction option.

 

so:

 

1. I have added the certificate from my vCenter to my cert store (both "Trusted Root Certifcation Authorities" and "3rd Party Root Certification Authorities" , which should take care of the "build up to root certificate", I thought. If not, what should I have done with this certificate, to avoid these warnings/errors?

2. I guess I should be issuning a "set-PowerCLIConfiguration -InvalidCertificationAction Ignore" for future use?

How to get the list of VMhost CPU Ready

$
0
0

Hi,

 

Can anyone please assist me in getting the report of VMHost CPU ready in total ?

 

this is so that i know which ESX host got issue with CPU ready or overly allocated.

 

Thanks.

CPU Ready Per ESX Host

$
0
0

Is it possible to pull the CPU Ready stats on a per ESX Host basis?

need a script to get performance report for a month on the below parameter for ESXi, VMS and cluster

$
0
0

Hi All,

 

For the below parameters we need script with the output in csv format separately for ESXi, VMs and cluster. (Monthly).

 

 

Actual Minimum CPU (%)Actual Average CPU (%)Actual 95th Percentile CPU (%)Actual Maximum CPU (%)Minimum Ready Time (%)Average Ready Time (%)95th Percentile Ready Time (%)Maximum Ready Time (%)Ready Time CountAverage Ready Time Above 10 (%)Allocated vCPURun QueueActual Average Memory (%)Actual 95th Percentile Memory (%)Actual Maximum Memory (%)Memory Granted (GB)Installed Memory (GB)Memory Granted (%)Average Memory Consumed (GB)95th% Memory Consumed (GB)Max Memory Consumed (GB)Average Memory Consumed (%)95th% Memory Consumed (%)Max Memory Consumed (%)Average Memory Active (GB)95th% Memory Active (GB)Max Memory Active (GB)Average Active Memory %95th Percentile Active Memory %Max Active Memory %Average Ballooning (GB)95th Percentile Ballooning (GB)Max Ballooning (GB)Average Ballooning (%)95th Percentile Ballooning (%)Max Ballooning (%)Average Swap In (KB)95th Percentile Swap In (KB)Maximum Swap In (KB)Average Swap Out (KB)95th Percentile Swap Out (KB)Maximum Swap Out (KB)Average I/O Wait Time95th Percentile I/O Wait TimeMaximum I/O Wait TimeAverage Kernal Latency95th Percentile Kernal LatencyMaximum Kernal LatencyAverage Device Latency95th Percentile Device LatencyMaximum Device LatencyAverage Aborts95th Percentile AbortsMaximum AbortsFile System Allocated Total Space (GB)Average File System (GB)95th Percentile File System (GB)Maximum File System (GB)Average Dropped Packed (Transmit)95th Percentile Dropped Packed (Transmit)Maximum Dropped Packed (Transmit)Average Dropped Packed (Received)95th Percentile Dropped Packed (Received)Maximum Dropped Packed (Received)

vmware cluster and resources

$
0
0

Dear vmware experts,

 

I have some general doubts regarding the rsource management in the vmware.

 

The normal memory and resource management techniques like transparent page sharing,memory ballooning,cpu timeslicing etc are only available if i enable DRS on the cluster or are these features available for all the vms on all the esxi hosts on  physical host level.

 

If i have 3 esxi nodes added to a cluster (without DRS)  i understand that all the hosts resources are added to the hidden resource pool associated with the cluster.So if a VM running on a host if doesnt have cpu or mem resource can the cluster allocate the resource to the VM from anoder host (without moving the vm to anoder host ) since the cluster have free resources available.

 

thanks for your replies.

 

 

thanks

manek

PowerCLI - Create Categories and Tags?

$
0
0

Hi,

 

I've been trawling the documentation and Google for an afternoon now, but I can't find a way of creating a Category and Tag in PowerCLI 5.1 R1 - does anyone know if this is possible? The custom attribute wizard is shockingly poor, I need to be able to PoSH my existing attributes into Tags.

 

Thanks,

 

Sam

Detach naa device from cluster

New-DrsRule - Anti-affinity Rule Max 2 VM's

$
0
0

Hello All,

I Using vSphere and PowerCli 4.1 to import and export vSphere objects and wondering if anyone could give me the low-down on DRS Anti-Affinity rules.

Specificly if the number of VM limit is still capped at two.

 

The reason I ask is that when I attempt to create a anti-affinity rule for three VM's from the command line with the following command:

 

New-DrsRule -Cluster (Get-Cluster -name $DRSR.cluster) -Name DRSR.Name -Enabled $True -KeepTogether $False -VM (Get-VM $DRSR.vms)

 

I get the following error:

 

New-DrsRule : 7/26/2011 3:30:24 PM    New-DrsRule        You need to specify 2 or more VMs if KeepTogether option is set and only 2 VMs if KeepTogether option is not set.   
At line:1 char:12
+ New-DrsRule <<<<  -Cluster (Get-Cluster -name $DRSR.cluster) -Name DRSR.Name -Enabled $True -KeepTogether $False -VM (Get-VM $DRSR.vms)
    + CategoryInfo          : InvalidArgument: (:) [New-DrsRule], VimException
    + FullyQualifiedErrorId : Client20_ComputeResourceServiceImpl_TryValidateDrsRuleVMCount_InvalidVmCount,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewDrsRule

 

However I am able to create the rule through vCenter.

What am I missing here? Is the rule I create in vCenter not actually being applied?

 

Anyone out there able to set me stright?

 

Thanks!

Need Powershell script for VM inventory

$
0
0

Hi,

 

Need a powershell script to collect the below given info from virtual center.

 

vmname | ESX Name | memory(GB) | vCPU count | vNIC Count | IP address(all) | vmdk(s) size(GB) | Total vmdk size(GB) | Datastore name | Tools version | tools update | shares | reservations(MB) | limit(MB) | snapshot count | Guest OS 

 

vmdk(s) size(GB) ---> Need all vmdk size of the vm seperated by "". EX: for a vm of 3 vmdk's of size 20,20,10GB each the output would be 2020+10

 

Datastore Name ---> Name of the datastore where VMX is located.

 

Tools update ---> Need status like old or updated

How to change font color to red if a condition is met?

$
0
0

HI

 

How would I change the font color to red in an HTML report if the PercentageFree is less than 10 %

 

 

 

a = "<style>"
$a = $a + "body {background-color:Ivory; font-family:Tahoma; font-size:12pt;}"
$a = $a + "td, th {border:1px solid black; border-collapse:collapse;}"
$a = $a + "th {color:white; background-color:Green;}"
$a = $a + "table, tr, td, th {padding: 2px; margin: 0px}"
$a = $a + "table {margin-left:70px;}"
$a = $a + "</style>"

 


##Function to get percentage of datastore free space
####################################################
function CalcPercent {    
     param(    
     [parameter(Mandatory = $true)]    
     [int]$InputNum1,    
     [parameter(Mandatory = $true)]    
     [int]$InputNum2)    
     $InputNum1 / $InputNum2*100

$datastores = Get-Datacenter "ECC-MTB (Martinsburg)" | Get-Datastore  | Where-Object {$_.Name -notlike "DataStore1*"}  
ForEach ($ds in $datastores)

{    
   if (($ds.Name -match "Shared") -or ($ds.Name -match ""))    
   {         $PercentFree = CalcPercent $ds.FreeSpaceMB $ds.CapacityMB        
             $PercentFree = "{0:N2}" -f $PercentFree       
             $ds | Add-Member -type NoteProperty -name PercentFree -value $PercentFree   
  }
}

Remove duplicate datastore mount from VC

$
0
0


Hi All,

 

I am trying to combine two logic here:

 

1. report duplicate mount points which we can do through the following

 

get-datastore * | where { $_.Name -like "*(*)" }

 

2. report hosts which have the follwoing datastores in a cluster/VC in the format:

 

Hostname     DSName FreeSpaceMB     CapacityMB

 

Any pointers?

 

Thx,

A


Open PowerCli from C# and run Commands on PowerCli

$
0
0

Hi,

 

I want to run commands in PowerCli in remote server from C#,

 

So I need to open PowerCli in remote server from C#  

 

I tried to run the below command but getting Connect-VIServer is not found as a cdmlt command.

 

Please provide me the C# code to open PowerCli and run Connect on that Runspace.

 

Connect-VIServer -Server 192.168.10.10 -Protocol http -User admin -Password sck9p84

 

Code I used to run the command

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

InitialSessionState initial = InitialSessionState

.CreateDefault();

initial.ImportPSModule(

 

 

new[] {"abc"

});

 

 

 

// create Powershell runspace

 

 

 

Runspace runspace = RunspaceFactory

.CreateRunspace(initial);

 

 

 

// open it

runspace.Open();

 

 

 

// create a pipeline and feed it the script text

 

 

 

Pipeline

pipeline = runspace.CreatePipeline();

 

 

 

// Create Command to Set Na Option

 

 

 

var access = new Command ("Connect-VIServer -Server 192.168.10.10 -Protocol http -User admin -Password sck9p84");

 

// Add Command to Pipeline

pipeline.Commands.Add(access);

 

 

 

//Execute by invoking

pipeline.Invoke();

 

 

 

// close the runspace

runspace.Close();

}

 

 

 

 

storage usage

$
0
0

I am looking to pull a report into either csv or html preferred.

the metrics i want to report on are the following:

 

VM name: xxxx

Number of disks assigned per vm: xxxx

Total storage assigned in GB per vm: xxxx

Total storage actually consumed per vm: xxxx

Total storage percentage consumed per vm: xxxx

 

any help will be greatly appreciated.

VMware ESX Hardware into an excel file

$
0
0

Hello all,

 

(1) The following instruction Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } will give the following result:

 

Vendor               : Cisco Systems Inc
Model                : N20-B6625-1
Uuid                 : 00000000-0000-0000-0000-10000000002f
OtherIdentifyingInfo :
MemorySize           : 51469164544
CpuModel             : Intel(R) Xeon(R) CPU           E5649  @ 2.53GHz
CpuMhz               : 2526
NumCpuPkgs           : 2
NumCpuCores          : 12
NumCpuThreads        : 24
NumNics              : 2
NumHBAs              : 2
DynamicType          :
DynamicProperty      :

 

(2). The following instruction Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object Vendor, Model, MemorySize, CpuModel, CpuMhz, NumCpuPkgs, NumCpuCores, NumCpuThreads, NumNics, NumHBAs will give the following result:

 

Vendor        : Cisco Systems Inc
Model         : N20-B6625-1
MemorySize    : 51469164544
CpuModel      : Intel(R) Xeon(R) CPU           E5649  @ 2.53GHz
CpuMhz        : 2526
NumCpuPkgs    : 2
NumCpuCores   : 12
NumCpuThreads : 24
NumNics       : 2
NumHBAs       : 2

 

And (3) The following instruction Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object Vendor will give the following result:

 

Vendor
------
HP
HP
HP
HP
Cisco Systems Inc
Cisco Systems Inc
Cisco Systems Inc
Cisco Systems Inc
Cisco Systems Inc
Cisco Systems Inc
Cisco Systems Inc

 

So my question is how do I isolate Vendor from its value so I can insert it into a cell in an excell spreadsheet ?

If I assign it into an array like $array1 = Get-VMHost | Get-View | ForEach-Object { $_.Summary.Hardware } | Select-object Vendor

the contents of array1[0] is Vendor HP

 

Thanks for your help.

vCenter version output...

$
0
0

How do I get the vCenter hostname, version, build number ?

 

Thanks for your help..

Active Snapshots into an array

$
0
0

Hello PowerCLI Gurus,

 

I would like to get the following from a snapshot: vm, name,created,description into an array.

 

If i execute the following $array0 = get-vm | get-snapshot | select-object -property VM

then

$array0[0] equals to


VM
--
VMname

 

I still can't figure it out  how to isolate those two fields.

 

I would like to expect for $array0[0] the value of VMname

 

Again, thanks for your help. You guys rocks and you have been very helpful to me,

Viewing all 16717 articles
Browse latest View live


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