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

Trace user actions - retrieve list of tasks that a user has performed

$
0
0

Our centers are running version 6.5 - how can I query the list of tasks a user (domain\user name) has carried out on a specific date (on any VM in that center).

 

It is mostly to do with snapshot and power off/on operations but could be on any VM in that center.

 

I need something like: date and time, task, username...

 

Thanks


Check vSphere HA settings on Multiple Host clusters : PowerCLI Script

$
0
0

Hello All;

 

could anyone guide  me on creating a script to check High Availability configuration on multiple clusters,  especially , Host Monitoring , Host failure response,admission control, Heartbeat Datastore configuration etc, i could not find any commandlets in powercli which can show these configuration

 

appreciate  your response ..

thanks

jooshil

Installing EXSI 6.7 has come across the problem of No Network Adapters. My Network card is RTL8111F.I need to be able to manually import their own network card driver tools

$
0
0

I used the esxi-customizer tool, but it gave me an error.The log information is as follows:

[2019/03/14 周四  9:09:02.43] This is ESXi-Customizer v2.7.2 ...

[2019/03/14 周四  9:09:02.44] Called with parameters:

[2019/03/14 周四  9:09:02.44] ... sISO             = "F:\VMware-VMvisor-Installer-6.7.0.update01-10302608.x86_64.iso"

[2019/03/14 周四  9:09:02.44] ... fOEM             = "F:\net55-r8168-8.045a-napi-offline_bundle.zip"

[2019/03/14 周四  9:09:02.44] ... wDir             = "G:"

[2019/03/14 周四  9:09:02.44] ... repackOpt        = "1"

[2019/03/14 周四  9:09:02.44] ... enableUEFI       = "1"

[2019/03/14 周四  9:09:02.46] ... updateCheck      = "0"

[2019/03/14 周四  9:09:02.46] Creating the temp-directory "G:\esxicust.tmp" ...

[2019/03/14 周四  9:09:02.46] Run: mkdir "G:\esxicust.tmp"

[2019/03/14 周四  9:09:02.47] Extracting the source ISO ...

[2019/03/14 周四  9:09:02.47] Run: "F:\ESXi-Customizer-v2.7.2\tools\7zip\7z.exe" x -y -o"G:\esxicust.tmp\iso" "F:\VMware-VMvisor-Installer-6.7.0.update01-10302608.x86_64.iso"

 

 

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

 

 

Processing archive: F:\VMware-VMvisor-Installer-6.7.0.update01-10302608.x86_64.iso

 

 

Extracting  .DISCINFO

Extracting  ATA_LIBA.V00

Extracting  ATA_PATA.V00

Extracting  ATA_PATA.V01

Extracting  ATA_PATA.V02

Extracting  ATA_PATA.V03

Extracting  ATA_PATA.V04

Extracting  ATA_PATA.V05

Extracting  ATA_PATA.V06

Extracting  ATA_PATA.V07

Extracting  B.B00

Extracting  BLOCK_CC.V00

Extracting  BNXTNET.V00

Extracting  BNXTROCE.V00

Extracting  BOOT.CAT

Extracting  BOOT.CFG

Extracting  BRCMFCOE.V00

Extracting  BTLDR.T00

Extracting  CHARDEVS.B00

Extracting  CHAR_RAN.V00

Extracting  EFI

Extracting  EFI\BOOT

Extracting  EFI\BOOT\BOOT.CFG

Extracting  EFI\BOOT\BOOTIA32.EFI

Extracting  EFI\BOOT\BOOTX64.EFI

Extracting  EFIBOOT.IMG

Extracting  EHCI_EHC.V00

Extracting  ELXISCSI.V00

Extracting  ELXNET.V00

Extracting  ELX_ESX_.V00

Extracting  ESXUPDT.V00

Extracting  ESX_DVFI.V00

Extracting  ESX_UI.V00

Extracting  FEATURES.GZ

Extracting  HID_HID.V00

Extracting  I40EN.V00

Extracting  IAVMD.V00

Extracting  IGBN.V00

