powercli

How to send notification mail via powershell

百般思念 提交于 2020-06-17 09:44:39
问题 I want to send notification mail after vm deploy like below. My question is : 1 - If DOMAIN field 'Y' then TRUE else will WORKGROUP 2- IF BACKUP IP field 'N' then it will "not defined" 3- Lastly , I have $diskSizes variable. A VM have one or more disks. $diskSizes[0 -> Hard disk 2] , $diskSizes[1 -> Hard disk 3] and so on. My script: $VCServer = Read-Host "Enter the vCenter server name" Import-Csv -Path C:\temp\vmdeploy.csv -UseCulture -PipelineVariable row | ForEach-Object -Process { New-Vm

How to recursively enumerate through properties of object?

流过昼夜 提交于 2020-05-12 13:48:09
问题 I've started rewriting my VMware daily report to use Get-View, rather than the related PowerCLI commands wherever possible, for performance reasons. One minor inconvenience with this is that the view objects returned often have many properties, many of which are objects themselves. Some properties are nested four or more levels deep. So I'm trying to create a function which will output all properties of an object, along with the full path to that property. This could then be piped to Where

How to recursively enumerate through properties of object?

微笑、不失礼 提交于 2020-05-12 13:44:31
问题 I've started rewriting my VMware daily report to use Get-View, rather than the related PowerCLI commands wherever possible, for performance reasons. One minor inconvenience with this is that the view objects returned often have many properties, many of which are objects themselves. Some properties are nested four or more levels deep. So I'm trying to create a function which will output all properties of an object, along with the full path to that property. This could then be piped to Where

Getting an error with Connect-NsxServer with powershell PowerNSX module

偶尔善良 提交于 2020-03-03 07:41:32
问题 after running this command $cred = get-credential Connect-NsxServer -vCenterServer MyVsphereServer -Credential $cred I get this error Connection to NSX server 10.X.X.X failed : Invoke-NsxRestMethod : The NSX API response received indicates a failure. 403 : Forbidden : Response Body: At C:\Program Files\WindowsPowerShell\Modules\PowerNSX\3.0.1174\PowerNSX.psm1:4939 char:13 + Throw "Connection to NSX server $NsxServer failed : $_" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +

Getting an error with Connect-NsxServer with powershell PowerNSX module

我是研究僧i 提交于 2020-03-03 07:41:06
问题 after running this command $cred = get-credential Connect-NsxServer -vCenterServer MyVsphereServer -Credential $cred I get this error Connection to NSX server 10.X.X.X failed : Invoke-NsxRestMethod : The NSX API response received indicates a failure. 403 : Forbidden : Response Body: At C:\Program Files\WindowsPowerShell\Modules\PowerNSX\3.0.1174\PowerNSX.psm1:4939 char:13 + Throw "Connection to NSX server $NsxServer failed : $_" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +

clone vm change network identity

社会主义新天地 提交于 2020-01-06 14:08:32
问题 I'm trying to script (powershell/powercli) the cloning of our QA environment (261 servers). Basically I want to make a new copy of each server just changing the VM name, the hostname, and the IP address. Ideally I'd want the new clone on the domain (90% of them are Windows OS). And many of my servers have many large hard drives that won't all fit on one datastore so I have to be able to clone to multiple datastores. I started off with New-VM for the servers that were small enough to fit on

PowerShell/CLI: “Foreach” loop with multiple arrays

余生长醉 提交于 2020-01-03 10:44:50
问题 I have a PowerCLI script that powers off a VM, changes its memory and cpu, and then powers it back on. I've adapted the script to utilize variables. This all works perfectly. I'm now trying to modify the script to utilize arrays, in order to cycle through numerous VMs. The script portions that powers off and powers on the VMs works perfectly. The trouble I'm having is using variables from two arrays in a foreach loop. For each VM in $vm_name, I need to set the corresponding amount of memory

Scripting using powerCLI Scripts

ⅰ亾dé卋堺 提交于 2019-12-31 07:28:22
问题 Is it possible to do scripting using powerCLI scripts to automate VM creation using notepad? or any powerCLI developing tool? How to go about studying PowerCLI scripting from scratch to automate VM creation? 回答1: More or less two months ago, I started learning powershell because the needing of using PowerCLI :). PowerCLI is the best choice for scripting vmware vsphere automation. When you start PowerCLI command line tool you can work there exactly as you were inside the powershell.

Distributing RDMs across SCSI controllers when adding hard disks via PowerCLI

∥☆過路亽.° 提交于 2019-12-25 11:33:07
问题 I have an issue that has me stumped and I can't figure out how to work around it. Here is my dilemma...I am testing a storage array. For each test, I create a set of volumes and them present them to my ESXi hosts. Each host has 2 to 4 VMs and each VM needs 4 to 8 RDMs attached. I have written a script to attach the RDMs and it works just fine with 4 RDMs. Here is the problem...when mapping 8 RDMs, I need the devices evenly distributed across the virtual SCSI adapters. Ideally I would like the

So what is special about Powershell PSC1 files?

偶尔善良 提交于 2019-12-22 10:11:37
问题 On my PowerShell shortcut I have the following: C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\"" Yet, I would prefer to add the registration of snapins and to run the init of the PowerCLI environment to my profile. So in my profile I add the following: Add-PSSnapin VMware.VimAutomation