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

need to get sum of all hard didks

$
0
0

how do I modify this to get the total sum of all vmdk/VM?

 

Screen Shot 2017-08-03 at 9.42.24 AM.png


Get-Compliance Report for a List of ESX Hosts in 1 vCenter?

$
0
0

So i have a command that works below individually. I want this to work for a list of hosts. How can i do this?

 

$vCenter = "VCENTERNAMEHERE" # vCenter FQDN

# Connect to vCenter

Connect-VIServer -Server $vCenter -User "USER" -Password "PASSWORD"

Get-Inventory -Name ESXHOSTNAMEHERE | Scan-Inventory -UpdateType HostPatch

$ESXhost = get-vmhost ESXHOSTNAMEHERE

$compliance = Get-Compliance -Entity $ESXhost -Detailed

$compliance.NotCompliantPatches | Select-Object Name,IDByVendor,Description,@{n='Product';e={$_.product | Select-Object -expandproperty Version}},ReleaseDate |

Export-Csv "C:\FOLDER\vCenterPatchReport.csv" -NoTypeInformation -UseCulture

NIC/VMTool/Hardware Detail Along With OS Version

$
0
0

please help me with the script to put the required info.

Run the below command but couldn't't join the OS version with NIC Version.

 

$vms=Get-View -ViewType VirtualMachine

$(

foreach($vm in $vms){

$networkcards=$vm.guest.net | ?{$_.DeviceConfigId -ne -1}

""|select  @{n="VM name";e={$vm.name}},@{n="uuid";e={$vm.config.uuid}},

@{n="Net_info";e={[string]::join(',',  $($networkcards|%{$devid=$_.DeviceConfigId;[string]::join

(',',$(($vm.config.hardware.device|?{$_.key  -eq $devid}).gettype().name,$_.network,($_.ipaddress -join ';'),

$_.Macaddress))})  )}}

}  Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") |

Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}},  @{N="Running OS";

E={$_.Guest.GuestFullName}}

)

Add disk on a specific virtual device node while the VM is online

$
0
0

Hi all,

 

Is it possible to add a new vHDD on a specific virtual device node e.g. (0:z) while the VM is online?

When creating a new disk with "New-HardDisk" I have no parameter for that. The disk is just added to the next free virtual device node on the SCSI controller:

 

New-HardDisk -VM $node -CapacityGB 2 -StorageFormat thin -Controller "SCSI-Controller 0"

 

If the VM is off, I can do it with "ExtensionData.ReconfigVM_Task" and the new specification, but I need it while the VM is online.

 

Thanks,

Sepp

AD group rename has to be applied in vCenter permission

$
0
0

Hello All,

Have an AD group called Test. With that group name in vCenter at Datacenter, folders, cluster and datastore permissions are provided.

Lets say now AD team is renaming the Test group name to Test1 group name.

Let me know any scripts to apply the new group name(Test1) inplace of old name(Test) where the permission applied.

Thanks in adavce,

Updating when there are dependencies between VMs

$
0
0

Hello,

 

I'm looking for a way to upgrade the hosts in a non-HA cluster where each host has a single VM and the VMs are dependent on the rest of the VMs in the cluster, such that only a single VM (i.e. host) can be down at a time. The VMs are part of a HA product that can't be failed over at the vmware level because each VM has persisted data that is required to maintain proper functionality (like a vSAN cluster). We need to update hosts sequentially (again, like a vSAN cluster) and after a VM comes up, we need some amount of time before the next host can be taken down. Is there an API (or a way to invoke a script that we supply) that would allow the hosts (or VUM) to query the VMs and see if they're "ready" to be taken down?

 

Thanks,

Kevin

PowerCli .NET and Connection status

$
0
0

Dear,

i'm using VMWare.Vim library for .NET application,  to inspect my hypervisor. Usually i start a request with Connect() method,querying items and Disconnect(), and all works. 

I would like to avoid Connect/Disconnect every time to improve performance but i notes there's no property o method to check if connection is alive (just for example the  network fall down).

So I would like to know if is there a suggestion to check connection status or if i must connect/disconnect every time.

Thanks

Guide for the script need to take clone on every day per schedule time

$
0
0

Hi All,

Guide for me the script need to take the virtual machine clone on every day per schedule time.
Conditions:

1) Its need to be delete the previous day backup and name format it should be standard so that it could be auto delete the last day clone. 

2) Also the clone will be choose data store automatically which having enough disk space.

3) After completing the clone auto generated email needs to be sent. if the clone is not success failure message also need to forward.

4) we need to exclude some data store with condition filter.

 

Thank in advance!!


VMware vSphere PowerCLI 6.0 Release 1 build 2548067 - Get-PowerCLIVersion fails