Extracting  IMA_QLA4.V00

Extracting  IMGDB.TGZ

Extracting  IMGPAYLD.TGZ

Extracting  IPMI_IPM.V00

Extracting  IPMI_IPM.V01

Extracting  IPMI_IPM.V02

Extracting  ISER.V00

Extracting  ISOLINUX.BIN

Extracting  ISOLINUX.CFG

Extracting  IXGBEN.V00

Extracting  JUMPSTRT.GZ

Extracting  K.B00

Extracting  LPFC.V00

Extracting  LPNIC.V00

Extracting  LSI_MR3.V00

Extracting  LSI_MSGP.V00

Extracting  LSI_MSGP.V01

Extracting  LSI_MSGP.V02

Extracting  LSU_HP_H.V00

Extracting  LSU_INTE.V00

Extracting  LSU_LSI_.V00

Extracting  LSU_LSI_.V01

Extracting  LSU_LSI_.V02

Extracting  LSU_LSI_.V03

Extracting  LSU_SMAR.V00

Extracting  MBOOT.C32

Extracting  MENU.C32

Extracting  MISC_CNI.V00

Extracting  MISC_DRI.V00

Extracting  MTIP32XX.V00

Extracting  NATIVE_M.V00

Extracting  NE1000.V00

Extracting  NENIC.V00

Extracting  NET_BNX2.V00

Extracting  NET_BNX2.V01

Extracting  NET_CDC_.V00

Extracting  NET_CNIC.V00

Extracting  NET_E100.V00

Extracting  NET_E100.V01

Extracting  NET_ENIC.V00

Extracting  NET_FCOE.V00

Extracting  NET_FORC.V00

Extracting  NET_IGB.V00

Extracting  NET_IXGB.V00

Extracting  NET_LIBF.V00

Extracting  NET_MLX4.V00

Extracting  NET_MLX4.V01

Extracting  NET_NX_N.V00

Extracting  NET_TG3.V00

Extracting  NET_USBN.V00

Extracting  NET_VMXN.V00

Extracting  NFNIC.V00

Extracting  NHPSA.V00

Extracting  NMLX4_CO.V00

Extracting  NMLX4_EN.V00

Extracting  NMLX4_RD.V00

Extracting  NMLX5_CO.V00

Extracting  NMLX5_RD.V00

Extracting  NTG3.V00

Extracting  NVME.V00

Extracting  NVMXNET3.V00

Extracting  NVMXNET3.V01

Extracting  OHCI_USB.V00

Extracting  PROCFS.B00

Extracting  PVSCSI.V00

Extracting  QCNIC.V00

Extracting  QEDENTV.V00

Extracting  QFLE3.V00

Extracting  QFLE3F.V00

Extracting  QFLE3I.V00

Extracting  QFLGE.V00

Extracting  QLNATIVE.V00

Extracting  RSTE.V00

Extracting  S.V00

Extracting  SAFEBOOT.C32

Extracting  SATA_AHC.V00

Extracting  SATA_ATA.V00

Extracting  SATA_SAT.V00

Extracting  SATA_SAT.V01

Extracting  SATA_SAT.V02

Extracting  SATA_SAT.V03

Extracting  SATA_SAT.V04

Extracting  SB.V00

Extracting  SCSI_AAC.V00

Extracting  SCSI_ADP.V00

Extracting  SCSI_AIC.V00

Extracting  SCSI_BNX.V00

Extracting  SCSI_BNX.V01

Extracting  SCSI_FNI.V00

Extracting  SCSI_HPS.V00

Extracting  SCSI_IPS.V00

Extracting  SCSI_ISC.V00

Extracting  SCSI_LIB.V00

Extracting  SCSI_MEG.V00

Extracting  SCSI_MEG.V01

Extracting  SCSI_MEG.V02

Extracting  SCSI_MPT.V00

Extracting  SCSI_MPT.V01

Extracting  SCSI_MPT.V02

Extracting  SCSI_QLA.V00

Extracting  SHIM_ISC.V00

Extracting  SHIM_ISC.V01

Extracting  SHIM_LIB.V00

Extracting  SHIM_LIB.V01

Extracting  SHIM_LIB.V02

Extracting  SHIM_LIB.V03

Extracting  SHIM_LIB.V04

Extracting  SHIM_LIB.V05

Extracting  SHIM_VMK.V00

Extracting  SHIM_VMK.V01

Extracting  SHIM_VMK.V02

Extracting  SMARTPQI.V00

Extracting  TOOLS.T00

Extracting  UC_AMD.B00

Extracting  UC_HYGON.B00

Extracting  UC_INTEL.B00

Extracting  UHCI_USB.V00

Extracting  UPGRADE

Extracting  UPGRADE\ESXIMAGE.ZIP

Extracting  UPGRADE\EXTLINUX

Extracting  UPGRADE\ISOINFO

Extracting  UPGRADE\MBR.BIN

Extracting  UPGRADE\MCOPY

Extracting  UPGRADE\METADATA.XML

Extracting  UPGRADE\METADATA.ZIP

Extracting  UPGRADE\PRECHECK.PY

Extracting  UPGRADE\PREP.PY

Extracting  UPGRADE\PROFILE.XML

Extracting  USBCORE_.V00

Extracting  USB_STOR.V00

Extracting  USER.B00

Extracting  USEROPTS.GZ

Extracting  VIM.V00

Extracting  VMKATA.V00

Extracting  VMKFCOE.V00

Extracting  VMKPLEXE.V00

Extracting  VMKUSB.V00

Extracting  VMWARE-ESX-BASE-OSL.TXT

Extracting  VMWARE-ESX-BASE-README

Extracting  VMWARE_E.V00

Extracting  VMW_AHCI.V00

Extracting  VMX.V00

Extracting  VSAN.V00

Extracting  VSANHEAL.V00

Extracting  VSANMGMT.V00

Extracting  WEASELIN.T00

Extracting  XHCI_XHC.V00

Extracting  XORG.V00

Extracting  [BOOT]\Bootable_NoEmulation.img

 

 

Everything is Ok

 

 

Folders: 3

Files: 184

Size:       329346510

Compressed: 329611264

[2019/03/14 周四  9:09:09.35] Checking media type ...

[2019/03/14 周四  9:09:09.35] --- INFO: This looks like an ESXi 5.x installation media.

[2019/03/14 周四  9:09:09.37] ---       No admin rights needed to customize ESXi 5.x. Continuing ...

[2019/03/14 周四  9:09:09.37] Removing old boot.cat from ISO directory. It will be created by mksiofs ...

[2019/03/14 周四  9:09:09.38] Run: del /f /q "G:\esxicust.tmp\iso\boot.cat"

[2019/03/14 周四  9:09:09.38] Removing [BOOT] directory from ISO directory ...

[2019/03/14 周四  9:09:09.38] Run: rmdir /s /q "G:\esxicust.tmp\iso\[BOOT]"

[2019/03/14 周四  9:09:09.40] Selected customization type is .zip.

[2019/03/14 周四  9:09:09.40] Unpacking the IMGDB.TGZ file ...

[2019/03/14 周四  9:09:09.40] Run: "F:\ESXi-Customizer-v2.7.2\tools\7zip\7z.exe" x -y -o"G:\esxicust.tmp" "G:\esxicust.tmp\iso\IMGDB.TGZ"

 

 

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

 

 

Processing archive: G:\esxicust.tmp\iso\IMGDB.TGZ

 

 

Extracting  <fdopen>

 

 

Everything is Ok

 

 

Size:       1792000

Compressed: 227919

[2019/03/14 周四  9:09:09.45] Run: "F:\ESXi-Customizer-v2.7.2\tools\7zip\7z.exe" x -y -o"G:\esxicust.tmp\imgdb" "G:\esxicust.tmp\IMGDB.tar"

 

 

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

 

 

 

 

Error:

cannot find archive

[2019/03/14 周四  9:09:09.46] !-----------------------------------------------------------------------------------