$
0
0

Just installed the 6.0 version of powercli

 

If I launch PowerCLI as administator (i.e. elevated permissions) all is fine (x64 and x32)

 

If I launch PowerCLI as default user (i.e. Not elevated permissions) not all the modules load

 

"

 

Get-PowerCLIVersion : The term 'Get-PowerCLIVersion' is not recognized as the name of a cmdlet,

 

function, script file, or operable program. Check the spelling of the name, or if a path was

 

included, verify that the path is correct and try again.

 

At C:\Program Files (x86)\VMware\Infrastructure\vSphere

 

PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1:38 char:12

 

+ $version = Get-PowerCLIVersion

 

+            ~~~~~~~~~~~~~~~~~~~

 

    + CategoryInfo          : ObjectNotFound: (Get-PowerCLIVersion:String) [], CommandNotFoundExce

 

   ption

 

    + FullyQualifiedErrorId : CommandNotFoundException

 

          Welcome to VMware vSphere PowerCLI!

 

Log in to a vCenter Server or ESX host:              Connect-VIServer

To find out what commands are available, type:       Get-VICommand

 

To show searchable help for all PowerCLI commands:   Get-PowerCLIHelp

 

Once you've connected, display all virtual machines: Get-VM

 

If you need more help, visit the PowerCLI community: Get-PowerCLICommunity

 

      

 

Copyright (C) VMware, Inc. All rights reserved.

 

 

but  none of the powercli commands run

 

and get-module show no vmware modules

 

Is this a new feature? needing to run as admin, previous version i didnt need to run elevated

Anyone else have the same issue?

Percentage memory and cpu used

$
0
0

Hello,

I have this script where I can get some info from each VM,

I would like to add:

 

CPU assigned/used

Memory assigned/used

 

 

Get-VM |select Guest,NumCpu,MemoryMB,Host,UsedSpaceGB,ProvisionedSpaceGB,Name|Export-Csv -path “C:\Users\gemela\Hardware_info.csv” -NoTypeInformation

Export and import the Vcenter roles and permission other VC

$
0
0

Hi All,

 

Can i get script for export and import the Vcenter roles and permission other VC ?

 

Thanks,

sankar

Script for Getting the Active alarm list in the VC

$
0
0

Hi All,

 

can i get Script for Getting the Active alarm list in the vcenter ?

 

Thanks,

Sankar R

Get-scsilunpath with VMhost name on output

$
0
0

Dear All,

 

I am still new to PowerCLI. My goal is to find death luns path in all the hosts.

I can use this command  Get-VMHost  | Get-ScsiLun  | Get-scsilunpath | Where {$_.state -eq “Dead”}.This will give me nice the output like this. But No VMhost name.

 

Name                SanID          State          Preferred

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

vmhba.xxx       xx.xx.xx       Dead           True

 

How can I have another column that includes hostname?

 

Thank you!

Max

No snap-in is registered for Windows PowerShell version 5

$
0
0

I have a PC running Windows 10 and I use PowerShell v.5 to connect to a vSphere 5.5 infrastructure.

When I start a PowerShell script that attempts to execute the Add-PSSnapin VMware.VimAutomation.Core command I get an error saying that no snap-in is registered for Windows PowerShell version 5.

How can I solve the problem?

Regards

marius

Baffled, runs interactively, doesn't run in windows task scheduler (win 2012 r2)

$
0
0

baffled....The user executing the task has Logon as a Batch, is a local Administrator.   I'm using the latest download from

 

 

I run this interactively, it works.  I run in a windows task scheduler, zero machines are returned.

 

 

Connect-viserver -server vcenter.ss.local -user user@vsphere.local -password deleteme | out-null

start-sleep -s 10

$vmlist = Get-Folder -Name VRMDeleted | Get-vm

Add-Content -path "e:\temp\log.txt" -value $vmlist.count

foreach($vm in $vmlist)

{

    Try

    {

        Add-Content -path "e:\temp\vm.txt" -value $vm.name

        Remove-VM -DeletePermanently -VM $vm -confirm:$false

    }

    catch

    {

        Add-Content -path "e:\temp\errors.txt" -value $error

    }

}


SRM Reporting using PowerCLI

$
0
0

So, I'm back to this old Chesnutt of trying to get accurate SRM Reports using PowerCLI.

 