[2019/03/14 周四  9:09:09.46] !-- FATAL ERROR: Error un-taring IMGDB.tar!

[2019/03/14 周四  9:09:09.48] !-----------------------------------------------------------------------------------

[2019/03/14 周四  9:09:09.48] Run: "F:\ESXi-Customizer-v2.7.2\tools\MsgBox.exe" 266260 "FATAL ERROR:&n   Error un-taring IMGDB.tar!&n&nSee log file 'G:\ESXi-Customizer.log' for details! Do you want to open the log file in notepad now?"

[2019/03/14 周四  9:09:18.60] Cleaning up ...

[2019/03/14 周四  9:09:18.62] Run: rmdir /s /q "G:\esxicust.tmp"

[2019/03/14 周四  9:09:18.70] This is the end.

Start VM within a cluster

$
0
0

I am using power cli VMware vSphere 6.7 and i am tring to start VM which is inside a cluster.

If i am entring "Get-VM" command i get the VM`s list properly, But when im tring "Start-VM -VM VM02 -Confirm" i get "Start-VM : 10/2/2018 4:57:04 PM Start-VM                Exception has been thrown by the target of an invocation.

At line:1 char:1

+ Start-VM -VM VM02 -Confirm

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

    + CategoryInfo          : NotSpecified: (:) [Start-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.StartVM"

Start-VM : 10/2/2018 4:57:04 PM Start-VM                Exception has been thrown by the target of an invocation.
At line:1 char:1
+ Start-VM -VM VM02 -Confirm
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Start-VM], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.StartVM

Powershell script run to long after migration from Powercli 6.5.4 to Powercli 11

$
0
0

Hi Community

 

My script run to long after changing PowerCLI 6.5.4 to Powercli 11.

 

I applied some recommandations found in internet but I'm not really satisfied.

 

My system is Windows 2016, 4 CPU's , 8GB

 

I changed scheduled Task Priority from 7 to 4

I control the PowerCLIConfiguration:

Scope    ProxyPolicy     DefaultVIServerMode InvalidCertificateAction  DisplayDeprecationWarnings WebOperationTimeout

                                                                                                  Seconds           

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

Session  NoProxy         Multiple            Ignore                    True                       300               

User     NoProxy         Multiple            Ignore                                                                 

AllUsers NoProxy

 

An exemple of running time:

Priority 7Priority 4
PowerCLI_6547mn7mn
Powercli_1136mn17mn

 

With PowerCLI_11 raise now in Windows an Event 10016

 

Can someone help to correct this issue?

Thanks for suggestions.

 

Regards

Denis

Get List of VMs, Datastores and Folder name per Cluster

$
0
0


Hello!!  I'm hoping someone can assist me with a PowerCLI script that can pull the subject info into a txt or csv file.  In an effort to get our environment cleaned up before our next DR exercise with SRM, I want to get a list that shows each VM, the datastore(s) it resides on, and the Folder name within VMs and Templates view.  We keep our VMs organized by creating folder names that correspond to the app running on the VM.  I mention SRM because last year our Protected Groups matched the Rcopy groups from our 3PAR array.  However, we've added over 200 new VMs since that time and my team members basically placed these new VMs on the first available datastore that had enough free space.  Unfortunately, we're not utilizing Storage Profiles...it's scheduled for next year.

 

The extracted info would look similiar to the following:

 

Servername    Datastore   Folder Name

Server1            LUN0           ActiveDirectory

Server2            LUN0           ActiveDirectory

Server3            LUN1           ActiveDirectory

Server4            LUN3           Argo

Server5            LUN7           Argo

Server6            LUN6           Lockbox

Server7            LUN5           Lockbox

Server8            LUN9           Citrix

etc...

 

Any help with extracting this info from vCenter would be greatly appreciated.

 

Thanks,

Charles

Detecting a VM starting to perform a Guest Shutdown

$
0
0

What is the earliest point in the shutdown process a PowerCLI script could detect that a Guest has initiated a controlled shutdown?

 

I'm asking because I am looking at a system where tight IOPS limits are applied to all VMs. Don't ask, it is simply a requirement we have to meet. Some of these are VERY low, which seriously hampers the VM startup and shutdown processes.

 

Startup is a trivial thing to deal with:

 

When VMs are off, have the IOPS limits unset. When a VM starts, apply the IOPS limits, when VMTools reports the guest is running, with perhaps an additional time delay to allow a limit headroom. Or more simply, apply the limits a set time after VM power-on.

 

The tricky one is when a VM is shutting down. If the process is initiated from within the guest, I would like to be able to detect this has happened and remove the IOPS limits, so the VM can shutdown swiftly, and be in the correct state for the next power-on.

 

Any ideas out there?

how to change "display name" via PowerCLI command?

$
0
0

Hi, guys,

I have a question:

Vcenter----->home---->inventory--->host and Clusters, I select an ESX host and ------->configuration----->storage adapter, we can see many LUNs from storage.

1.jpg

We usually right click the "Name" to change the name to match with what we see in stroage side.

file:///E:/1.jpg

 

now we present 90 LUNs to this ESX cluster.

 

I am wondering if there is any command we can change the device name?

 

I tried get-ScsiLun.....and I can get the HLU, but there is no "Name" in the outpur.........

 

would you help please point the right command?

 

many thanks in advance!


exclude list

$
0
0

Hi - Looking to do a query against all my datastores to find out what is at 90% used space but exclude a list of datastores from the output. I can't seem to get the content read in to exclude  my list and not sure what I am doing wrong. It seems like it should be a fairly easy script - any help is appreciated.

 

 

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

#powershell script to output the datastores that over over 90%used

 

#add datastores to be excluded

$exceptiondatastores = Get-Content C:\exceptiondatastores.txt <<this file contains a list of datastores as well as * at the end for wildcard

 

Get-Datastore |

Select Name, @{N='UsedPerc';E={($_.CapacityGB - $_.FreeSpaceGB)/$_.CapacityGB}} |

where{$_.'UsedPerc' -ge 0.90  -and $_.Name -notmatch $exceptiondatastores} |

Select Name -expandproperty Name |Sort-Object -Property Name |

out-file  C:\diskusage90.txt

 

Disconnect-VIServer -Server xxxx -Confirm:$false

 

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

script_powercli_renaming distributed port groups

$
0
0

Hi Luc,

 

can you check folowingscript  orange part .

1:i need to exclude one vm in $vms and store in $vms_supported can we use exclude switch

2:i need to rename distributed portgroups by replacing abc by xyz is this correct what i mentioned in second orange part.

 

$source_side=read-host "specify cluster"

$cluster_source=get-cluster $source_side

$vms=get-vm -Location $cluster_source

$vms_supported=.....

foreach($vm in $vms_supported)

{

 

$vm.name

 

 

 

}

 

 

 

$des_cluster=get-cluster -name cluster2

$grb_distributedswitch=Get-VirtualSwitch -Distributed -Datacenter dc2

$port_groups_grbs=Get-VirtualPortGroup -Distributed -VirtualSwitch $dc2_distributedswitch

$pgdc2=$port_groups_dc2|select name

foreach($pg in $pgdc2)

{

$new_name=$pg.replace("abc","xyz")

Set-VirtualPortGroup -VirtualPortGroup $pg -name $new_name -WhatIf

 

 

 

}

Powershell noun pre-fix conflict

$
0
0

Looks like vmware chose not to use a unique noun prefix, is there an easy way to add, lets say 'VS' (for vsphere), as a prefix when installing your module?  Also where can i submit a bug report to get you folks to make this change default?

 

Edit: found the answer to my first question `Import-Module -Prefix` (but is this respected by the module?)

 

edit2: this still breaks the hyper-v cmdlets

 

edit3: Does the powercli module not respect the -prefix flag when importing the module?

Horizon View and PowerCLI

$
0
0

Hello everyone.

 

I'm a relatively new coder to the VM PowerCli enviornment.

And I am trying to code for automation the creation of a desktop pool and incorporate it into a Global Desktop Entitlement.

 

The pool, will be created from a virtual machine hosted in vSphere, and has GRID enabled.

 

Now, I do know the key to enable renderer3D, and what the value should be.

But, my problem comes along when trying to add this pool to a Global Entitlement.

I'm getting error thrown out that there is a mismatch with the with the 3D rendering setting between the desktop pool and the global entitlement.

 

Up until now, I have been using the lmvutil command, which is very clunky to use and very limited.

I'm trying to find a way to do this through PowerCLI without having to invoke lmvutil.

 

I know that I can get the Global Entitlement ID with the Get-HVPool cmdlet, and what it returns is not practical to use.

So I was hoping there was something similar for global entitlements, but I'm not seeing anything.

 

Hoping someone can point me in the right direction.

 

Thanks.

 

Update:

OK, so I was testing a PowerShell script that creates a manual desktop pool from a virtual machine on our vCenter and creates a Global Desktop Entitlement, and assigns a user to that as well as the newly created desktop pool.

The virtual machine does have the NVIDIA GRID GPU enabled.

When I run my script, it throws the following error:

 

Exception calling "Desktop_Create" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidArgument

ErrorMessage : Machine Machine/NzA2ZjhkYWQtYWU2NC00Yjk4LTkxOGEtZjA1ODg1NGY0NTNj/VW5hc3NpZ25lZFZpcnR1YWxNYWNoaW5l/M2VkYzk3NTctZDcwNS00MWViLWJhODEtN2FlNT

E3ZGYyMDRi/L0RDMSAoQ2xpZnRvbiwgTkopL3ZtL1dvcmtzdGF0aW9ucy9Vc2VyL0lTL05ldE9wcy9NT05HRUxMUDAxREMx/dm0tMjU1 requires GRID, but the desktop is not enabledto support it

ParameterName : manualDesktopSpec.machines"

At C:\Users\*********\Documents\WindowsPowerShell\Modules\VMware.Hv.Helper\VMware.HV.Helper.psm1:3403 char:5

+     $desktop_helper.Desktop_create($services,$desktopSpecObj)

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

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

 

Now, I see that it is coming from the the New-HVPool cmdlet from the module.

And the reason, because it is not enabled on the desktop, but it is.

So I am not sure where it is looking to determine if GRID is enabled on the desktop.

 

Through the GUI, on the Horizon Connection server everything works fine.

 

Thanks again.

Importing VM Tags from CSV file

$
0
0

I've been struggling to complete a massive import task of assigning upwards of a dozen categories of tags to a few thousand VMs.

I've started by using Alan Renouf's code to begin the process but I'm only successful at importing one or two categories before the script unexpectedly ends. Anyone else have suggestions?

adding datastore_cluster_powercli

$
0
0

Hi Luc ,

 

i have 6 datastores that i need to add to a cluster of 6 esxi hosts.

 

are following two commands sufficient to add  VMFS_Datastore_1’ to enitrecluster .

 

New-Datastore -VMHost "esxi1" -Name ‘VMFS_Datastore_1’ -Path naa.60000xxxxxxxxxxxxxxxxx36 -vmfs

 

 

and then rescan all esxi in cluster to get vmfs_datastore_1 mounted to all 6 esxi in cluster

Get-Cluster -name “YourClusterName” | Get-VMhost | Get-VMHostStorage –RescanAllHBA

 

How To get the CPU, Memory and HDD Size from Power Off VMs ?

$
0
0

How To get the CPU, Memory and HDD Size from Power Off VMs ?

 

Thanks

Madhu


Running Invoke-VMScript With Multiple Credentials

$
0
0

Is it possible to run Invoke-VMScript with a list of credentials to try?  I have a script I'd like to run on all VMs in the vCenter, but we have a few VMs that are in our DMZ and therefore have different credentials.

 

I know this won't work since I can only specify the parameter once, but conceptually, something like this?

 

$DomainCreds = Get-Credential
$DMZCreds = Get-Credential

Invoke-VMScript -VM "TestVM" -ScriptText {sample script} -GuestCredential $DomainCreds -GuestCredential $DMZCreds

PowerCLI to shutdown vms , put host to maintenance mode and power off hosts in a vSAN 6.7 cluster.

$
0
0

Hello,

 

Checking if anyone can help with a PowerCLI script to shutdown vms , put host to maintenance mode and power off hosts in a vSAN 6.7 cluster. also perfrom the reverse actions once host is powered back up. I have some codes , but its not serving the purpose.

SRM Environment variables in scripts

$
0
0

I am having issues running the SRM environment variables such as :

 

VMware_RecoveryMode and VMware_VC_Host.

 

I want to know how to apply these to scripts like in a if and else statements.

 

So if i pass the variable via echo and run it in a step in a recovery plan it works so the script is called testrun :

 

echo %VMware_RecoveryMode% >> D:\scripts\MES\logs\logfile.log

 

and so when i add a step in the recovery step to the location of this script like :

 

C:\Windows\System32\cmd.exe /c d:\scripts\MES\Testrun.bat

 

It runs fine when i run a test as it outputs test in the log fils.

 

But now when i run this variable in a script with the if and else statements when doing a test recovery it does not work.  So an example of the script is :

 

If "%VMware_RecoveryMode%==test"

echo %VMware_RecoveryMode% >> D:\scripts\MES\logs\logfile.log

 

This fails in a recovery plan.   I have tried various combinations of if syntax with quotation marks, brackets, and then commands, but it keeps failing.

 

Has anyone used these variables in scripts and made it to work, can anyone send a sample of a working script.

 

Thanks

Need network stats from 2 host vmnics on every host in cluster

$
0
0

Hi

 

I have an older ibm chassis that has a 10 gb backplane that has traffic split between virtual nics. The split is 80% and 10% and 10%, in the hosts I'm trying to get networks stats from vmnic 6 and vmnic 7 to see if they hit 1GB limit at any point. I can't seem to find the best way to do this, has anyone tried anything similar?

register vms to inventory_powercli

$
0
0

Hi Luc,

 

I got following from your blog .couldyou please suggest if   orange code will loop to all datastores as i see resultof one datastore only .

this question to related to get registered count from all datastores.

 

$Cluster = "MyCluster"

$Datastores = "MyDS"

$VMFolder = "MyFolder"

$ESXHost = Get-Cluster $Cluster | Get-VMHost | get-random

foreach($Datastore in Get-Datastore $Datastores) {

# Collect .vmx paths of registered VMs on the datastore

$registered = @{}

Get-VM -Datastore $Datastore | %{$_.Extensiondata.LayoutEx.File | where {$_.Name -like "*.vmx"} | %{$registered.Add($_.Name,$true)}}

# Set up Search for .VMX Files in Datastore

New-PSDrive -Name TgtDS -Location $Datastore -PSProvider VimDatastore -Root '\' | Out-Null

$unregistered = @(Get-ChildItem -Path TgtDS: -Recurse | `

where {$_.FolderPath -notmatch ".snapshot" -and $_.Name -like "*.vmx" -and !$registered.ContainsKey($_.Name)})

Remove-PSDrive -Name TgtDS

#Register all .vmx Files as VMs on the datastore

foreach($VMXFile in $unregistered) {

New-VM -VMFilePath $VMXFile.DatastoreFullPath -VMHost $ESXHost -Location $VMFolder -RunAsync

}

}

 

do we need to write like below to get correct registered vms from all datastore

 

$Cluster = "cluster1"

$Datastores = Get-Datastore -RelatedObject $cluster

#$VMFolder = "MyFolder"

$ESXHost = Get-Cluster $Cluster | Get-VMHost | get-random

 

$fragments = @()

foreach($Datastore in $Datastores)

{

 

$vms_registered=Get-VM -Datastore $Datastore | %{$_.Extensiondata.LayoutEx.File | where {$_.Name -like "*.vmx"}}

$fragments += $vms_registered

}

 

 

 

$fragments.count

Viewing all 14549 articles
Browse latest View live


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