I've the following setup

  • Protection Group Name = MyTestPG
  • Protection Group Protection Status in Web Client = Not Configured(this is deliberate for testing, I've attached a .iso)
  • Recovery Plan Name = MyTestRP
  • Recovery Plan Recovery Status in Web Client = Ready

 

Using PowerCLI, I have the following

Connect-VIServer -Server $vcenter -Credential $cred | Out-Null
Connect-SrmServer -Credential $cred -RemoteCredential $cred -OutVariable srm

 

$srmApi = $srm.ExtensionData
$protectionGroups = $srmApi.Protection.ListProtectionGroups()

$testPgName = MyTestPG

 

# To Test 1 PG
$test = $protectionGroups | where {$_.getinfo().name -like $testPgName} | Get-Unique

 

foreach ($item in $test) {
      $item = $_
      $protectionGroupName = $item.GetInfo().name
     $protectionGroupState = $item.GetProtectionState()
      $recoveryPlanName = $item.ListRecoveryPlans().GetInfo().Name
      $recoveryPlanState = $item.ListRecoveryPlans().GetInfo().state
}

 

My issue is that at this point, $ProtectionGroupStatereturns a value of Ready.

This is not what's seen in the Web Client. Why does the Web Client show Not Configured but, the PowerCLI output shows Ready ?

 

Before continuing with the script,, including VM Names, VM Status, outputting results to either .csv / .html. I'd like to correct this issue first.

Failed Import-vapp to dvswitch

$
0
0

Hello all!

I'm trying to automate the import of virtual machines to inventory. But the error is issued when starting Import-Vapp command.

 

Import-VApp -Source $ova -VMHost $vmhost -Datastore $ds -DiskStorageFormat thin -Conirm:$false -Force -OvfConfiguration $ovfconfig

WARNING: "Network 'V25' is not accessible from host with id 'HostSystem-host-30319'."

Import-VApp : 20.06.2016 12:01:37    Import-VApp        Host did not have any virtual network defined.

At line:1 char:1

+ Import-VApp -Source $ova -VMHost $vmhost -Datastore $ds -Di ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [Import-VApp], OvfNoHostNic

    + FullyQualifiedErrorId : Client20_VappServiceImpl_ImportVApp_CreateImportSpecError,VMware.VimAutomation.ViCore.Cm

   dlets.Commands.ImportVApp

 

The problem is that I only used dvswitch

Once I create vswitch - the problem disappears and everything is imported properly.

Mapping the network does not help.

Tell me, is there any way to import without creating vswitch?

Or is there some other method of automatic import the VMs?

Thank you!

Multipathing Policy - Fixed with preferred target - for PowerCLI N00b

$
0
0

Hello,

 

I have been looking for a script to change the Preferred Path Policy to FIXED on about 30+ 5.5 ESXi hosts with about 35 datastores, alternating between the two HBAs on each host.


What I would like is a simple command where I don't have to worry about the complexity of finding variables.  While I realize how powerful PowerCli is, I have not worked with PowerCli.

 

I just want to say something like, "Set preferred path on ESXi1 for naa.datastoreA  to FIXED and -preferred path is on HBA1-Port1".  I have no problem changing these parameters for each command as long as I can run one command after another.

 

Any help would be appreciated, and this would be a great starting place for learning a bit of PowerCli.

 

Thank you!

Horizon View - Convert User ID to English Username

$
0
0

Hello.

I am trying to display the user assigned to a desktop. Horizon View 7.1, PowerCLI 6.5. When I display the desktop details:

 

$hvDesktops[0] | fl *

 

Name                             : XX-YY-ZZZZ

DnsName                          : xx-yy-zzzz.xyz.com

User                             : VMware.Hv.UserOrGroupId

AccessGroup                      : VMware.Hv.AccessGroupId

Desktop                          : VMware.Hv.DesktopId

Session                          : VMware.Hv.SessionId

BasicState                       : CONNECTED

Type                             : MANAGED_VIRTUAL_MACHINE

OperatingSystem                  : Windows 7

AgentVersion                     : 7.1.0

AgentBuildNumber                 : 5170901

RemoteExperienceAgentVersion     :

RemoteExperienceAgentBuildNumber : 29075

 

$hvDesktops[0].User

---

Id

--

UserOrGroup/Uy0xLTUtMjEtMTIyNTE4NzgzNy0zDCD5OTM5NOk5PTIzOTEzNDI1NDktMTIyNTI

 

 

I'm not sure what the contents of the Id field means and how I would go about converting this to an English name or AD account. (I have changed a few digits in the results in case they are sensitive)

Help with Host Profiles and PowerCLI needed

$
0
0

Hello,

 

I have 2 questions on using PowerCLI to edit vSphere Host Profiles:

 

1) How can I clone a host profile, by using PowerCLI ?

 

2) How can I modify Host profiles, by using PowerCLI, to update these settings ?
    a) Networking configuration - DNS configuration - Host name
    b) Authentication configuration - Active Directory configuration - Domain Name

 


Thanks!

 

Regards,
Harold

Viewing all 14549 articles
Browse latest View live


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