684 Commits

Author SHA1 Message Date
lyuboasenov
062749868d Add PAIF-N automation example (#629)
* Adding PAIF-N demo scripts

* Removing Confidential from headers

* Addressing review comments

---------

Co-authored-by: Lyuboslav Asenov <lasenov@vmware.com>
2024-03-28 15:50:45 +02:00
kamennikolov
9055bf72f3 Merge pull request #625 from desrosim232/master
Patch for Set-HVApplicationIcon
2023-11-24 15:58:36 +02:00
desrosim232
e02efdec9e Merge pull request #2 from desrosim232/patch-Set-HVApplicationIcon
Patch set hv application icon
2023-11-24 07:18:00 -05:00
desrosim232
346141e69e Merge branch 'master' into patch-Set-HVApplicationIcon 2023-11-24 07:17:48 -05:00
desrosim232
3c0a12f72a Update VMware.HV.Helper.psm1
Remove unnecessary Write-Host in Set-HVApplicationIvon
2023-11-24 07:15:55 -05:00
desrosim232
50ac249ec1 Merge branch 'vmware:master' into master 2023-11-23 15:58:52 -05:00
desrosim232
3634649afc Merge branch 'vmware:master' into patch-Set-HVApplicationIcon 2023-11-23 15:58:38 -05:00
desrosim232
9e4f03aebe Merge pull request #1 from desrosim232/patch-Set-HVApplicationIcon
Set-HVApplicationIcon Patch
2023-11-23 15:54:30 -05:00
desrosim232
0b3e4c9ea2 Set-HVApplicationIcon Patch
Patching a conditional issue with Set-HVApplicationIcon

Signed-off-by: Mathieu Desrosiers desrosim@gmail.com
2023-11-23 15:52:49 -05:00
Kamen Nikolov
ce06c5372b Added git sync script and fixed an issue in the
remove old snapshots script in the PowerActions folder
2023-11-21 16:55:06 +02:00
kamennikolov
20871aeffa Merge pull request #620 from Geo-Ron/instant-clone-accept-vtpm-machines
VMWare.HV.Helper - New-HVPool: implemented addVirtualTPM for instant clones
2023-09-07 12:09:52 +03:00
kamennikolov
524b0aac2f Merge pull request #619 from Geo-Ron/new-hvpool-gpu-changes
VMWare.HV.Helper - New-HVPool: implemented vGPU profile for instant clones
2023-09-07 12:08:54 +03:00
GeoRon
f748f2591e enabled addVTPM for instant clones
Signed-off-by: GeoRon <ronnie.peeters@gmail.com>
2023-09-06 16:07:06 +02:00
GeoRon
cd502a516b removed duplicate line
Signed-off-by: GeoRon <ronnie.peeters@gmail.com>
2023-09-06 15:41:49 +02:00
GeoRon
d43b7ec88b enabled vGPU profile for instant clones
Signed-off-by: GeoRon <ronnie.peeters@gmail.com>
2023-09-06 15:39:36 +02:00
Kamen Nikolov
d70d246e34 Added Power Actions sample actions
Signed-off-by: Kamen Nikolov <knikolov@vmware.com>
2023-07-31 16:23:56 +03:00
kamennikolov
d41905e00f Merge pull request #613 from desrosim232/Start-HVFarm-additions
Start hv farm additions
2023-06-27 16:57:28 +03:00
desrosim232
2be8d05707 Update VMware.HV.Helper.psm1
Encoding correction

Signed-off-by: Mathieu Desrosiers desrosim@gmail.com
2023-06-27 08:08:53 -04:00
desrosim232
356b3c4d68 Update VMware.HV.Helper.psm1
Adding new parameters for Start-HVFarm function to configure the ComputeProfile of the VMs underlying a farm:

NumCPU
Ram
CoresPerSocket

Signed-off-by: Mathieu Desrosiers desrosim@gmail.com
2023-06-27 08:07:14 -04:00
kamennikolov
52d38656ed Merge pull request #609 from desrosim232/New-HVFarm-additions
Update VMware.HV.Helper.psm1
2023-04-24 18:43:43 +03:00
desrosim232
1480fdec06 Adding infos to Ram parameter in New-HVFarm
Adding units info in the Ram parameter in New-HVFarm

Signed-off-by: Mathieu Desrosiers desrosim@gmail.com
2023-04-24 11:30:30 -04:00
desrosim232
ddc96d276e Update VMware.HV.Helper.psm1
Adding new parameters for New-HVFarm function to configure the ComputeProfile of the VMs underlying a farm:
- NumCPU
- Ram
- CoresPerSocket 

Adding the use of the parameter ReusePreExistingAccounts for INSTANT_CLONE farm

Signed-off-by: Mathieu Desrosiers <desrosim@gmail.com>
2023-04-21 10:31:32 -04:00
kamennikolov
ee6e800726 Merge pull request #605 from abidlen/master
Update README.md
2023-03-06 16:25:46 +02:00
Andy B
101b92e28d Update README.md
Fixed typo in link to Filing Issues section
Signed-off-by: Andy Bidlen <abidlen@gmail.com>
2023-03-02 20:06:07 -05:00
Nikola Klinkachev
fdebb39901 Building the SSOAdmin module with the latest changes in src and publishing the dlls. 2023-02-17 12:11:04 +02:00
kamennikolov
74f450fb75 Merge pull request #604 from Jiancao164/caojian/fixCertificateBug
Fix the bug of not creating certificates in linux
2023-02-16 09:37:35 +02:00
Jian Cao
25700a9ac2 Fix the bug of not creating certificates in linux
Signed-off-by: Jian Cao <caojian@microsoft.com>
2023-02-15 13:57:30 -08:00
Kamen Nikolov
414b6ccb62 Added VMware.VISecret module for managing secrets
Signed-off-by: Kamen Nikolov <knikolov@vmware.com>
2023-02-13 17:11:16 +02:00
kamennikolov
3c6190a2be Merge pull request #598 from bwuch/master
Updating module to resolve duplicate object bug
2022-12-21 10:47:56 +02:00
Brian Wuchner
b68077e4c3 Updating module to resolve duplicate object bug
When passing in objects to Get-SkylineAffectedObject, it was possible for duplicate queries to be invoked for the same product.  This commit fixes that by moving some of the string manipulation inside the correct loop for this function.  Additionally, the text replace lines were consolidated to reduce some confusion with variable assignment that led to this bug in the first place.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-12-20 08:52:34 -05:00
kamennikolov
c67b7d47a9 Merge pull request #592 from vmware/adatanasov/wcf-framework-dependency
Updated the SsoAdmin projects to reference WCF from the framework instead of a package.
2022-10-04 17:59:21 +03:00
Atanas Atanasov
9f468a5cc2 Updated the SsoAdmin projects to reference WCF from the framework instead of a package.
Signed-off-by: Atanas Atanasov <adatanasov@vmware.com>
2022-10-04 17:42:22 +03:00
kamennikolov
c6f51e944d Merge pull request #587 from Geo-Ron/issue-586
HV.Helper: Issue 586 - reEnable vTPM if previously defined on desktop pool
2022-08-17 14:45:21 +03:00
Ron Peeters
e9f5fa2c52 restore vTPM if previously defined
Signed-off-by: Ron Peeters <ronnie.peeters@gmail.com>
2022-08-17 13:07:41 +02:00
Ron Peeters
366aef13c2 using get-hvpool to retrieve existing settings.
Signed-off-by: Ron Peeters <r.peeters@vdl.nl>
2022-08-15 17:34:35 +02:00
kamennikolov
97799789da Merge pull request #584 from romqatt/master
Added Restart-HVMachine function
2022-08-09 13:56:45 +03:00
Гончаренко Роман Андреевич
9b62032a26 Added Restart-HVMachine function
Signed-off-by: Гончаренко Роман Андреевич <goncharenkora@nspk.ru>
2022-08-01 12:03:30 +03:00
kamennikolov
c74ae8cd7d Merge pull request #552 from DisasteR/openldap-identity-source
allow OpenLdap identity source creation
2022-06-29 13:37:11 +03:00
Benjamin SAIZ
dbd5f7e907 allow OpenLdap identity source creation
Signed-off-by: Benjamin Saiz <benj.saiz@gmail.com>
2022-06-29 11:12:31 +02:00
kamennikolov
91ab53cdf7 Merge pull request #550 from IvyPW/master
Add vCenter and collaboration support for manul pools
2022-05-31 14:55:01 +03:00
kamennikolov
51d21ca815 Merge pull request #546 from bwuch/bwuch-SkylineInsights
Timeout upates and bugfixes.
2022-05-26 09:37:56 +03:00
Brian Wuchner
e0e2d1bbdc Update VMware.Skyline.InsightsApi.psm1
I accidentally committed a version with a query problem in Get-SkylineAffectedObject.  This version does not contain that search problem.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-05-13 16:43:07 -04:00
Brian Wuchner
80622414d6 Update VMware.Skyline.InsightsApi.psm1
Apologies for the delay on getting this commit to address the final open item in the PR.  This change removes the "hit a 429 and retry" logic as it was not effective.  Replaced it with a global variable that stores the time of the last query.  If a query has happened within the last 501ms we wait before sending.  I've issued a few thousand queries with this logic added and have not yet hit the 429 error.  The logic to find and report on 429's in a more friendly way still exists, just in case.

Additionally I've implemented a counter to track number of queries that is reset by Connect-SkylineInsights, to track how many queries are executed.  This was more of a debugging tool, but felt the overhead was low enough to leave it in for future troubleshooting.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-05-13 11:14:46 -04:00
Brian Wuchner
b2e0decb68 Update VMware.Skyline.InsightsApi.psm1
Fixing minor issue uncovered by testing where only a product (vCenter Name) was passed to Get-SkylineFinding function.  When passed by pipeline, the product was applied to each pipeline input.  Making a change to require passing through pipeline by property name only.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-03-20 20:50:13 -04:00
Brian Wuchner
d85c6096a3 Update VMware.Skyline.InsightsApi.psm1
Addressing issues in PR 546.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-03-18 23:04:05 -04:00
Ivy Huang
6188524f90 support enableCollaboration parameter for new-hvpool
Function New-HVPool
1. support the setup with json object DesktopSettings.displayProtocolSettings.enableCollaboration
2. support the parameter enableCollaboration
2022-03-18 14:58:44 +08:00
Ivy Huang
d5f851339b take $jsonObject.ManualDesktopSpec.VirtualCenter
ManualDesktopSpec.VirtualCenter of json file was not taken care of. This could cause new-hvpool fail when creating with json file and there are multiple vcenters added to broker.
2022-03-17 16:11:21 +08:00
dmilov
829307318f Implement Set Default Identity Source and Get Default Identity Source (#545)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2022-02-25 11:26:10 +02:00
kamennikolov
9a302e0473 Merge pull request #543 from bwuch/master
Adding 'Get-SscFile','Set-SscFile','New-SscFile','Remove-SscFile','Get-SscLicense','Get-SscvRALicense','Get-SscMinionKey','Set-SscMinionKey' and 'Remove-SscMinionKey' cmdlets.
2022-02-24 14:54:24 +02:00
Brian Wuchner
02fd75b6a1 Updates to SaltStackConfig module
Updates to function names and parameters to ensure consistency as discussed in PR 543.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-23 15:32:31 -05:00
Brian Wuchner
3cd0fe0ca5 Update VMware.Skyline.InsightsApi.psm1
Moving the ParameterSetName checks to the process block instead of the begin block.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-23 15:18:04 -05:00
Brian Wuchner
bc6d2e8a5f Initial commit of VMware.Skyline.InsightsApi module
Initial commit of VMware.SkylineInsightsApi module, containing the following functions:
Connect-SkylineInsights, Disconnect-SkylineInsights, Invoke-SkylineInsightsApi, Get-SkylineFinding, Get-SkylineAffectedObject, Format-SkylineResult, Start-SkylineInsightsApiExplorer

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-21 12:21:45 -05:00
Brian Wuchner
b9cdded704 Update SaltStackConfig.psm1
Updates per conversation on PR 543.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-18 20:21:29 -05:00
Brian Wuchner
d23db41cfb Adding new functions to SaltStackConfig module
Adding support for new functions to SaltStackConfig module.  WIth this change items in the SSC Fileserver can get retrieved, modified, created, and removed, license details can be retrieved, and minion keys can be retrieved, modified, and removed.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-15 20:46:29 -05:00
kamennikolov
9b4ce6cf65 Fixing issues in VAMI and VMware.WorkloadManagement modules
Fixing issues in VAMI and VMware.WorkloadManagement modules
2022-02-14 16:09:44 +02:00
Brian Wuchner
38a6dea1d9 Update VAMI.psm1
Updates per conversation in PR #542.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-12 11:47:10 -05:00
Brian Wuchner
77b9db2f4e Update VMware.WorkloadManagement.psm1
Fixes #375 Adds the requested typecast to string for the MgmtNetworkNTP parameter.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-09 21:41:22 -05:00
Brian Wuchner
9964e16338 Update VAMI.psm1
Fixes #536.  The fullname vs. full_name options appear to have changed between the techpreview and GA of the API and have been accounted for in this update.  Additionally, after making a change so that the error message was present, the second issue showed to be type casting related.  For example, the input parameter for PasswordExpires is a switch, but the API was expecting a string.  This has been resolved with this commit.

When testing New-VAMIUser, I wanted to confirm success using Get-VAMIUser, but found a new bug where passing in a specific user through the Name property would fail with a vSphere 7 test environment.  This commit also includes a fix for that issue.

Changes to New-VAMIUser and Get-VAMIUser have been tested against 6.5, 6.7, and 7.0 environments and should function as expected.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-09 21:17:39 -05:00
kamennikolov
7a43b1096b Fixing instances of sort with sort-object
Fixing instances of sort with sort-object
2022-02-04 12:24:59 +02:00
Brian Wuchner
248a86f0a2 Fixing instances of sort with sort-object
Fixes #535 - module using sort instead of sort-object causing unexpected behavior on powershell core/Linux.
Instead of only addressing the issue at hand, I looked for other instances of sort being used instead of sort-object for other modules within this repo and corrected those as well.  I think I got most of them, but feel free to raise another issue if you find another.  If the sort was in an example/help statement, or was inside the logic/process of the function, I replaced sort with sort-object.  In the one case where the sort was only applied to the output I removed the statement -- this way the function user can add the sort in their script and not have to sort output twice.  I changed a couple  select/where with select-object/where-object along the way as well just as I saw them.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-02-03 20:11:02 -05:00
kamennikolov
9546f492e1 Merge pull request #526 from bwuch/master
Introduced SkipCertificateCheck and SslProtocol parameters to Connect-SSCServer
2022-01-26 15:51:37 +02:00
Brian Wuchner
de17729494 Update SaltStackConfig.psm1
Changing SslProtocol parameter from static validateset list to proper type.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-01-25 09:59:05 -05:00
kamennikolov
238adac0bd Merge pull request #529 from abidlen/master
Commit signing instructions added to the readme.
2022-01-25 11:41:37 +02:00
Andy Bidlen
054910c219 Merge branch 'vmware:master' into master
Signed-off-by: Andy B <abidlen@gmail.com>
2022-01-24 19:50:00 -05:00
Andy B
d8857e63db Update README.md
Updated Pull Request Requirements section to include examples and added a dco-required section to suggest how to respond to that error.

Signed-off-by: Andy Bidlen <abidlen@gmail.com>
2022-01-24 18:10:22 -05:00
Andy Bidlen
680ef82866 Fixes #124 - Contributor License Agreement issue.
Added information about the required DCO to submit a Pull Request and comply with the CLA.
Signed-off-by: Andy Bidlen <abidlen@gmail.com>
2022-01-24 15:30:25 -05:00
Brian Wuchner
c46d3522bd Updates to SSC Module -- provide better SSL support for Connect-SscServer
Moving the code to set SslProtocol to a separate parameter instead of hiding it under SkipCertificateCheck.
Updating Module Version to denote this minor change.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-01-24 14:48:21 -05:00
kamennikolov
fcf5ab8828 Merge pull request #525 from cadegenn/master
New-HVPool -Spec /path/to/file honor minNumberOfMachine attribute
2022-01-24 13:42:02 +02:00
Charles-Antoine Degennes
5648fe1bec [VMware.HV.Helper.psm1] New-HVPool: check for provisioningTime value
Signed-off-by: Charles-Antoine Degennes <cadegenn@univ-lr.fr>
2022-01-24 08:50:39 +01:00
Charles-Antoine Degennes
e83cfa1b0b [VMware.HV.Helper.psm1] fix issue #524
Signed-off-by: Charles-Antoine Degennes <cadegenn@univ-lr.fr>
2022-01-24 08:50:39 +01:00
Brian Wuchner
4e9093d0e5 Update SaltStackConfig.psm1
In the previous version of Connect-SscServer, we assumed that the SaltStack Config master node has an SSL certificate from an authority trusted by the powershell client and that the client supports the same TLS version as the server.  However, this may not be the case.  Therefore this commit adds support for a switch parameter named SkipCertificateCheck which ignores untrusted certificates and sets support for various TLS versions.  All SSC servers I've tested with have only supported Tls12, but lower levels were added to this function for backwards compatibility.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-01-21 15:11:17 -05:00
kamennikolov
db96e946f3 Merge pull request #512 from Ichigo49/patch-1
Modification on Get-VAMINetwork
remove write-host for hostname and DNS Servers, adding them in the $interfaceResult PSCustomObject
2022-01-14 11:36:56 +02:00
kamennikolov
6b82f226f7 Merge pull request #522 from imtrinity94/master
Added Rebuild-HVMachine function
2022-01-14 11:31:46 +02:00
Mayank Goyal
b5915de07a Merge branch 'master' of https://github.com/imtrinity94/PowerCLI-Example-Scripts
Signed-off-by: Mayank Goyal <imtrinity94@gmail.com>
2022-01-14 14:02:00 +05:30
Mayank Goyal
99674644d8 Update VMware.HV.Helper.psm1
Signed-off-by: Mayank Goyal <imtrinity94@gmail.com>
2022-01-14 14:01:18 +05:30
Mayank Goyal
8cfc5e4fa6 Update VMware.HV.Helper.psm1 2022-01-14 13:50:35 +05:30
kamennikolov
b1c98c0fa2 Merge pull request #521 from bwuch/master
SqlTimeout parameter added to Get-HVEvent
2022-01-13 17:20:55 +02:00
Brian Wuchner
5b291a5ac0 Update VMware.HV.Helper.psm1
Fixes #364 - Get-HVEvent timeout issue
Changes to line 877-879 adds help for a new SqlTimeout parameter added to Get-HVEvent
Changes to line 931-934 add support for the new SqlTimeout parameter with a default value of 30 seconds.
Changes to line 1064 implements the timeout parameter created above when executing the query.

The change to line 1031 resolves an unrelated issue where I was seeing an extra '1' in the output from Get-HVEvent.  Adding the `Out-Null` statement is similar to another example in this same function which already existed on line 1065.  Adding the `Out-Null` statement did resolve the extra '1' displayed in the output.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-01-13 07:59:41 -05:00
kamennikolov
0b5e119776 Merge pull request #520 from bwuch/master
Handling SFTP backup issue on VC 7.0
2022-01-12 09:41:22 +02:00
Brian Wuchner
33e41a756e Update Backup-VCSA.psm1
Fixes #468.  In this issue, it is noted that starting with vSphere 7 you need to use SFTP instead of SCP when calling Backup-VCSAToFile.  In this commit we are adding SFTP to the Validate Set for the Location Type.  Additionally, we add some logic to toggle between SFTP or SCP depending on appliance version and provide warning text that an adjustment was made.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2022-01-11 20:25:22 -05:00
kamennikolov
379ff32624 Merge pull request #517 from bwuch/master
Added a -Credential parameter to the Connect cmdlet.
2022-01-04 13:57:31 +02:00
Brian Wuchner
05d2016ff0 Update SaltStackConfig.psm1
Minor update to add examples of the new functionality to the help in the function.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-12-23 19:21:59 -05:00
Brian Wuchner
e293d7e365 Update SaltStackConfig.psm1
Improve Connect-SscServer to accept credentials instead of just plaintext username/password values.

We will make the PlainText parameter set items mandatory, so if you use this parameter set both values need to be provided.
However, if you don't specify any credentials at all as arguments, we will default to the optional Credential parameter set.  When the credential parameter set is used but the credential value is null, we will prompt for credentials using Get-Credential.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-12-23 14:24:17 -05:00
dmilov
1d96b6a340 Implement update authentication credential for LDAP identity sources (#516)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-12-22 12:34:59 +02:00
Ichigo49
7eb5651feb Update VAMI.psm1
Signed-off-by: Mathieu ALLEGRET <mathieu.allegret@pm.me>
2021-12-08 12:32:12 +01:00
Ichigo49
cc2c740738 Update VAMI.psm1
Modification on Get-VAMINetwork
remove write-host for hostnmae and DNS Servers, adding them in the $interfaceResult PSCustomObject
2021-12-08 12:27:50 +01:00
kamennikolov
13d0ef4b86 Merge pull request #502 from bwuch/master
vRealize Automation SaltStack Config API wrapper
2021-12-07 11:04:48 +02:00
Brian Wuchner
3b7653da71 Minor changes to Connect-SscServer output properties.
Changing returned columns from Connect-SscServer to be more in line with other PowerCLI cmdlets.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-12-06 15:49:33 -05:00
Brian Wuchner
3afa7eed5d Resolving comments from PR in SaltStackConfig module
Promoting properties on the connection object as requested in PR comment.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-12-03 12:53:37 -05:00
Brian Wuchner
96205f85b2 Updating SaltStackConfig module
Updated functions based on comments in PR502.  Updated manifest to include Get-SscActivity (previously Get-SscCommand) and reference to new Format.ps1xml, which contains custom formatting for the Connect-SscServer output.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-12-02 14:39:23 -05:00
Brian Wuchner
ded1ce575d Resolving some of the items from PR comments.
Many thanks to @kamennikolov for his time to review and provide such helpful comments!  This commit address many of the comments from PR 502 in the module psm1 file.  Also updated module manifest to rev version number, changed FunctionsToExport to address Get-SscMinion --> Get-SscMinionCache name change.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-12-01 11:58:39 -05:00
Brian Wuchner
95abde3a5a Update SaltStackConfig.psm1
Fixing help information in Connect-SscServer to be more descriptive.
Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-11-29 06:52:50 -05:00
Brian Wuchner
ba63d1643a Update SaltStackConfig.psd1
Increasing version number in manifest.
Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-11-29 06:48:29 -05:00
Brian Wuchner
38998cee05 vRealize Automation SaltStack Config API wrapper
Initial commit of SaltStackConfig module, a series of wrapper functions for the vRealize Automation SaltStack Config API.

Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
2021-11-28 21:29:59 -05:00
Matt Frey
ccdddba4e7 Reversing 9d9ebc504b (#492)
The change made in 9d9ebc504b breaks ImagePush operations for Instant Clone pools. See the API documentation for reference.

The schema for `DesktopPushImageSpec` is as follows:

* DesktopPushImageSpec
  * Settings
    * StartTime

Signed-off-by: Matt Frey <mfrey@vmware.com>
2021-11-25 14:35:12 +02:00
Matt Frey
2ec8f92823 Address Issue 496 (#497)
Addressing Issue 496 to resolve the unintentional false condition when `-Value` is set to `$false` on `Set-HVGlobalSettings

Signed-off-by: Matt Frey <mfrey@vmware.com>
2021-11-25 14:34:40 +02:00
dmilov
8830d3ec2d Bug fixes (#499)
* Add Certificates to External Identity Source

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

* Add Credential parameter to Connect-SsoAdminServer

Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-11-25 14:18:53 +02:00
ricoroodenburg
9d82c04d72 Update VMware.HV.Helper.psm1 (#489)
Fix for error Get-HVBaseImageVM - Cannot find an overload for "BaseImageVM_List" and the argument count: "1"
2021-10-01 14:31:12 +03:00
dmilov
294071df19 Remove VC IP 2021-09-16 14:53:21 +03:00
dmilov
a7cd4db523 PowerCLI 12.4 vSphere APIs through PowerCLI demo script (#486)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-09-16 14:48:11 +03:00
dmilov
5025ab9047 Add PowerCLI Logo (#485)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-09-16 13:14:33 +03:00
dmilov
173c08216e Increase the default web operation timeout (#484)
* Increase the default web operation timeout

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

* Increament module version

Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-09-07 11:24:51 +03:00
Dimitar Milov
1710f7ccbd Add new PowerCLI icon in the PowerCLI Examples Repo
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-09-02 17:40:04 +03:00
Nam Tran
dbb570e009 Update VMware.HV.Helper.psm1 (#469) 2021-08-23 14:43:37 +03:00
Dan Acristinii
3c961963f1 Fixed no snapshot found error mistype (#481)
Signed-off-by: Dan Acristinii <dan.acristinii@roche.com>
2021-08-23 14:38:27 +03:00
dmilov
a62b0006b8 Update IconUri (#476)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-07-28 17:19:55 +03:00
dmilov
5b9265d0ad Update link to powercli log icon (#475)
* Implement feature issue #472

Signed-off-by: Dimitar Milov <dmilov@vmware.com>

* Fix modules manifest to point to powercli log icon

Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-07-28 16:28:41 +03:00
dmilov
2b62d20d13 Implement feature issue #472 (#474)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-07-28 16:23:54 +03:00
dmilov
0cbd85190c Implement Enable/Disable Person Uer account in the Set-SsoPersonUser cmdlet (#471)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-07-23 15:11:42 +03:00
Jimit G
246a887e84 Added VMsStatusReport file (#465)
* Added VMsStatusReport file

* fixed typo and added space before and after |

* Modified script to fuction with VIServerFilePath and OutPath parameters

* Refined help section

* Changed name from VMsStatusReport.ps1 to Get-VMSnapshotReport.ps1

* help documentation refined

* commit

* fomating corrections using prettier extension

* cmdletbinding correction

* added example and fixed parameter issue
2021-06-28 07:35:24 +03:00
Rob Nelson
3077daaeb5 DesktopRecomposeSpec does not have a Settings attribute (#464)
Similar adjustment as in #452 to another instance.
2021-06-21 11:02:04 +03:00
dmilov
1dd718eb3a Fix issue #460 adding PasswordExpirationRemainingDays property to the PersonUser object (#463)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-06-07 10:42:18 +03:00
dmilov
fb641c8a1c License PowerCLI-Examples-Scripts repository under BSD-2 Clause (#462)
As part of the VMware open source program, we have to update this repository with the correct license and copyright information.
We add the BSD-2 Clause License for this repository.
We mark all source code provided by VMware with the Copyright notice under BSD-2 Clause license.

* Update repository license to BSD 2-Clause License

* Update Copyright
2021-06-07 09:58:47 +03:00
dmilov
db68f439a3 Merge pull request #461 from jatinpurohit92/topic/vlcm-cmdlets
adding vLCM cmdlets
2021-06-07 09:09:01 +03:00
Jatin purohit
32749fbd16 adding vLCM cmdlets 2021-06-04 08:44:12 -07:00
dmilov
af57eab8b8 Merge pull request #457 from j33tu/copy-ipsetv2t
function to move ipsets from nsx v to Nsx t
2021-06-02 09:15:46 +03:00
Joanna singh
21f4e8734c function to move ipsets from nsx v to Nsx t 2021-06-01 21:50:07 +05:30
dmilov
8de76d1327 Merge pull request #453 from MallocArray/master
Resolve issues with Backup-VCSA
2021-05-28 09:22:13 +03:00
dmilov
53ab16a241 Merge pull request #452 from rnelson0/starttimebug
Recompose with starttime generates error
2021-05-28 09:22:00 +03:00
dmilov
0c6b0b0a95 Merge pull request #454 from dmilov/topic/ssoadmin-support-groups
Group management cmdlet in SsoAdmin module
2021-05-26 11:22:38 +03:00
Dimitar Milov
7b8d982dd3 Implement Find Group By Group
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-05-26 11:11:13 +03:00
Dimitar Milov
5d221fdb15 Implement Add and Remove principal to/from SsoGroup
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-05-26 10:54:15 +03:00
Dimitar Milov
f0cf0f58bd Implement Set-SsoGroup cmdlet
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-05-26 09:44:52 +03:00
Dimitar Milov
04b0807ed5 Implement New and Remove SsoGroup cmdlets.
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-05-25 19:11:15 +03:00
Dimitar Milov
09fad317e1 Refactor advanced functions moving them to dedicated .ps1 file
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
2021-05-25 15:47:52 +03:00
Joshua Post
5a45f4ec85 BackupDays must be all caps for API call to work
When days are in mixed or lower case, the schedule summary page shows
the correct day, but editing the schedule shows a blank and scheduled
executions do not happen.  API reference shows it in all caps which does work as expected.
Attempted to use .ToUpper() on line 319 but it resulted in an error
Changing validation to require it in all caps
2021-05-24 14:50:28 -05:00
Joshua Post
5df4070717 Encrypt Backup is option in VAMI
Change Mandatory to false so it can be optional as shown in the VAMI GUI
2021-05-24 14:48:19 -05:00
Joshua Post
9a02c0e1fa Correct casting of int
Interger is not a valid type, at least in Powershell 5.1
2021-05-24 14:47:07 -05:00
Joshua Post
e872cc50d1 If 'common' is not specified, it is not included
If 'common' is not included, it is unchecked when viewing in the GUI
2021-05-24 14:45:14 -05:00
Joshua Post
9519635847 Add support for SMB location 2021-05-24 14:43:39 -05:00
Joshua Post
83447772b6 Replace invalid character with ' 2021-05-24 14:41:56 -05:00
Rob Nelson
9d9ebc504b DesktopRecomposeSpec does not have a Settings attribute 2021-05-19 09:46:54 -04:00
Rob Nelson
88f15d9fe3 Some linting 2021-05-19 09:46:31 -04:00
dmilov
a8d656e879 Merge pull request #449 from rnelson0/patch-1
Better handling of module version checks
2021-05-18 07:41:12 +03:00
Rob Nelson
0a94dd4658 Better handling of module version checks
If the module is not loaded, and autoloading does not occur before the `Get-HVModuleVersion` call, the result might be an empty string. This gives a chance to force loading the module and error if it is not available.
2021-05-17 15:41:54 -04:00
Jake Robinson
8db1fe37a2 Vmware Cloud Partner Navigator Example Module 2021-04-09 00:34:58 -04:00
dmilov
bffb3f7630 Merge pull request #438 from TheRealBenForce/FullClone-New-HvPool
enhancements for full clones
2021-03-19 12:27:09 +02:00
dmilov
e308436f06 Merge pull request #435 from mtelvers/ListByDatacenter
`VmTemplate_ListByDatacenter` requires two arguments as identified by
2021-03-19 12:26:30 +02:00
dmilov
a9bc152266 Merge pull request #441 from dmilov/dmilov/new-ssoadmin-features
Add new features in Get-SsoPersonUser and new cmdlet Remove-IdentitySource
2021-03-19 09:47:51 +02:00
Dimitar Milov
ed4f05238f Implement Remove-IdentitySource
Add FailoverUrl Property to ActiveDirectory identity source
2021-03-19 09:41:19 +02:00
Dimitar Milov
5fda0c70d5 Add Locked and Disabled properties to PersonUser object 2021-03-19 08:58:40 +02:00
Dimitar Milov
bfccd7faeb Implement Get-SsoPersonUser by Group 2021-03-18 19:13:54 +02:00
Dimitar Milov
6198fffb2d Implement GetPersonUsersInGroup 2021-03-18 18:58:13 +02:00
Dimitar Milov
4f60f40a72 Remove catalog file from the output 2021-03-17 18:27:34 +02:00
Ben Force
979463b66f enhancements for full clones 2021-03-09 11:46:22 -07:00
dmilov
0e8d0d9cf5 Merge pull request #434 from mtelvers/syslog
Added functions Get-HvSyslog and Set-HvSyslog to manage the UDP
2021-03-09 16:08:32 +02:00
mtelvers
cbd9a9594c VmTemplate_ListByDatacenter requires two arguments as identified by
@TheRealBenForce in #431.  I have looked back to PowerCLI 6.5 and this
was the case back then as well and not a new 12.2 change.

    VmTemplate_ListByDatacenter            Method
    VMware.Hv.VmTemplateInfo[] VmTemplate_ListByDatacenter(
      VMware.Hv.Services service, VMware.Hv.DatacenterId datacenter
      )

Without wanting to steal anyones credit I've created a PR for this change.
2021-03-08 09:52:11 +00:00
mtelvers
0f6839ba68 Added functions Get-HvSyslog and Set-HvSyslog to manage the UDP
syslog server settings on Horizon.
2021-03-08 08:53:39 +00:00
dmilov
7dd8f4cabc Merge pull request #430 from mtelvers/HostOrCluster
Removed duplicate calculation of HostClusterID
2021-03-08 08:40:51 +02:00
dmilov
63655338ee Merge pull request #428 from mtelvers/master
Address changes to BaseImageVm_List()
2021-03-08 08:39:38 +02:00
dmilov
cf7277cf7c Merge pull request #425 from ricoroodenburg/patch-2
Get-NetworkLabels function
2021-03-08 08:39:27 +02:00
mtelvers
0dd8b6f046 Removed duplicate calculation of HostClusterID 2021-03-05 19:14:34 +00:00
mtelvers
9f78104a1f Address changes to BaseImageVm_List()
Address issue #397
2021-03-02 14:54:26 +00:00
ricoroodenburg
30b8fa5c6d Update VMware.HV.Helper.psm1 2021-02-25 18:16:44 +01:00
ricoroodenburg
dc51c284da Get-NetworkLabels function
Can be used for the future, for assigning Network Labels to a a nic for new Horizon farm of desktop pool
2021-02-25 18:12:50 +01:00
dmilov
d3848a097f Merge pull request #421 from ricoroodenburg/patch-1
Added Load Balancing Settings
2021-02-24 07:20:14 +02:00
ricoroodenburg
38b3524beb Added Load Balancing Settings
- Added 2 lines within "Get-FarmSpec" (3281 + 3282)
- Added new parameters within "New-HVFarm" (2282 till 2312)
- Added new coding within "New-HVFarm" (2856 till 2866)
2021-02-23 23:05:27 +01:00
dmilov
fd9c63825c Merge pull request #419 from dmilov/topic/dmilov/reset-self-password
Implement Set-SsoSelfPersonUserPassword
2021-02-19 09:15:22 +02:00
Dimitar Milov
59f562d9ed Implement Set-SsoSelfPersonUserPassword 2021-02-19 09:14:32 +02:00
dmilov
7766772353 Merge pull request #409 from ashishsharma-git/patch-1
Update vRealize Operations Maintenance Mode.ps1
2021-02-17 16:45:46 +02:00
dmilov
e52b7dab53 Merge pull request #412 from bitszor/issue-400
Fix issue #400 - New-HVFarm fails when maxSessionsType is LIMITED
2021-02-17 16:44:41 +02:00
dmilov
6ebbad11e9 Merge pull request #418 from dmilov/topic/dmilov/failoverurl
Add SecondaryUrl parameter to Add-LDAPIdentitySource
2021-02-17 16:40:18 +02:00
Dimitar Milov
8606722f6e Add SecondaryUrl parameter to Add-LDAPIdentitySource 2021-02-17 16:38:46 +02:00
dmilov
13dc050dd2 Update README.md 2021-02-17 11:12:14 +02:00
dmilov
80509a18a5 Merge pull request #417 from dmilov/topic/dmilov/ssoadmin-externaldomain
Implement prepare for publishing funcitonality
2021-02-17 10:59:05 +02:00
Dimitar Milov
f07791e1dd Implement prepare for publishing funcitonality 2021-02-17 10:56:22 +02:00
dmilov
19e507581f Update README.md 2021-02-17 10:13:31 +02:00
dmilov
a31276bcdb Merge pull request #416 from dmilov/topic/dmilov/ssoadmin-externaldomain
Add LDAP Identity Source Functions
2021-02-17 10:12:17 +02:00
Dimitar Milov
16b3a0fe05 Add Set-LdapIdentitySource functionality 2021-02-17 10:10:39 +02:00
Dimitar Milov
fa518f99ee Fix certificate formatting before send them to the server 2021-02-17 09:26:23 +02:00
Dimitar Milov
1e8308d84c Fix tests taht use old pester syntax 2021-02-16 19:15:49 +02:00
Dimitar Milov
ef804e6a05 Migrated to Pester 5.1
Migrated to netcoreapp3.1
2021-02-16 19:10:43 +02:00
Dimitar Milov
5426af92b7 Fix LDAP register MoRef 2021-02-16 18:11:27 +02:00
Dimitar Milov
ac6c923e90 Implement Add-LDAPIdentitySource 2021-02-11 16:26:04 +02:00
dmilov
ec2ffb87ae Merge pull request #414 from dmilov/topic/dmilov/ssoadmin-externaldomain
New features and bug fixes
2021-02-11 11:44:14 +02:00
Dimitar Milov
f5a4dbf4cd Rebase on upstream master 2021-02-11 11:41:11 +02:00
Dimitar Milov
bda716b560 Rebase 2021-02-11 11:11:18 +02:00
Dimitar Milov
25f21ecfb5 Update binaries 2021-02-11 11:10:14 +02:00
Dimitar Milov
3f43eed119 Improve error handling. Added ref counting of server connections. Extended Add-ExternalDomainIdentitySource 2021-02-11 11:07:52 +02:00
Dimitar Milov
176590fb66 Update binaries 2021-02-11 10:33:33 +02:00
Dimitar Milov
775498aa8a Improve error handling. Added ref counting of server connections. Extended Add-ExternalDomainIdentitySource 2021-02-11 10:31:03 +02:00
Ben Blier
cb6076ac60 Fix issue #400 - New-HVFarm fails when maxSessionsType is LIMITED 2021-02-04 11:03:40 -07:00
ashishsharma-git
066dbb25f7 Update vRealize Operations Maintenance Mode.ps1
Since Get-Inventory does not return Datastore Objects, added switch "IsDatastore" to specify Datastore Objects being passed to the function.
2021-01-25 21:37:23 +05:30
dmilov
29c2cc0221 Merge pull request #406 from vmware/topic/dmilov/fix-addactivedirectory-for-67
Fix issue #405
2020-12-15 13:56:19 +02:00
dmilov
dcfd1c6caf Fix issue #405 2020-12-15 13:54:16 +02:00
dmilov
b2498a3fc3 Merge pull request #404 from vmware/topic/dmilov/fix-vsphere-sso-module
Remove searchAllDomains files from lookup service filter
2020-12-10 09:24:56 +02:00
dmilov
837d98960c Remove searchAllDomains files from lookup service filter 2020-12-10 09:21:55 +02:00
dmilov
c5d2cb9f09 Merge pull request #399 from dmilov/topic/dmilov/get-identity-source-cmdlet
Implement Get-IdnetitySource advanced function
2020-11-26 17:44:08 +02:00
dmilov
c212b24cbb Implement Get-IdnetitySource advanced function 2020-11-26 17:41:10 +02:00
dmilov
791f976665 Merge pull request #393 from antracey/patch-1
Update VMware.HV.Helper.psm1
2020-10-14 10:39:49 +03:00
dmilov
023edb4959 Merge pull request #391 from shidouli/master
Update the module to support the new feature introduced in PowerCLI
2020-10-14 10:38:36 +03:00
antracey
c1e8ee9ab9 Update VMware.HV.Helper.psm1
Fix New-HvManualApplication to support MultiSessionMode and MaxMultiSessions VMware.Hv.ApplicationData properties and validation of MaxMultiSessions param.
2020-10-13 17:55:08 -04:00
Carrie Yang
f4eb24821f Update the module to support the new feature introduced in PowerCLI
12.1.0 for vCenter Server 7.0.1: Add-TrustedHost should be used only for
   7.0.0, use 'Set-TrustedCluster -Remediate' for 7.0.1 for
     TrustedCluster adding a new host
2020-10-13 10:57:36 +08:00
dmilov
dc5a755805 Merge pull request #390 from dmilov/topic/type-name-typo-fix
Fix typo 'Stirng' to 'String' in argument transformation type names
2020-10-06 21:15:40 +03:00
dmilov
9abd96740a Fix typo 'Stirng' to 'String' in argument transformation type names 2020-10-06 21:11:24 +03:00
dmilov
acc1ab14bf Merge pull request #389 from dmilov/topic/obn-for-server-parameter
Implement OBN for -Server parameter of Disconnect-SsoAdminServer funstion. Fixes https://github.com/vmware/PowerCLI-Example-Scripts/issues/387
2020-10-06 11:01:17 +03:00
dmilov
c1e3e1936e Merge 2020-10-06 10:57:00 +03:00
dmilov
8aa673e375 Add tests for String to SsoAdminServer argument transformation in Disconnect-SsoAdminServer funciton 2020-10-06 10:56:00 +03:00
dmilov
927d5de17c Implement String to SsoAdmin server argument transformation attribute 2020-10-06 10:45:13 +03:00
dmilov
67529beefa Merge pull request #388 from qlikq/master
Enable quick disconnect for Disconnect-SsoAdminServer
2020-10-06 10:40:07 +03:00
dmilov
8621610ed8 Implement String to SsoAdmin server argument transformation attribute 2020-10-06 10:38:38 +03:00
Grzegorz Kulikowski
2c1eafde18 Modify test disconnect-ssoadminserver with throw msg 2020-10-06 08:59:32 +02:00
Grzegorz Kulikowski
7832d6e7ae Use Throw instead of ThrowTerminatingError() 2020-10-06 08:50:50 +02:00
Grzegorz Kulikowski
d6565f9e26 fix test for Disconnect-SsoAdminServer 2020-10-05 20:38:37 +02:00
Grzegorz Kulikowski
ca508570fb Add support for quick disconnect to Disconnect-SsoAdminServer
In case one is connected just to one SSO server the cmdlet does not
need to take the -server parameter as it will be discovered from
$DefaultSsoAdminServers. In case there are more than 1 SSO servers
it will not disconnect any connection, instead it will ask to be more
precise using the Server parameter.
2020-10-05 20:28:40 +02:00
Grzegorz Kulikowski
b03c1a536d Add pester tests for Disconnect-SsoaAminServer 2020-10-05 20:16:36 +02:00
dmilov
eb827499cd Merge pull request #386 from dmilov/topic/dmilov/SsoAdminModule
PowerShell Module for managing VMware vSphere SSO Admin functionality
2020-10-05 10:50:25 +03:00
dmilov
b2934bcbf1 Rename module's exported functions with Sso prefix on the noun part 2020-10-05 10:48:36 +03:00
dmilov
68e777357c Address PR discussions 2020-10-05 10:39:52 +03:00
dmilov
4ca1a612ab Update copyright info 2020-10-01 17:16:16 +03:00
dmilov
def74388ce Update README with required build and test tools 2020-09-30 16:00:09 +03:00
dmilov
69975a39ff Fix net45 assmeblies publishing 2020-09-30 15:44:01 +03:00
dmilov
63d52d4e60 Fix global defaultSsoAdminServers variable 2020-09-30 15:28:34 +03:00
dmilov
6148e8ff89 Implement Add-ActiveDirectoryIdentitySource 2020-09-30 15:19:54 +03:00
dmilov
14e81f78af Implement Get/Set-TokenLifetime 2020-09-30 14:26:31 +03:00
dmilov
5abdbe9702 Implement Get/Set-LockoutPolicy cmdlets 2020-09-30 13:48:01 +03:00
dmilov
88648e2db2 Implement Get/Set-PasswordPolicy cmdlets 2020-09-30 12:17:56 +03:00
dmilov
c53453abb2 Implement Get/Set-PasswordPolicy cmdlets 2020-09-30 12:17:36 +03:00
dmilov
b8030e4272 Implement ResetPassword and Unlock for PersonUser accounts. 2020-09-29 17:16:47 +03:00
dmilov
5fb63bb345 Implement Add/Remove User to/from Group 2020-09-29 16:52:17 +03:00
dmilov
0cf0626f4c Implement Get-Group advanced function 2020-09-29 16:01:37 +03:00
dmilov
48df3710fd Implement Get/New/Remove-PersonUser 2020-09-29 14:39:30 +03:00
dmilov
bac4cf704c Implement Connad/Disconnect-SsoAdminServer finctions 2020-09-29 09:53:29 +03:00
dmilov
8599b67b81 Implement SsoAdminServer data type
Implement GetLocalUsers
Add inntegration tests for GetLocalUsers
2020-09-29 08:18:49 +03:00
dmilov
391660cdf4 Implement Create/Delete/List person users functionality in ssoAdminClient 2020-09-28 17:59:13 +03:00
dmilov
64e0b52224 Adds module code structure, build script, test script, and API bindings 2020-09-28 11:25:47 +03:00
dmilov
35859f68ba Merge pull request #381 from CTip/master
Update VMware.HV.Helper.psm1 - expanded manual pool options
2020-09-23 10:17:17 +03:00
dmilov
1a7acd4812 Merge pull request #370 from saintdle/master
Edits to VMC NSX-T module
2020-09-23 10:15:55 +03:00
dmilov
d5abcdfbbe Merge branch 'master' into master 2020-09-23 10:15:25 +03:00
dmilov
f685181096 Merge pull request #380 from dunsdon/patch-3
Update Backup-VCSA.psm1
2020-09-23 10:13:00 +03:00
dmilov
f6f10d1738 Merge pull request #382 from dunsdon/patch-4
Update VAMI.psm1
2020-09-23 10:07:29 +03:00
Michael Dunsdon
0c3cad8410 Update VAMI.psm1
Made some additional Changes and adjusted the Case of Variables.
2020-09-22 13:10:16 -05:00
CTip
3c45bbc117 Update VMware.HV.Helper.psm1 2020-09-21 15:38:51 -05:00
Michael Dunsdon
368ec747ac Update Backup-VCSA.psm1
Updated Code based on Comments
2020-09-21 14:35:17 -05:00
dmilov
d64e0fbdc0 Merge pull request #373 from vMarkusK/Apply-OMRightsizing
Apply-OMRightsizing
2020-08-03 09:47:50 +03:00
Markus Kraus
9532ea9fac pply-OMRightsizing 2020-07-30 20:45:13 +02:00
dmilov
b78fb11206 Merge pull request #369 from mycloudrevolution/Set-VMHostSecureNTP.ps1
New Function Set-VMHostSecureNTP
2020-06-01 09:36:05 +03:00
Markus Kraus
b0dcb843aa Fix tab alignments 2020-05-30 21:02:25 +02:00
Markus Kraus
d2544c9418 Other loop for "Remove all existing NTP Servers" 2020-05-30 20:59:57 +02:00
Markus Kraus
8de5885437 Change NTP input to type ipaddress 2020-05-30 20:51:00 +02:00
Markus Kraus
7ecfd1309d ReOrg the inline function 2020-05-30 20:48:19 +02:00
Markus Kraus
91053171e7 Add Parameter Position 2020-05-29 19:17:01 +02:00
Markus Kraus
dd4bb2f415 fix Typos 2020-05-28 21:06:40 +02:00
Markus Kraus
4d1436b857 Fix Var Naming 2020-05-28 21:01:09 +02:00
Markus Kraus
4af6de8e1d Add MetaData 2020-05-28 20:58:53 +02:00
Markus Kraus
3a91b48f15 Add Secure Operation 2020-05-28 20:45:46 +02:00
Markus Kraus
91cac83589 Fix for existing configurations 2020-05-28 20:38:09 +02:00
Markus Kraus
222f75a6ca Workaround for duplicate IP 2020-05-27 18:59:32 +02:00
Markus Kraus
9a7dc6dd59 Added Error Handling and Pre-Checks 2020-05-26 22:37:26 +02:00
Markus Kraus
bd70bfb5dc processing for SetSecure 2020-05-25 21:45:13 +02:00
Markus Kraus
5c3e80bbf6 SetSecure inlline function 2020-05-25 21:41:22 +02:00
dmilov
f0e801fceb Merge pull request #368 from lamw/master
Add Workload Management module for vSphere with Kubernetes
2020-05-21 07:59:31 +03:00
William Lam
29b3b75604 Added Workload Management module for vSphere with Kubernetes
Updating Banner
2020-05-20 07:57:54 -07:00
dmilov
efef60d86a Merge pull request #265 from ctolan/Pester-Test-Coverage
Pester test coverage
2020-05-18 09:03:05 +03:00
dmilov
0500e52750 Merge pull request #358 from lamw/master
Add support for pagination for retrieving NSX-T Segments
2020-05-15 16:31:26 +03:00
dmilov
cfd3ca222d Merge pull request #365 from mycloudrevolution/Get-UplinkDetails
New Function Get-VMHostUplinkDetails
2020-05-08 08:40:07 +03:00
Markus Kraus
ca6f6abeb7 remove reporting array and sort 2020-05-07 20:42:54 +02:00
Markus Kraus
f53c09ae03 Replace % with Foreach-Object. 2020-05-07 20:35:44 +02:00
Markus Kraus
0c3ff917d0 Replace where with Where-Object 2020-05-07 20:34:28 +02:00
Markus Kraus
228de51f25 Fix code formatting 2020-05-07 20:33:25 +02:00
Markus Kraus
e24187a954 rename VMHost Parameter 2020-05-07 20:32:06 +02:00
Markus Kraus
be7f982767 Update Parameter 2020-05-07 20:25:40 +02:00
Markus Kraus
3a4dada48d Rename Function 2020-05-07 20:20:13 +02:00
Markus Kraus
a918eacdad Rename Get-UplinkDetail.ps1 to Get-UplinkDetails.ps1 2020-04-29 23:04:44 +02:00
Markus Kraus
76d01e7eb8 Create Get-UplinkDetail.ps1 2020-04-29 23:04:18 +02:00
Markus Kraus
1191cf6f75 Merge pull request #2 from vmware/master
Update Fork
2020-04-29 23:01:45 +02:00
saintdle
a4d766922a Update VMware.VMC.NSXT.psm1
By adding the validation 'EQUALS' to line 881, this allows for the creating of a Group using the virtual machine member type. This change works for creating a single virtual machine using this type. Cannot quite figure out how to fix this to work for adding multiple machines at once.
2020-04-20 21:47:22 +01:00
saintdle
4b2113d44f Merge pull request #1 from saintdle/saintdle-patch-1
Update VMware.VMC.NSXT.psm1
2020-04-20 20:15:20 +01:00
saintdle
d6b02fb0ad Update VMware.VMC.NSXT.psm1
Corrected spelling mistake on like 93 + 104
Retrievig 
To;
retrieving
2020-04-20 20:14:43 +01:00
Alan Renouf
f4ef4b0e07 Merge pull request #362 from vmware/AccessUpdates
Updated Workspace One Access module
2020-04-15 15:04:44 -07:00
Alan Renouf
500e4022e7 Updated Workspace One Access module to include Get-UEMConfig and Remove-UEMConfig 2020-04-15 14:09:13 -07:00
dmilov
20f387d2cf Merge pull request #360 from BaoyinQiao/bqiao-Encryption
Add the VMware.TrustedInfrastructure.Helper module
2020-04-13 13:38:44 +03:00
Baoyin Qiao
adba00b7e8 Adding the module script and manifest of it 2020-04-02 19:00:30 +08:00
Baoyin Qiao
3d74470c70 Update README.md 2020-04-02 18:58:49 +08:00
Baoyin Qiao
23ad3e0f64 Create Readme file 2020-04-02 18:57:41 +08:00
Baoyin Qiao
21182d762b Merge pull request #2 from BaoyinQiao/master
pull from master
2020-04-02 18:35:22 +08:00
Baoyin Qiao
747190c33d Merge pull request #1 from vmware/master
Sync from original
2020-04-02 18:33:38 +08:00
William Lam
1e7033a66f Add support for pagination for retrieving NSX-T Segments 2020-03-07 13:39:29 -08:00
Kyle Ruddy
c5c836d3d6 Update VMware.HV.Helper.psm1
Updated per Issue #357
2020-03-06 11:48:31 -05:00
Kyle Ruddy
31fa1244fd Merge pull request #355 from bfett20/master
Add -clearGlobalEntitlement to Set-HVApplication
2020-03-05 14:09:19 -05:00
Kyle Ruddy
46c3a91c9d Merge pull request #356 from lamw/master
Add VyOS and VCSA PowerCLI Module
2020-03-05 14:08:32 -05:00
William Lam
3cf69178d5 Support Disconnected NSX-T Segments for {New,Set}-NSXTSegment 2020-03-05 10:12:36 -08:00
William Lam
f3c549a867 Consolidated VCSA functions into VCSA Module 2020-02-28 10:34:01 -08:00
William Lam
aa8d5e3c26 List VCSA Identity Source 2020-02-28 08:51:45 -08:00
bfett20
926260096f Delete stale.yml 2020-02-24 06:40:29 -06:00
bfett20
233c220dd6 Update VMware.Hv.Helper
Added "clearGlobalEntitlement" switch to Set-HVApplication
2020-02-24 06:30:39 -06:00
bfett20
e45aa0171d Create stale.yml 2020-02-24 06:24:44 -06:00
William Lam
41f6194fdb Updated VyOS Module 2020-02-09 08:08:01 -08:00
William Lam
98ae307c1f Merge branch 'master' of https://github.com/lamw/PowerCLI-Example-Scripts 2020-02-09 08:07:42 -08:00
William Lam
5d570cb0df VyOS Automation
Signed-off-by: William Lam <william2003@gmail.com>
2020-02-09 08:05:00 -08:00
William Lam
a70e324282 VyOS Automation 2020-02-08 06:44:01 -08:00
Kyle Ruddy
1715d94892 Merge pull request #349 from freythman/master
Minor cleanup and platyPS help
2020-02-06 16:21:47 -05:00
Kyle Ruddy
e61587ac9b Merge pull request #350 from lamw/master
Workspace One Access + VCSA Password Policy Module
2020-02-06 16:19:24 -05:00
William Lam
b940759bbf Retrieve VCSA Password Policy 2020-02-06 13:00:55 -08:00
William Lam
6da888fd19 Merge remote-tracking branch 'upstream/master' 2020-02-06 12:58:58 -08:00
Matt Frey
118739b8fb Minor cleanup and platyPS help 2020-02-06 13:49:04 -06:00
Kyle Ruddy
33e038bbba Merge pull request #347 from rnelson0/patch-1
Make `-StartTime` argument to `Start-HVPool` take effect
2020-02-06 12:33:23 -05:00
William Lam
1b0dd9f42e Workspace One Access PS Module 2020-02-05 05:48:12 -08:00
Rob Nelson
3f430900cf Make -StartTime argument to Start-HVPool take effect 2020-01-23 16:33:43 -05:00
Kyle Ruddy
b1fa944909 Merge pull request #344 from jpgrall/master
Fixing Full File Path for Get-ContentLibraryItemFiles
2020-01-14 17:54:22 -06:00
Kyle Ruddy
22f0926161 Merge pull request #343 from mtelvers/master
Update VMware.HV.Helper.psm1
2020-01-14 17:53:21 -06:00
Kyle Ruddy
9db267a14c Merge pull request #340 from BaoyinQiao/bqiao-Encryption
Update VMware.VMEncryption.psm1
2020-01-14 17:52:51 -06:00
Kyle Ruddy
1d251bde8a Merge pull request #335 from lamw/master
Updating to latest CSP Auth API
2020-01-14 17:52:37 -06:00
Joshua Grall
254e062e52 Fixing path 2020-01-10 14:00:27 -06:00
jpgrall
2182f6ba6f Merge pull request #1 from vmware/master
updating fork
2020-01-10 13:52:20 -06:00
Kyle Ruddy
9c62ed266e Merge pull request #338 from freythman/master
Fixes for VMware.Hv.Helper
2020-01-08 12:58:04 -06:00
mtelvers
39cc775d25 Update VMware.HV.Helper.psm1
Add -clearGlobalEntitlement to Set-HVPool
2020-01-03 09:33:42 +00:00
Baoyin Qiao
0d4ba8b4dc Update VMware.VMEncryption.psm1
Update the Set-VMHostCryptoKey to make the RemoveKeys() only apply to vSphere 6.5 and not remove host key when it is in use.
2019-12-23 17:34:19 +08:00
Matt Frey
adfe78f236 One more place to iterate version number 2019-12-20 10:49:26 -06:00
Matt Frey
fa9a3c5026 Iterate version number to 1.3.1 2019-12-20 10:47:06 -06:00
Matt Frey
7a39d28314 Fix issue with manual parameterset on new-hvpool 2019-12-20 10:39:42 -06:00
Matt Frey
ab266189c2 Fix for Get-HVInternalName and GlobalEntitlementId 2019-12-20 10:28:54 -06:00
William Lam
6797eb8156 Updating to latest CSP Auth API 2019-11-30 07:43:08 -08:00
Kyle Ruddy
5e66c56742 Merge pull request #334 from tlindsay42/New-NSXTDistFirewall_action
Force New-NSXTDistFirewall Action value to be uppercase in payload
2019-11-21 18:23:59 -05:00
Kyle Ruddy
ddde669037 Merge pull request #330 from tlindsay42/New-NSXTDistFirewall_section_match
Use first section match for New-NSXTDistFirewall
2019-11-21 18:23:37 -05:00
Kyle Ruddy
39499c240b Merge pull request #324 from bluzytrix/CSP-API-Authorize-fix
Fixing the authorize request to use the recently updated API change. …
2019-11-21 18:23:13 -05:00
Troy Lindsay
a8a98e098e #333: New-NSXTDistFirewall force action uppercase 2019-11-21 03:19:02 -06:00
Kyle Ruddy
03272c1d2d Merge pull request #332 from kmruddy/master
Update ContentLibrary.psm1
2019-11-19 16:53:18 -05:00
Kyle Ruddy
5c210f3839 Update ContentLibrary.psm1
Updating per Issue 319
2019-11-19 16:50:57 -05:00
Kyle Ruddy
f11b9bd485 Merge pull request #331 from kmruddy/master
CISTag Module Improvements and Get-TriggeredAlarm Addition
2019-11-19 12:25:24 -05:00
Troy Lindsay
31e3accfe1 #328: New-NSXTDistFirewall use first section match 2019-11-19 09:51:20 -06:00
Kyle Ruddy
a7ff78fee0 Create Get-TriggeredAlarm.ps1
Adding a new function to view triggered alarms for vSphere objects
2019-11-18 19:09:41 -05:00
Kyle Ruddy
1a3e397661 Merge pull request #5 from vmware/master
Update fork
2019-11-18 19:06:54 -05:00
Kyle Ruddy
f83ceec0e8 Merge pull request #329 from lucdekens/master
On the off chance someone does not have PowerCLI installed
2019-11-18 18:56:53 -05:00
LucD
c1e181ea11 On the off chance someone does not have PowerCLI installed
Handle ToString() error when PCLI is not present

Signed-off-by: Luc Dekens <dekens.luc@gmail.com>
2019-11-18 13:34:53 +01:00
Kyle Ruddy
dc74d06a9c Merge pull request #327 from tlindsay42/New-NSXTGroup_matching_objects
Add New-NSXTGroup matching support
2019-11-15 15:43:15 -05:00
Troy Lindsay
478d913779 #326: Add New-NSXTGroup matching support 2019-11-14 10:44:55 -06:00
Akeem Jenkins
c7fcb1b186 Fixing the authorize request to use the recently updated API change. Refresh tokens visa the query param were deprecated.
https://console.cloud.vmware.com/csp/gateway/am/api/swagger-ui.html#/Authentication/getAccessTokenByApiRefreshTokenUsingPOST
2019-11-12 13:46:23 -07:00
Kyle Ruddy
ffe7d86921 Merge pull request #323 from tlindsay42/New-NSXTFirewall-Action
New-NSXTFirewall fix action
2019-11-01 10:03:04 +01:00
Kyle Ruddy
764123f903 Merge pull request #321 from tlindsay42/New-NSXTSegment-domainName
Add DomainName param to New-NSXTSegment
2019-11-01 10:01:50 +01:00
Kyle Ruddy
4d399cc5ef Merge pull request #318 from doogleit/feature/set-clusterdpm
Sample script for DPM configuration
2019-11-01 10:01:08 +01:00
Kyle Ruddy
f50c067e80 Merge pull request #316 from servisan/patch-1
Rearranged notes section
2019-11-01 10:00:04 +01:00
Troy Lindsay
49c0b44beb #322: New-NSXTFirewall fix action 2019-10-25 22:08:36 -05:00
Troy Lindsay
39a8539d97 #320: Add example for New-NSXTSegment -DomainName 2019-10-25 16:26:26 -05:00
Troy Lindsay
ae16ef6e52 #320: Add DomainName param to New-NSXTSegment
Allows end user to specify the DNS domain name for the network segment
2019-10-25 15:23:06 -05:00
Doug Taliaferro
1b7ea80342 Create Set-ClusterDpm.ps1
Configures Distributed Power Managment (DPM)
2019-10-11 09:30:38 -04:00
Sander
c506bf400a Rearranged notes section
Tabs and spaces cleaned up
2019-09-30 21:12:56 +02:00
Kyle Ruddy
81763c04c2 Merge pull request #4 from vmware/master
Updating the fork v2
2019-09-15 06:34:51 -04:00
Kyle Ruddy
e33fdc3453 Merge pull request #305 from thebillness/patch-1
Add Tag Assigments option
2019-09-15 06:34:02 -04:00
Kyle Ruddy
8b40cf94ec Merge pull request #306 from thibautnoben/master
Added vgpu support to new-hvfarm
2019-09-15 06:32:39 -04:00
Kyle Ruddy
03f685980f Merge pull request #311 from virtualex-itv/master
Update NewProfile.ps1
2019-09-15 06:32:11 -04:00
Kyle Ruddy
ef84482ee3 Merge pull request #304 from seanpmassey/master
Update VMware.VMC.psm1
2019-09-15 06:31:42 -04:00
Kyle Ruddy
b7e1d95e83 Merge pull request #3 from vmware/master
Update local fork
2019-09-15 06:30:12 -04:00
Alex Lopez
35095fbea7 Update NewProfile.ps1
Removed redundant display of (Core) in the console as it's displayed in the Title; minor cleanup.
2019-09-10 21:46:44 -04:00
Alex Lopez
46db5d0f50 Revert "Update NewProfile.ps1"
This reverts commit 323b9e88f7.
2019-09-10 21:42:15 -04:00
Alex Lopez
323b9e88f7 Update NewProfile.ps1
Removed redundant display (Core) in the console as it's displayed in the Title
2019-09-10 21:35:12 -04:00
Kyle Ruddy
7bd49b7779 Merge pull request #308 from virtualex-itv/master
PS Profile - Update
2019-09-10 13:35:49 -04:00
Alex Lopez
44fbae8d08 PS Profile - Update
Added PowerShell-Core compatibility for multi-OS support
2019-09-09 17:49:16 -04:00
Kyle Ruddy
23a6bcf09b Merge pull request #307 from lucdekens/Fingertips
PS Profile
2019-09-05 10:31:15 -04:00
LucD
c49cf2f721 PS Profile
As documented in http://www.lucd.info/2019/09/05/at-your-fingertips/

Signed-off-by: Luc Dekens <dekens.luc@gmail.com>
2019-09-05 13:25:31 +02:00
Thibaut Noben
3653dd09bc Removed spaces from name json file 2019-08-27 12:14:00 +02:00
Thibaut Noben
fef2f32adf Added vgpu support to new-hvfarm 2019-08-26 11:42:01 +02:00
Bill Wall
9de3195b32 Add Tag Assigments option
Added the optional ability to export/import tag assignments.
2019-08-08 09:30:43 -05:00
seanpmassey
0ba0b870af Update VMware.VMC.psm1 2019-08-07 15:27:37 -05:00
seanpmassey
2c79a86531 Create VMware.VMC.psm1 2019-08-07 15:22:51 -05:00
seanpmassey
5325596b2f Delete VMware.VMC.psm1 2019-08-07 15:17:43 -05:00
Kyle Ruddy
f703e1c275 Merge pull request #298 from lamw/master
Fixing DFW URL
2019-08-07 14:57:57 -04:00
Kyle Ruddy
ff54be27cd Merge pull request #302 from freythman/master
Update VMware.Hv.Helper
2019-08-07 14:57:32 -04:00
Matt Frey
db5cd60916 Improved New-HVPreinstalledApplication 2019-08-07 13:02:42 -05:00
Matt Frey
0cfbf635e7 Resolved issue with Get-HVEntitlement for user 2019-08-06 17:11:36 -05:00
Matt Frey
cbf397df24 Worked through PSScriptAnalyzer low hanging fruit 2019-08-06 14:28:16 -05:00
Matt Frey
337dc077a9 Update version. Minor formatting 2019-08-06 10:33:44 -05:00
seanpmassey
5f6294cf67 Update VMware.VMC.psm1
Add switch to Connect-VMCVIServer to allow the use of the management IP Address instead of the Public IP address.  This would be used when the DNS resolution for the VMC vCenter is set to the private IP.
2019-08-05 01:16:33 -05:00
Matt Frey
10647481f1 Added Set-HVApplication to update ApplicationInfo 2019-08-02 16:09:15 -05:00
Matt Frey
4badbe5ff5 New-HVManualApplication fixes 2019-07-30 16:34:02 -05:00
Matt Frey
4436510b02 Additional EntityID Type, and fixes 2019-07-30 16:33:31 -05:00
William Lam
0887967dc3 Actually fixing DFW URL :X 2019-07-09 06:44:12 -07:00
William Lam
9854561591 Fixing DFW URL 2019-07-09 06:42:41 -07:00
Kyle Ruddy
908f0ee95f Merge pull request #294 from lamw/master
Add {Get,Set,Remove} functions for Public IP & NAT
2019-07-01 09:02:23 -04:00
William Lam
823e150ef7 Add {Get,Set,Remove} functions for Public IP & NAT 2019-07-01 05:41:13 -07:00
Kyle Ruddy
ee017eb822 Merge pull request #293 from lamw/master
Fixing typo in HCX function name
2019-06-25 08:52:32 -04:00
William Lam
723acfd811 Fixing typo in function name 2019-06-25 05:43:05 -07:00
Kyle Ruddy
a849a67527 Merge pull request #292 from lamw/master
Fix in VMware.VMC + Enhancements to VMware.VMC.HCX Module
2019-06-19 09:13:30 -04:00
William Lam
64db788986 Merge branch 'master' into master 2019-06-19 06:10:10 -07:00
William Lam
864a6446f0 Add HCX Cloud Service functionality 2019-06-19 06:05:44 -07:00
William Lam
e7222d13f7 Fix Get-VMCOrg / Get-VMCSDDC to use -eq vs -match 2019-06-19 06:01:10 -07:00
Kyle Ruddy
b3e9ffc51d Update VMware.Community.CISTag.psm1
Issues fixed with "where-where-object" typos
Loop fixed for detecting the Object Type
Get/Remove-CISTagAssignment updated to work with Datastore objects
2019-06-14 16:59:43 -04:00
Kyle Ruddy
e9e8a14f19 Merge branch 'master' of https://github.com/kmruddy/PowerCLI-Example-Scripts 2019-06-14 10:10:26 -04:00
Kyle Ruddy
b5563cc11a Update VMware.Community.CISTag.psm1
Add Datastore support for New-CISTagAssignment
2019-06-14 10:10:09 -04:00
Kyle Ruddy
30fc960778 Merge pull request #2 from vmware/master
Update Fork
2019-06-14 08:21:43 -04:00
Kyle Ruddy
9c8a928cd7 Merge pull request #252 from isjwuk/patch-2
Create Get-Migrations.ps1
2019-06-09 10:04:51 +02:00
Kyle Ruddy
c1cc32db4b Merge pull request #291 from lamw/master
Added Get/Set NSX-T DNS Zone Configuration
2019-06-09 09:57:03 +02:00
William Lam
5f3f41ff44 Added Get/Set NSX-T DNS Zone Configuration 2019-06-08 13:13:19 -07:00
Kyle Ruddy
93e61262ff Merge pull request #287 from libertymutual/HCX-Infrastructure-Testing
Updates to VMware.HCX to aide end to end automation and infrastructure testing
2019-05-28 15:43:16 -04:00
Kyle Ruddy
fde0627160 Merge pull request #289 from lamw/master
Adding DRaaS Module + VMC module typo fix
2019-05-28 15:42:12 -04:00
William Lam
2a5eff4fd1 Adding DRaaS Module + VMC module typo fix 2019-05-28 06:20:26 -07:00
Kyle Ruddy
72864b7860 Merge pull request #288 from lamw/master
Added Get/New/Remove functions for Policy Based VPN
2019-05-09 10:02:18 -04:00
William Lam
5f1a86e78b Added Get/New/Remove functions for Policy Based VPN 2019-05-09 06:50:22 -07:00
Mark McGilly
0576034d74 Fix tabs instead of spaces 2019-05-09 04:57:23 -04:00
Mark McGilly
e8fdf541d4 Added Get-HcxLicense function
Added parameter to set Proxy Exclusions in Set-HcxProxy
Added ability to return UserName from Get-HcxNSXConfig
Added ability to return UserName, LookupServiceURL from Get-HcxVCConfig
2019-05-09 04:49:39 -04:00
Kyle Ruddy
f55ffc3b20 Merge pull request #282 from lucdekens/master
Save-PowerCLI v2.1
2019-05-08 10:33:35 -04:00
Kyle Ruddy
4c23a8a5d6 Merge pull request #285 from samiullasha/patch-3
Adding new functions to Application Pool
2019-05-08 10:29:15 -04:00
samiullasha
50559d9c6d Adding new functions to Application Pool
Adding the below new functions to Application Pool.
Get-HVApplication, Remove-HVApplication, New-HVManualApplication, Get-HVPreInstalledApplication, New-HVPreInstalledApplication
2019-05-08 18:26:00 +05:30
LucD
6f22da7f67 Save-PowerCLI v2.1
- fixed incorrect module version download
- added a working cleanup in End

Signed-off-by: Luc Dekens <dekens.luc@gmail.com>
2019-05-08 10:10:32 +02:00
Kyle Ruddy
c91a764ffe Merge pull request #277 from thibautnoben/master
get-hvfarm returned farmsummary
2019-05-07 06:52:07 -07:00
Kyle Ruddy
975a7baf8d Merge pull request #280 from lamw/master
Updates to VMC NSX-T & Content Library Module
2019-05-07 06:51:12 -07:00
William Lam
f4fc007bd5 Added Destination Resource Pool / VM Folder 2019-05-06 12:14:41 -07:00
William Lam
11181a95ec Added New-SubscribedContentLibrary function 2019-05-04 12:48:19 -07:00
Thibaut Noben
9e33329a96 Merge branch 'master' of github.com:thibautnoben/PowerCLI-Example-Scripts 2019-04-22 21:03:02 +02:00
Thibaut Noben
4c9fab7b6c removed return farm summary 2019-04-22 21:01:59 +02:00
William Lam
fd7429055d Add Remove-NSXTDistFirewallSection 2019-04-20 12:42:15 -07:00
William Lam
3134d1acd9 Removing -Name as required param + DROP keyword for action 2019-04-20 12:29:24 -07:00
Kyle Ruddy
942db3940d Merge pull request #275 from lamw/master
{Get/New/Remove} Route-Based VPN Functions
2019-04-20 13:41:43 +02:00
Kyle Ruddy
a9d6acc44b Merge pull request #274 from libertymutual/Enhancement-to-Get-HcxMigration
Get-HcxMigration: Allow array of MigrationIds
2019-04-20 13:41:23 +02:00
Kyle Ruddy
19d6151380 Merge pull request #272 from freythman/master
New VMware.Hv.Helper functions
2019-04-20 13:40:33 +02:00
William Lam
2cebd97c01 Fixed Distributed Firewall Rule Section + Remove NSX-T Service 2019-04-19 16:24:19 -07:00
William Lam
25450e9003 Fix No DHCP NSX-T Segment creation 2019-04-15 09:15:40 -07:00
thibautnoben
f2b9ac0647 Merge pull request #1 from vmware/master
mastersync
2019-04-14 19:16:19 +02:00
William Lam
0cfb39779b Fix "Successfully" typo 2019-04-13 14:11:49 -07:00
William Lam
423e752404 Adding Route Based VPN functions 2019-04-13 13:41:51 -07:00
Mark McGilly
b95886558f Get-HcxMigration: Allow array of MigrationIds 2019-04-09 10:55:34 -04:00
Matt Frey
3b5f501d72 Address Issue #180 2019-04-08 00:56:49 -05:00
Matt Frey
db8f4407a0 Address Issue #273 2019-04-05 11:19:38 -05:00
Matt Frey
31d785fc14 Merge branch 'master' into master 2019-04-04 11:29:51 -05:00
Kyle Ruddy
1760d4c963 Merge pull request #270 from freythman/patch-1
Address Issue #269
2019-03-29 18:52:09 -04:00
Kyle Ruddy
d12619c64d Merge pull request #271 from kmruddy/master
Add SDDC Cluster Functions
2019-03-26 21:16:42 -07:00
Kyle Ruddy
528eca815c Add SDDC Cluster Functions
Add the following SDDC Cluster Functions:
Get-VMCSDDCCluster
New-VMCSDDCCluster
Remove-VMCSDDCCluster
2019-03-27 00:12:03 -04:00
Kyle Ruddy
74dd5ef9fb Merge pull request #1 from vmware/master
Update kmruddy fork
2019-03-26 21:01:02 -07:00
Kyle Ruddy
45ac4a47fb Revert "Add SDDC Cluster Functions"
This reverts commit fe603f60d6.
2019-03-27 00:00:01 -04:00
Kyle Ruddy
fe603f60d6 Add SDDC Cluster Functions
Added the following functions:
Get-VMCSDDCCluster
New-VMCSDDCCluster
Remove-VMCSDDCCluster
2019-03-26 23:55:29 -04:00
Matt Frey
1c54a37fbd Shortened ImageType to Type 2019-03-19 15:06:54 -07:00
William Lam
d95806ea2f Fix CGW/MGW scope 2019-03-19 10:31:20 -07:00
William Lam
bda5a5a276 Fixing the default Scope label for CGW FW Rules 2019-03-18 13:39:52 -07:00
William Lam
72a5555860 Fixing logic for SRC/DST Infra Group 2019-03-15 10:46:43 -07:00
William Lam
29fbb5bc59 Fixing optional for Source/Destination Groups + typo 2019-03-15 05:13:37 -07:00
Matt Frey
360e190300 New HV Functions for vCenter and BaseImage 2019-03-14 19:08:01 -05:00
William Lam
b8b48e40f8 Add support for both Infra Group/Scopes related to CGW Edge Fireweall 2019-03-14 12:00:27 -07:00
Matt Frey
ecc12a1884 Address Issue #269
Both flash parameters for `New-HVPool` were limited to the validate set of `LINKED_CLONE`. This updates them to be valid for all desktop types, since it is applicable to all desktop types. See https://vdc-download.vmware.com/vmwb-repository/dcr-public/3721109b-48a5-4ffb-a0ad-6d6a44f2f288/ff45dfca-1050-4265-93ef-4e7d702322e4/vdi.resources.Desktop.AdobeFlashSettings.html for details.
2019-03-13 14:43:33 -05:00
Conor Tolan
bbc6d0f775 Started tests for VMCFirewall.
Fixed incorrect function call in sddc version test.
2019-02-27 22:23:05 +00:00
Conor Tolan
3e09f0a601 Wrote tests covering get VMC SDDC Version
Fixed up get VMC Hosts a bit.
2019-02-25 22:28:23 +00:00
Conor Tolan
f926508d1f Added test for Get-VMCVMHost, complicated object mocking. 2019-02-25 21:09:18 +00:00
Conor Tolan
c01427f6f4 Added new tests. 2019-02-24 16:06:47 +00:00
Conor Tolan
2bb82249ca Added new tests for get default creds
Added test for not connected route in functions to increase coverage.
2019-02-24 14:41:16 +00:00
Conor Tolan
b5111e1fab Adding a VMC code coverage script to invoke the coverage report. 2019-02-23 19:33:24 +00:00
Conor Tolan
5c833d4ce5 Wraped all the tests inModuleScope for invoke-pester invocation.
Moved function name into module scope.
2019-02-23 18:56:44 +00:00
Conor Tolan
b90c83ac56 Created tests for get VMC Task
Trimed out excess fom get SDDC parameters in the object.
2019-02-23 18:06:09 +00:00
Conor Tolan
f642290b2d Tidied up the object creation in tests. 2019-02-23 17:41:23 +00:00
Conor Tolan
a95e01066d Renamed VMC Org test file.
Added VMC Sddc test file.
2019-02-23 16:40:31 +00:00
Conor Tolan
6c578f7b78 Added mock write-host to clean up output.
Added the general creation of the $object needed to mock the function.
2019-02-23 16:37:03 +00:00
Conor Tolan
3a61850b41 Randomly wrote over import. undone. 2019-02-20 22:26:26 +00:00
Conor Tolan
783319a624 Finished org tests 2019-02-20 22:17:59 +00:00
Conor Tolan
f9ca007ae5 Added two pester tests for Get-VMCCommand and Connect-VMCVIServer. 2019-02-18 21:57:52 +00:00
Kyle Ruddy
71915cde79 Merge pull request #264 from kmruddy/master
Create Move-DatastoreCluster.ps1
2019-02-13 18:59:13 -05:00
Kyle Ruddy
0e318d3e07 Create Move-DatastoreCluster.ps1
Moves a datastore cluster to a new location
2019-02-13 15:57:51 -08:00
Kyle Ruddy
780e830205 Merge pull request #263 from lamw/master
Added NSX-T Overview Info
2019-02-08 08:59:36 -05:00
William Lam
2212477dff Added NSX-T Overview Info 2019-02-08 05:28:10 -08:00
Kyle Ruddy
481845717c Merge pull request #260 from lamw/master
Added Set-VMCSDDC function to rename SDDC
2019-02-04 12:36:48 -05:00
William Lam
407be173e4 Adding NSX-T Routing Table 2019-02-02 07:34:16 -08:00
Kyle Ruddy
6cc6634628 Create Set-NetworkAdapterOpaqueNetwork.ps1
Code sample provided as part of KB 65149: https://kb.vmware.com/s/article/65149
2019-02-01 14:19:32 -05:00
William Lam
9ff4c4f48c Merge branch 'master' into master 2019-01-23 05:48:32 -08:00
William Lam
216ee7386f Module for managing vCenter CEIP Settings 2019-01-23 05:25:14 -08:00
William Lam
ff3d297e69 Fixing typo for creating NSX-T GW Firewall 2019-01-17 08:07:15 -08:00
William Lam
59ab2785e3 Added Set-VMCSDDC function to rename SDDC 2019-01-12 15:56:50 -08:00
Kyle Ruddy
5efdf01810 Merge pull request #259 from lamw/master
Fixed CSP Auth due to API change + Refresh Token expiry info
2019-01-10 18:59:55 -05:00
William Lam
24556bbe19 Fixed CSP Auth due to API change + Refresh Token expiry info 2019-01-10 15:48:43 -08:00
Kyle Ruddy
83899d2b7b Merge pull request #258 from kmruddy/master
Create Script: Save-PowerCLI.ps1
2019-01-10 14:50:51 -05:00
Kyle Ruddy
e35e17a04d Update Save-PowerCLI.ps1
Updating function with v2 additions:
- Dynamic RequiredVersion parameter
- Simple parameter to handle the nested version folders
- Address the potential of downloading multiple module folders twice
2019-01-10 09:44:58 -05:00
Kyle Ruddy
9073d8f3b2 Create Save-PowerCLI.ps1
Adding function to download specific versions of PowerCLI from an online repository
2019-01-10 09:42:14 -05:00
Kyle Ruddy
a2fef29a71 Merge pull request #257 from kmruddy/master
Update VMware.Community.CISTag.psm1
2019-01-10 09:23:56 -05:00
Kyle Ruddy
d758b5ba4c Merge pull request #256 from lamw/master
Updating Metdata file + Minor Typo/Fixes
2019-01-04 12:54:13 -05:00
William Lam
0d75606d99 Updating psd1 2019-01-04 06:54:17 -08:00
William Lam
a2c896b81b Fixing typo + Remove-NSXTDistFirewall function 2019-01-04 06:52:09 -08:00
Kyle Ruddy
16528c92b8 Merge pull request #254 from PARAMESHO/master
Set-HVApplicationIcon not behaving correctly with .ico and .bmp files
2019-01-03 16:16:10 -05:00
Kyle Ruddy
9845e9d16b Merge pull request #255 from lamw/master
Adding "Get" functions for Distribugted FW rules
2019-01-03 16:15:34 -05:00
William Lam
5571a8900a Added {New,Remove}-NSXTDisFirewall functions 2019-01-03 12:21:50 -08:00
William Lam
25cfffa14f Adding "Get" functions for Distribugted FW rules 2019-01-02 10:07:40 -08:00
PARAMESHO
06d018c7a6 Set-HVApplicationIcon not behaving correctly with .ico and .bmp files
When bmp/ico image files are used as customized application icons, short
cuts feature on Horizon Client is facing the issues in rendering. Bug
2168320 has been reported for this issue. We have decided to block all
the non-png image files for the customization of application icons.

Testing:
Tested with the changes. Working as expected. Refer review
https://reviewboard.eng.vmware.com/r/1446121 for more details.
2019-01-02 21:55:26 +05:30
Kyle Ruddy
e6a4c09e6d Merge pull request #253 from lamw/master
Fixing Get/New-NSXTSegment due to NSX-T Policy API change
2018-12-21 13:01:04 -05:00
William Lam
81e60245d0 Fixing New-NSXTSegment (Network property not required) 2018-12-21 09:58:37 -08:00
William Lam
4652495ece Fixing Get/New-NSXTSegment due to NSX-T Policy API change 2018-12-20 06:35:45 -08:00
Chris
8953a512fe Create Get-Migrations.ps1
Quick function for listing the currently running and recently finished VM migrations
2018-12-20 10:28:31 +00:00
Kyle Ruddy
bfbcbc8faa Update VMware.Community.CISTag.psm1
Add VIServer capabilities to Get-CISTag
2018-12-18 19:37:42 -05:00
Kyle Ruddy
bf33a58232 Merge pull request #251 from kmruddy/master
Update VMware.Community.CISTag.psm1
2018-12-18 15:01:35 -05:00
Kyle Ruddy
44879d8c25 Update VMware.Community.CISTag.psm1
Updated Synopsis and Examples
2018-12-18 15:00:39 -05:00
Kyle Ruddy
334f58476c Merge pull request #250 from kmruddy/master
Introduction of a new Tagging module
2018-12-18 14:08:20 -05:00
Kyle Ruddy
3372f3faf3 Introduction of a new Tagging module
Introduction of a new module which uses the REST based CIS API to perform tagging operations. More info:  http://blogs.vmware.com/PowerCLI/2018/12/new-module-for-tag-management.html
2018-12-18 11:16:26 -05:00
Kyle Ruddy
c906e8a772 Merge pull request #249 from lamw/master
Updated URLs to new NSX-T Policy API endpoints
2018-12-14 11:04:41 -05:00
William Lam
faa125fd83 Updated URLs to new NSX-T Policy API endpoints 2018-12-14 05:54:25 -08:00
Kyle Ruddy
0246451fe6 Merge pull request #233 from jerrak0s/master
backup-esxi-host-configuration
2018-12-12 11:31:20 -05:00
Kyle Ruddy
9f851b38a1 Merge pull request #246 from jackwmc4/master
Added Set-HVInstantCloneMaintenance to VMware.Hv.Helper
2018-12-12 11:29:35 -05:00
Kyle Ruddy
dcc04b8d88 Merge pull request #244 from StuebiSoft/master
removed brake for issue vmware#74
2018-12-12 11:28:52 -05:00
Kyle Ruddy
5dc0145c92 Merge pull request #243 from admoseley/admoseley-update-11222018
Verbiage for DeleteFromDisk if False
2018-12-12 11:28:20 -05:00
Kyle Ruddy
726eb7e181 Merge pull request #245 from jpgrall/master
Adding file path to Get-ContentLibraryItemFiles
2018-12-12 11:27:45 -05:00
Kyle Ruddy
c384c84892 Merge pull request #247 from jasemccarty/master
Initial VMware.VsanEncryption Pull Request
2018-12-10 15:40:37 -05:00
Jase McCarty
70edda9043 Merge branch 'master' of https://github.com/jasemccarty/PowerCLI-Example-Scripts 2018-12-10 13:37:31 -07:00
Jase McCarty
82c7889cec Initial Push
This is an initial push to PowerCLI-Example-Tools
2018-12-10 13:36:22 -07:00
Jase McCarty
76eadeba8a Initial vSAN Encryption Module
vSAN Encryption Module
2018-12-07 16:11:18 -07:00
Jake Robinson
ac650e4a36 Merge pull request #241 from dzl84/master
Initial commit of VMware.VCGChecker module
2018-12-06 15:22:20 -05:00
Jack McMichael
bd983dcd7f Update VMware.HV.Helper.psm1
Moving messaging so it doesn't repeat over and over.
2018-12-05 13:00:12 -07:00
Jack McMichael
cea57f11d5 Update VMware.HV.Helper.psm1
Added per feedback
2018-12-04 14:05:08 -07:00
Jack McMichael
c7a19c795e Update VMware.HV.Helper.psm1
Changed booleans to switches after looking at other uses in the code.
2018-12-02 17:01:26 -07:00
Jack McMichael
e5920d40f5 Update VMware.HV.Helper.psm1
Updating exports to be more organized
2018-12-01 21:15:51 -07:00
Jack McMichael
4ef4cce5ef Update VMware.HV.Helper.psm1 2018-12-01 21:01:25 -07:00
Jack McMichael
53b8377c53 Update VMware.HV.Helper.psm1 2018-12-01 20:59:06 -07:00
Jack McMichael
f9953ec994 Update VMware.HV.Helper.psm1
Added Set-HVInstantCloneMaintenance function.
2018-12-01 20:55:50 -07:00
Jack McMichael
937f213451 Update VMware.HV.Helper.psm1
Added functions to starting and starting Instant Clone maintenance operations on a host for Horizon 7.x
2018-12-01 17:15:38 -07:00
jpgrall
7c7f8d3fbf Update ContentLibrary.psm1
Adding logic incase backing isn't a datastore.
2018-11-30 09:55:46 -06:00
jpgrall
971e4aeec7 Adding file path to Get-ContentLibraryItemFiles
Adding the support to display the actual path of the file on the datastore.  This is useful when needing to mount an ISO that is hosted on the Content Library.  Also, replaced references of "Libary" to "Library" throughout.
2018-11-30 09:43:40 -06:00
Zhoulin Dai
0caddf91fa Merge branch 'master' of github.com:dzl84/PowerCLI-Example-Scripts 2018-11-30 17:17:43 +08:00
Zhoulin Dai
560739222d Fix bugs 2018-11-30 17:15:13 +08:00
Maik Stübner
3e28c516a7 removed brake for issue vmware#74 2018-11-30 09:12:16 +01:00
dzl84
1ce8b927ce Update README.md 2018-11-27 17:17:46 +08:00
Adrian Moseley
82b32df293 Verbage for DeleteFromDisk if False 2018-11-21 16:53:37 -06:00
Zhoulin Dai
0743c67799 Initial commit of VMware.VCGChecker module 2018-11-19 22:41:26 +08:00
Kyle Ruddy
cb9e57e185 Merge pull request #237 from franciosi/patch-1
Update README.md
2018-11-15 07:54:45 -05:00
Kyle Ruddy
374baa8c7f Merge pull request #240 from Magneet/master
Bugfix for viewStorageAcceleratorSettings
2018-11-15 07:52:06 -05:00
Wouter Kursten
ce32e7ab1d bugfix viewStorageAcceleratorSettings 2018-11-15 10:07:01 +01:00
Wouter Kursten
bcff03c896 Merge pull request #8 from vmware/master
resync
2018-11-15 10:05:40 +01:00
Franciosi
37c9effbd7 Update README.md
Small typo fix
2018-11-02 15:08:07 -03:00
Kyle Ruddy
a7b81266bd Merge pull request #231 from doogleit/feature/set-customattributesinguestinfo
Script to set custom attributes in guestinfo
2018-11-02 13:25:22 -04:00
Kyle Ruddy
b5d8306bd4 Merge pull request #230 from doogleit/feature/set-tagsinguestinfo
Sample script to set VM tags in the guestinfo
2018-11-02 13:21:15 -04:00
Kyle Ruddy
56cab055f6 Merge pull request #235 from lucdekens/master
Updated VMware.VMC
2018-11-02 13:19:53 -04:00
Kyle Ruddy
934fcc45af Merge pull request #234 from lamw/master
Updated NSX-T function + new HCX functions
2018-11-02 13:19:29 -04:00
William Lam
578d3c5deb Updated to include configuringn Proxy Settings 2018-11-01 07:33:40 -07:00
LucD
3904b416b3 XRef for VMC services and functions
Requires ImportExcel module
2018-10-25 10:43:04 +02:00
LucD
b68dc6c4e0 Updated VMware.VMC
Fix issue #176
Added functions:
- Get-VMCEdge
- Get-VMCEdgeNic
- Get-VMCEdgeStatus
- Get-VMCEdgeNicStat
- Get-VMCEdgeUplinkStat
2018-10-25 10:02:23 +02:00
William Lam
48d2db91d8 Added new functions to configure HCX Manager 2018-10-09 13:36:45 -07:00
Gerasimos Alexiou
501bfa7fd2 backup-esxi-host-configuration
backup-esxi-host-configuration powershell script
2018-10-09 22:48:07 +03:00
Doug Taliaferro
4246cfc71f Script to set custom attributes in guestinfo 2018-10-04 19:53:08 -04:00
Doug Taliaferro
0581d89cbe Sample script to set VM tags in the guestinfo 2018-10-03 21:16:50 -04:00
Doug Taliaferro
b25c280714 Sample script to set VM tags in the guestinfo 2018-10-03 21:09:18 -04:00
William Lam
82b5b2eb1e Adding VM & Criteria types into Get-NSXTGroup function 2018-09-27 15:55:12 -07:00
William Lam
ea4ab5f61d Updated function to support Cloud Motion & other HCX Migrations 2018-09-24 14:17:39 -07:00
Kyle Ruddy
ed5b8eaf5e Merge pull request #225 from Magneet/master
Added functions & fixes
2018-09-21 12:58:21 -04:00
Kyle Ruddy
2bb2cd451f Merge pull request #224 from crlogic/master
Additional Set Commands added & re-wrote a couple earlier get-cmdlets
2018-09-21 12:57:31 -04:00
Kyle Ruddy
3a1afa39fa Merge pull request #226 from lamw/master
Initial PS Module for new NSX-T Policy API in VMC
2018-09-21 12:56:26 -04:00
William Lam
8402e69993 Fixed caps 2018-09-20 05:04:18 -07:00
William Lam
a1c3c01f05 Added NSX-T Policy Firewall cmdlets 2018-09-20 04:56:43 -07:00
AndyG
5052044ae1 Added Comment to Set-NSXTIPPool
Added Comment to Set-NSXTIPPool
2018-09-19 22:08:39 -05:00
AndyG
3a022777d3 Removed unnecessary JSON conversion in template
Removed unnecessary JSON conversion in template
2018-09-19 22:06:01 -05:00
AndyG
179cfa82be Set-NSXTIPPool finally working
Set-NSXTIPPool finally working
2018-09-19 21:35:23 -05:00
AndyG
39c179ae1a Added Get-NSXTClusterNode
Added Get-NSXTClusterNode
2018-09-19 15:01:25 -05:00
William Lam
691709dd40 Initial commit for HCX PowerShell Module 2018-09-19 05:34:54 -07:00
William Lam
16b32f1b03 Additional NSX-T Policy API functions 2018-09-19 05:34:20 -07:00
William Lam
526f6a8ad9 Check $global:DefaultVMCServers.IsConnected during NSX-T Proxy Connect 2018-09-18 14:47:36 -07:00
AndyG
e8b64517c7 Added Get/Set/Remove IPAMIPBlock
Added Get/Set/Remove IPAMIPBlock
2018-09-18 16:45:59 -05:00
AndyG
9e569b139a Added ShouldProcess to Set functions
Added ShouldProcess to Set functions
2018-09-18 09:32:36 -05:00
Wouter Kursten
5ee5c5d09a added functions 2018-09-17 09:39:07 +02:00
Wouter Kursten
21fe9a8d55 Merge pull request #7 from r3mdh/master
Update VMware.HV.Helper.psm1
2018-09-17 09:34:59 +02:00
William Lam
9c427a4886 Merge branch 'master' of https://github.com/lamw/PowerCLI-Example-Scripts 2018-09-15 05:32:29 -07:00
William Lam
14ecf2107d Initial Commit 2018-09-15 05:32:19 -07:00
AndyG
10f1f26ec1 Don't want to export templates
Don't want to export templates
2018-09-14 16:16:27 -04:00
AndyG
9a4acf5c57 Adding Set Commands
Adding Set Commands
2018-09-14 15:51:11 -04:00
AndyG
2103438f8a Added Help & Get-NSXTLogicalRouterPorts
Added Help & Get-NSXTLogicalRouterPorts
2018-09-14 12:27:31 -04:00
Kyle Ruddy
c49f893044 Merge pull request #222 from freythman/patch-1
Update VMware.HV.Helper.psm1
2018-09-14 09:52:20 -04:00
Kyle Ruddy
4c88b337aa Merge pull request #218 from crlogic/master
Added Get-TraceFlows
2018-09-14 09:51:35 -04:00
Kyle Ruddy
e51b3050e2 Merge pull request #217 from mycloudrevolution/Validate-ESXiPackages
add Module with Validate-ESXiPackages Function
2018-09-14 09:50:20 -04:00
Kyle Ruddy
b32256de5f Merge pull request #223 from lamw/master
SDDC Summary data using GET /sddc
2018-09-14 09:49:24 -04:00
AndyG
c34b602bf3 Get-NSXTRoutingTable & Get-NSXTForwardingTable now work
Get-NSXTRoutingTable & Get-NSXTForwardingTable now work. Thanks for Nick from VMW for pointing out the .help was incorrect and submitting a PR to update the API guide.
2018-09-14 08:58:53 -04:00
William Lam
5b74c582b7 Fixing typo 2018-09-12 12:23:37 -07:00
William Lam
33bb7f6b3a Added {Get,New,Remove}-VMCPublicIP function 2018-09-12 11:38:49 -07:00
AndyG
75a2562d97 Updates to Set-NSXTraceFlow
Updates to Set-NSXTraceFlow. Added more comment and aligned variable names with api
2018-09-12 13:45:38 -04:00
AndyG
a753d8251b Major refactoring
Major refactoring - replaced hashtables with classes.  Can now accept pipeline input.
2018-09-12 13:31:03 -04:00
Matt Frey
760c534cf7 Update VMware.HV.Helper.psm1
Added -DeleteFromDisk parameter to Remove-HVMachine
Performed some minor cleanup (remove trailing whitespaces, capitalization)
2018-09-07 11:02:42 -05:00
William Lam
127252196f SDDC Summary data using GET /sddc 2018-09-05 11:46:41 -07:00
Michael D. Harlan
7086f2c823 Update VMware.HV.Helper.psm1 2018-08-28 00:01:03 -04:00
Kyle Ruddy
dc191995f3 Merge pull request #219 from kmruddy/master
VMWonAWS Firewall Rule Accelorator Script
2018-08-27 14:36:31 -04:00
Kyle Ruddy
cca008ed27 VMWonAWS Firewall Rule Accelorator Script
Addition of the script version of the VMware Cloud on AWS Firewall Rule Accelorator functionality
2018-08-24 19:49:32 -04:00
AndyG
1f6ec2c2c2 First try at a set- function - does not work!
First try at a set- function. Does not work!  Not clear how to resolve, the .create method ignores required parameters; looking for ideas.
2018-08-24 16:36:48 -04:00
AndyG
3c5e8363ed Added Get-TraceFlowsObservations
Added Get-TraceFlowsObservations. Will add to export if it looks ok.
2018-08-24 16:34:11 -04:00
AndyG
cff2f29b97 Added Get-TraceFlows
Added Get-TraceFlows.  Will add to export list if it looks good.
2018-08-24 16:32:35 -04:00
mycloudrevolution
3d29306cb6 add Module with Validate-ESXiPackages Function 2018-08-24 14:20:51 +02:00
Kyle Ruddy
121c1bd2db Merge pull request #215 from crlogic/master
Added Get-NSXTTransportNodes
2018-08-21 16:23:04 -04:00
AndyG
a332102392 Added Get-NSXTTransportNodes to FunctionsToExport
Added Get-NSXTTransportNodes to FunctionsToExport
2018-08-21 16:07:17 -04:00
Kyle Ruddy
3366bb25e0 Merge pull request #214 from dmilov/patch-1
Functions for reading a VM's vmsd file content and search for specifi…
2018-08-21 15:47:07 -04:00
Kyle Ruddy
7b22e46772 Merge pull request #213 from Magneet/master
adding functions
2018-08-21 15:46:21 -04:00
Kyle Ruddy
a36bdf923d Merge pull request #216 from kmruddy/master
Update 1 Host Script
2018-08-21 15:45:55 -04:00
Kyle Ruddy
8ae75925af Update 1 Host Script
Updating the script to not require the association of an AWS Account, plus some other general corrections.
2018-08-21 15:40:01 -04:00
AndyG
61a9929bca Added Get-NSXTTransportNodes
Added Get-NSXTTransportNodes
2018-08-20 15:52:41 -04:00
dmilov
50b76efef6 Functions for reading a VM's vmsd file content and search for specific settings
To be able to identify certain VM has linked clone children a specific setting has to be read from the VM's snapshot config file. For the purpose of this I created two functions that enable reading full content of the vmsd file as well as searching for a specific setting in the vmsd file content.
2018-08-14 17:03:12 +03:00
Wouter Kursten
a24fbf4e95 added extra query deifinitions
added Eventsummaryview and GlobalApplicationEntitlementInfo as they are newly added since PowerCLI 10.1.1
2018-08-13 09:07:37 +02:00
Wouter Kursten
fc270dc256 Added Clear-HVEventDatabase 2018-07-24 20:41:51 +02:00
Wouter Kursten
348eb1899e added function Get-HVEventDatabase 2018-07-24 19:53:53 +02:00
Wouter Kursten
b096ace8ae added function Set-HVEventDatabase 2018-07-24 19:33:41 +02:00
Kyle Ruddy
fe6932a5fe Merge pull request #212 from lamw/master
PowerShell module for VMware Cloud Services Portal API
2018-07-24 02:00:24 +03:00
William Lam
ad76a77c20 PowerShell module for VMware Cloud Services Portal API 2018-07-23 13:23:39 -07:00
Kyle Ruddy
3eb90cf148 Merge pull request #207 from Magneet/master
Several changes
2018-07-19 14:56:09 +03:00
Kyle Ruddy
c2261080ff Merge pull request #210 from lamw/master
Added support for VMTX Template support for VMC-based Content Library
2018-07-18 01:00:50 +03:00
Wouter Kursten
355d499301 remove break issue #211
remove break issue https://github.com/vmware/PowerCLI-Example-Scripts/issues/211
2018-07-17 20:40:58 +02:00
William Lam
d9768c21ac VMTX Template support for VMC-based Content Library 2018-07-17 05:21:32 -07:00
Wouter Kursten
2200c4d25d fix 2018-07-11 14:17:56 +02:00
Wouter Kursten
f567922869 Several changes
added new-hvhomesite, get-hvhomesite
removed new-hvpassword (never pulled to master)
2018-07-06 09:32:23 +02:00
Kyle Ruddy
e345493124 Merge pull request #206 from simonfangyingzhang/master
Update VMware.VMEncryption.psd1
2018-07-03 15:15:08 -04:00
simonfangyingzhang
e36208e2db Update VMware.VMEncryption.psd1
VMware.VimAutomation.Core 10.1.0.8344055 instead of VMware.VimAutomation.Core 10.1.0.8346946
2018-07-03 03:25:29 +01:00
Kyle Ruddy
189dbd13b5 Merge pull request #205 from kmruddy/master
Add VMWonAWS_InviteUsers.ps1
2018-06-29 08:46:46 -04:00
Kyle Ruddy
b88f3a286a Add VMWonAWS_InviteUsers.ps1
Script which can be used to automate the process of adding new users to a specified VMware Cloud on AWS Organization
2018-06-29 08:38:24 -04:00
Kyle Ruddy
a8b54df5ff Merge pull request #203 from kmruddy/master
Reorganization of VMWonAWS Script Resources
2018-06-13 16:06:00 -04:00
Kyle Ruddy
0a1e5a65c3 Reorganization of VMWonAWS Script Resources
Reorganizing VMWonAWS scripting resources into the appropriate folder.
2018-06-13 16:04:54 -04:00
Kyle Ruddy
dd5f70caca Merge pull request #202 from kmruddy/master
Adding Script to Deploy a 1 Node SDDC for VMW on AWS
2018-06-13 14:31:16 -04:00
Kyle Ruddy
2c23ecb414 Adding Script to Deploy a 1 Node SDDC for VMW on AWS
Adding a new script in order to automate the deployment of a 1 node
SDDC for VMware Cloud on AWS
2018-06-13 14:19:58 -04:00
Kyle Ruddy
eff217ab5d Merge remote-tracking branch 'vmware/master' 2018-06-13 14:13:42 -04:00
lucdekens
b90c1ecad0 Merge pull request #199 from vmware/VMFSIncrease-module
VMFSIncrease - bug fix
2018-05-30 19:54:26 +02:00
lucdekens
3dda8cc639 VMFSIncrease - bug fix
Fixed bug in New-VmfsDatastoreIncrease -Datastore <ds> -Expand -IncreaseSizeGB <size>
2018-05-30 19:53:01 +02:00
Kyle Ruddy
c09c40b8b2 Merge pull request #198 from chongsein/master
Add vTPM cmdlets
2018-05-24 14:55:47 -04:00
Chong Yeo
de8d765719 Add the following Cmdlets for vTPM Support and also change minor version from 1.1 to 1.2
Add-Vtpm
Remove-Vtpm
Get-VtpmCsr
Set-VtpmCert
Get-VtpmCert
2018-05-23 14:18:13 -07:00
Chong Yeo
de1197d0e6 Revert "1. Add the following Cmdlets for vTPM Support"
This reverts commit 8dbea3ac24.

Reverting because there were some merge conflicts that got away.
2018-05-23 11:50:25 -07:00
Kyle Ruddy
40026511e9 Merge pull request #197 from chongsein/master
Add cmdlets for vTPM Support
2018-05-22 15:55:16 -04:00
Wouter Kursten
8c0e1985b1 Merge pull request #4 from vmware/master
.
2018-05-22 20:30:44 +02:00
Chong Yeo
8dbea3ac24 1. Add the following Cmdlets for vTPM Support
Add-Vtpm
Remove-Vtpm
Get-VtpmCsr
Set-VtpmCert
Get-VtpmCert
2.  Minor Version Change from 1.1 to 1.2
2018-05-22 10:38:35 -07:00
Wouter Kursten
73d7eaa992 added function to create vmware.hv.securestring password 2018-05-22 19:22:02 +02:00
Kyle Ruddy
642e83e6fd Merge pull request #195 from kmruddy/master
Adding Per-VM EVC Module
2018-05-21 11:55:55 -04:00
Kyle Ruddy
aaae686d7c Adding Per-VM EVC Module
Per-VM EVC functionality is available through the vSphere API. This
module adds the ability to manage these settings through high-level
functions like Get-VMEvcMode, Set-VMEvcMode, Remove-VMEvcMode
2018-05-21 11:50:19 -04:00
Kyle Ruddy
69397e76ce Merge remote-tracking branch 'vmware/master' 2018-05-21 11:44:56 -04:00
Kyle Ruddy
3121a12808 Merge pull request #194 from lamw/master
Added logic to handle Instant Clone from a poweredOn Source VM
2018-05-21 11:44:22 -04:00
Kyle Ruddy
e2ad078168 Merge pull request #192 from cmcmahonVMW/patch-1
Updates needed for v2.0
2018-05-21 11:43:46 -04:00
Kyle Ruddy
c6607eb188 Merge pull request #191 from Magneet/master
removed showing of plain password
2018-05-21 11:43:09 -04:00
Kyle Ruddy
e5c0d95cb0 Merge remote-tracking branch 'vmware/master' 2018-05-21 11:28:31 -04:00
William Lam
fb5c9e248a Fixing typo in poweredOn string 2018-05-20 06:39:49 -07:00
William Lam
7c28fbc894 Adding logic to handle PoweredOn Source VM 2018-05-20 05:12:50 -07:00
cmcmahonVMW
60217aaa5c Updates needed for v2.0
In v2.0 of the tool, the URI for Get-XVCMStatus changed from /api/ping to /api/status, updated line 15.  
In v2.0 of the tool, there were a number of changes necessary for New-XVCMRequest. Updated the Notes on Lines 145-173 to reflect new parameters, changed behavior and removed parameters. Added $opType on line 176 and 202 for the Operation type new to v2.0.  Removed line 181 and 196 for Source Cluster because it is no longer needed. Modified $DstCluster to accept null and removed the String Type definition to allow null to not be converted or the task creation will fail because it expects null as the assigned value.  Added $DstHost to line 184 and 199 to allow destination host input to override $DstCluster.
2018-05-10 00:29:15 -04:00
Wouter Kursten
748adc6f27 removed showing of plain password 2018-05-09 19:29:20 +02:00
Kyle Ruddy
83b4f78c72 Merge pull request #190 from lamw/master
Parentless Instant Clone for vSphere 6.7
2018-05-01 18:24:07 -04:00
Kyle Ruddy
e83d70081c Merge pull request #185 from jrodsguitar/master
Adding Remove-HVMachine function
2018-04-30 15:41:33 -04:00
William Lam
8694c40210 Parentless Instant Clone for vSphere 6.7 2018-04-30 05:22:46 -07:00
jrodsguitar
f4ba11fe75 Added Remove-HVMachine to Export-ModuleMember 2018-04-29 12:27:58 -07:00
jrodsguitar
056df11512 Fixed PR conflict and Merged 2018-04-29 12:23:26 -07:00
Kyle Ruddy
9d929431b0 Merge pull request #184 from Magneet/master
Adding functions
2018-04-28 11:29:03 -04:00
Kyle Ruddy
f584dae11e Merge pull request #187 from mycloudrevolution/VMware-vCD-Module_Update
vCD-Module _Update
2018-04-28 11:28:05 -04:00
Kyle Ruddy
5852e5bf7f Merge pull request #188 from simonfangyingzhang/master
update VMware.VMEncryption for vSphere 6.7
2018-04-28 11:26:52 -04:00
Wouter Kursten
948a5539a9 Merge pull request #3 from Magneet/wkursten_dev
Wkursten dev
2018-04-28 17:05:13 +02:00
Wouter Kursten
fc02a60eaf fixes for podfederations and sites 2018-04-28 17:04:32 +02:00
simonfangyingzhang
95138e128f Update VMware.VMEncryption.psd1 2018-04-27 05:10:09 +01:00
simonfangyingzhang
60aafba7ae Update VMware.VMEncryption.psd1 2018-04-27 05:03:22 +01:00
simonfangyingzhang
3b44fbcf20 Update VMware.VMEncryption.psd1 2018-04-27 04:53:24 +01:00
simonfangyingzhang
9bd66f1a66 Update VMware.VMEncryption.psm1 2018-04-27 04:50:10 +01:00
simonfangyingzhang
049e621fb6 Update VMware.VMEncryption.psm1 2018-04-27 04:45:44 +01:00
simonfangyingzhang
29719d6ca7 Update VMware.VMEncryption.psm1 2018-04-27 04:42:18 +01:00
simonfangyingzhang
13649b8e35 Update VMware.VMEncryption.psm1 2018-04-27 04:32:55 +01:00
simonfangyingzhang
df9d71d4e0 Update VMware.VMEncryption.psm1
1, added new function Set-VMCryptoUnlock
2, deprecating functions related to KMServer and KMSCluster from VMware.VMEncryption
2018-04-27 04:22:42 +01:00
simonfangyingzhang
d70bee9f99 Update VMware.VMEncryption.psd1 2018-04-27 04:19:53 +01:00
simonfangyingzhang
d4f4e64ca3 Deprecating functions related to KMServer and KMSCluster from VMware.VMEncryption 2018-04-27 04:18:51 +01:00
Wouter Kursten
c4c92f7a87 Added Site functions 2018-04-26 10:27:36 +02:00
Markus Kraus
d987a7535b vCD-Module _Update 2018-04-25 22:48:38 +02:00
Wouter Kursten
373b909095 added multiple podfederation functions 2018-04-25 11:52:50 +02:00
Jose Rodriguez
054d127f12 Making sure Get-ViewAPIService is there. 2018-04-09 02:04:20 -07:00
Jose Rodriguez
7235de655d Various modifications per feedback.
Now using Get-ViewAPIService to connect. Now using $services variable instead of $viewapi.
2018-04-09 01:58:24 -07:00
Jose Rodriguez
245cacae25 Revert "Revert "Adding Remove-HVMachine function""
This reverts commit cdff3035cc.
2018-04-08 20:48:30 -07:00
Jose Rodriguez
cdff3035cc Revert "Adding Remove-HVMachine function"
This reverts commit c265c50447.
2018-04-08 20:46:38 -07:00
Jose Rodriguez
c265c50447 Adding Remove-HVMachine function 2018-04-08 15:00:08 -07:00
Wouter Kursten
969d31fcfb added pod to get-hvhealth 2018-04-08 10:56:34 +02:00
Wouter Kursten
5a0bb408ba Added get-hvhealth 2018-04-07 11:26:06 +02:00
Wouter Kursten
fa6be16f34 Merge pull request #2 from vmware/master
sync
2018-04-07 09:19:25 +02:00
alanrenouf
bad590dbc2 Added Vmware Cloud on AWS Sample to deploy 100 VMs 2018-03-27 22:05:56 -07:00
alanrenouf
a68325cc50 Added Vmware Cloud on AWS Sample to deploy 100 VMs 2018-03-27 22:04:23 -07:00
Brian Graf
009a298bff VMware Cloud on AWS Integrations Demos - Code
Code from Re:Invent 2017 on integrations with AWS services. The
re:Invent session can be watched on youtube here:
https://www.youtube.com/watch?v=lGq806eej54
2018-03-09 10:46:46 -07:00
Kyle Ruddy
58c110be5a Merge pull request #175 from kmruddy/master
Updating VMC module to 1.2
2018-03-06 20:45:01 -05:00
Kyle Ruddy
b2d62e84ad Merge pull request #174 from spartyzik/master
Get-HVPoolStorageObject bug fix
2018-03-06 20:44:46 -05:00
Kyle Ruddy
f8d285e9b5 Merge pull request #171 from Magneet/master
replaced return of vcenter vm id's
2018-03-06 20:43:05 -05:00
Kyle Ruddy
03041fea20 Update Module for Logical Network Functions
Updating module version to include Get/New/Remove-VMCLogicalNetwork
functions
2018-03-06 17:52:29 -05:00
Kyle Ruddy
e240f04de9 Merge remote-tracking branch 'vmware/master' 2018-03-06 16:24:26 -05:00
Ed Symanzik
aaed5597d6 Get-HVPoolStorageObject bug fix
Function prepares variable $datastoreList but uses $datastoreInfoList.
2018-03-06 09:26:22 -05:00
Kyle Ruddy
08cbf5276c Reorganizational Update
Reorganizational Update - Putting scripts into the Scripts folder
2018-03-05 14:45:32 -05:00
Wouter Kursten
9282c79c86 getnext placed on the wrong spot 2018-03-03 10:23:22 +01:00
Brian Graf
74dcf88b05 Updated 2018-02-27 17:50:38 -07:00
Brian Graf
e53df3dc57 Initial Commit
Need to clean up and convert to uber function
2018-02-27 14:39:22 -07:00
Wouter Kursten
cda9bd36e1 replaced return of vcenter vm id's
replaced some return of vcenter vm id's that gave back some hardly usefull information to the user. Now it gives a successfully add... message
2018-02-26 22:01:33 +01:00
Kyle Ruddy
a6f8d7db15 Merge pull request #166 from Magneet/master
Multiple fixes, removal and new functions in vmware.hv.helper
2018-02-12 09:53:50 -05:00
Kyle Ruddy
1fef21bad6 Merge pull request #165 from mtelvers/master
Updates to Remove-HVEntitlement
2018-02-12 09:51:28 -05:00
Wouter Kursten
f7da4a963f added reset-hvmachine 2018-02-10 15:44:12 +01:00
Wouter Kursten
f0f5ec7967 Removed get-hvpodsession, added get-hvglobalsession
get-hvpodsession only got a count + naming was incorrect (it was global but name said pod) get-hvglobalsession actually enumerates all global sessions
2018-02-10 10:32:10 +01:00
Wouter Kursten
0109a2d0d2 Update VMware.HV.Helper.psm1 2018-02-05 16:31:46 +01:00
Wouter Kursten
5dfaf81e73 added if for groupfilter in get-hventitlement
https://github.com/vmware/PowerCLI-Example-Scripts/issues/167
2018-02-05 10:55:56 +01:00
Wouter Kursten
e73ababdcc Added get-hvlocalsession
added this new cmdlet to make it easier to get a list of all sessions from the local pod. Method is based on the way find-hvmachine works to work around the maximum of 2000 results the queries normally have.
2018-02-04 14:03:23 +01:00
Wouter Kursten
f1669f8794 Merge pull request #1 from vmware/master
sync
2018-02-04 13:59:58 +01:00
mtelvers
3e50b4ebde Update to Set-HVMachine to ease the assignment to users machines 2018-02-03 16:35:33 +00:00
mtelvers
9c2b190faa Update to Remove-HVEntitlement()
See Issue #163
2018-02-03 13:55:28 +00:00
mtelvers
a4a976e835 Merge pull request #1 from vmware/master
refresh from master
2018-02-03 10:31:33 +00:00
Kyle Ruddy
e887ac3152 Merge pull request #162 from alanrenouf/master
updated module with VMC Firewall functions
2018-02-01 10:22:19 -05:00
alanrenouf
8a4abe7dd4 Added a VMC example script 2018-01-31 22:18:58 -08:00
alanrenouf
a9c83ab50a Added a VMC Firewall Rules example script 2018-01-31 21:40:34 -08:00
alanrenouf
e0e4a56826 updated module with VMC Firewall functions 2018-01-31 20:40:39 -08:00
Kyle Ruddy
cd2e8503ba Merge pull request #160 from benmeadowcroft/master
Initial commit to Examples of SRM-Cmdlets
2018-01-31 11:21:21 -05:00
Ben Meadowcroft
61aead2685 Initial commit to Examples of SRM-Cmdlets 2018-01-30 21:03:35 -08:00
Kyle Ruddy
4c645a7393 Merge pull request #156 from kmruddy/master
Add PowerCLI_FixNestedFolders.ps1
2018-01-18 11:39:22 -05:00
Kyle Ruddy
ecdd19911f Add PowerCLI_FixNestedFolders.ps1
Add script to help remove the nested version folders when moving
PowerCLI module folders from systems with PoSh 5.x to 4.0/3.0 systems
that can’t properly understand those versioned folders.

More info:
https://blogs.vmware.com/PowerCLI/2018/01/powercli-offline-installation-
walkthrough.html
2018-01-18 08:37:38 -08:00
Kyle Ruddy
5e844cf2cf Merge remote-tracking branch 'vmware/master' 2018-01-18 08:31:53 -08:00
Kyle Ruddy
b21e3d4fc0 Merge pull request #154 from JoshuaCooper/master
Fixing spelling errors and grammar issues
2018-01-11 16:33:05 -05:00
cloudcowboyco
5bee9abf62 Fixing spelling errors and grammar issues 2018-01-11 15:57:17 -05:00
Kyle Ruddy
02286dbe53 Update VMToolsManagement.psm1
Update the quotes on line 1222 so that the module import no longer errors out.
2018-01-09 14:55:28 -05:00
Kyle Ruddy
23f215be35 Update VMToolsManagement.psm1
Added advanced function: Get-VMToolsUpgradePolicy
Updated the following advanced functions to add functionatlity:
- Set-VMToolsUpgradePolicy - Supports UpgradeAtPowerCycle and Manual
- Update-VMToolsConfInVM - Supports all log levels now
Misc other minor updates: 
- cmdlets changed to 'advanced function'
- 'vcetner' changed to 'vcenter'
2018-01-05 16:13:39 -05:00
Kyle Ruddy
7217cec777 Merge pull request #149 from lamw/master
PowerCLI Module using Cross vCenter Migration Utility Fling API
2017-12-20 12:44:16 -05:00
William Lam
b5800f0eff PowerCLI Module using Cross vCenter Migration Utility Fling API 2017-12-20 08:37:38 -08:00
lucdekens
dd9a0a16fa Merge pull request #148 from vmware/rCisTag-module
Rcistag module
2017-12-02 23:27:44 +01:00
Kyle Ruddy
b39e6394db Merge remote-tracking branch 'vmware/master' 2017-10-14 15:53:39 -04:00
314 changed files with 66180 additions and 1840 deletions

4
.gitignore vendored
View File

@@ -5,6 +5,7 @@
#VS Code Files
*.vscode
/.vs
# Windows image file caches
Thumbs.db
@@ -48,4 +49,5 @@ $RECYCLE.BIN/
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
.apdisk
/Modules/VMware.vSphere.SsoAdmin/ForPSGallery/VMware.vSphere.SsoAdmin

View File

@@ -1,42 +0,0 @@
# PowerCLI-Example-Scripts
VMWARE TECHNOLOGY PREVIEW LICENSE AGREEMENT
Notice to User: This Technology Preview License Agreement (the “Agreement”) is a CONTRACT between you (either an individual or a single entity) (“you” or “Licensee”) and VMware, Inc. (“VMware”), which covers your use of the Technology Preview Software (as defined below). If you do not agree to the terms of this Agreement, then do not install or use the Technology Preview Software. By explicitly accepting this Agreement, however, or by installing, copying, downloading, accessing, or otherwise using the Technology Preview Software, you are acknowledging and agreeing to be bound by the following terms.
1. DEFINITIONS. (a) “Technology Preview Software” means the unreleased, concept version of VMwares software, in object form only, excluding any Open Source Software provided with the such software, and the media and Documentation provided by VMware to Licensee and for which Licensee is granted a use license pursuant to this Agreement. (b) “Documentation” means the printed and online written reference material furnished to Licensee in conjunction with the Technology Preview Software, including, without limitation, instructions, testing guidelines, and end user guides. (c) “Intellectual Property Rights” shall mean all intellectual property rights, including, without limitation, patent, copyright, trademark, and trade secret. (d) “Open Source Software” means various open source software components provided with the Technology Preview Software that are licensed to you under the terms of the applicable license agreements included with such open source software components or other materials for the Technology Preview Software. (e) “Updates” means a modification, error correction, bug fix, new release, or other update to or for the Technology Preview Software.
2. LICENSE GRANT, USE AND OWNERSHIP.
(a) Limited License. Subject to the terms and conditions of this Agreement, VMware grants to Licensee a non-exclusive, non-transferable license (without the right to sublicense) (i) to use the Technology Preview Software in accordance with the Documentation solely for purposes of internal testing and evaluation, (ii) to use the Documentation provided with the Technology Preview Software in support of Licensees authorized use of the Technology Preview Software, and (iii) to copy the Technology Preview Software for archival or backup purposes, provided that all titles and trademarks, copyright, and restricted rights notices are reproduced on such copies.
(b) Evaluation Feedback. The purpose of this limited license is the testing and evaluation of the Technology Preview Software as set forth above. In furtherance of this purpose, Licensee shall provide feedback to VMware concerning the functionality and performance of the Technology Preview Software from time to time as reasonably requested by VMware, including, without limitation, identifying potential errors and improvements. Licensee will provide the requested feedback in a manner that is convenient to Licensee subject to reasonable availability of Licensees personnel. Notwithstanding the foregoing, prior to Licensee disclosing to VMware any information under this Agreement that Licensee considers proprietary or confidential, Licensee shall obtain VMwares prior written approval to disclose such information to VMware, and without such prior written approval from VMware, Licensee shall not disclose any such information to VMware. VMware may use feedback to improve or enhance its products and, accordingly, you hereby grant to VMware a non-exclusive, perpetual, irrevocable, royalty-free, transferable, worldwide right and license, with the right to sublicense, to use, reproduce, disclose, distribute, perform, display, modify, prepare derivative works of and otherwise exploit the feedback and other information without restriction in any manner now known or in the future conceived and to make, use, sell, offer to sell, import and export any product or service that incorporates the feedback and other information.
(c) Restrictions. Licensee shall not copy or use the Technology Preview Software (including the Documentation) except as expressly permitted in this Agreement. Except to the extent that any applicable mandatory laws prevent VMware restraining Licensee from doing so, Licensee will not, and will not permit any third party to, sublicense, rent, copy, modify, create derivative works of, translate, reverse engineer, decompile, disassemble, or otherwise reduce to human perceivable form any portion of the Technology Preview Software or accompanying Documentation. Without limiting the generality of the foregoing, Licensee shall not use the Technology Preview Software for Licensees product development or any other commercial purpose. The Technology Preview Software and all performance data and test results, including without limitation, benchmark test results (collectively “Performance Data”) relating to the Technology Preview Software are the Confidential Information of VMware, and will be treated in accordance with the terms of Section 4 of this Agreement. Accordingly, Licensee shall not publish or disclose to any third party any Performance Data relating to the Technology Preview Software.
(d) Ownership. VMware shall own and retain all right, title and interest in and to the Intellectual Property Rights in the Technology Preview Software, subject only to the limited license expressly set forth in Section 2(a) hereof. Licensee does not acquire any other rights, express or implied, in the Technology Preview Software. ALL RIGHTS NOT EXPRESSLY GRANTED HEREUNDER ARE RESERVED TO VMWARE.
(e) No Support Services. VMware is under no obligation to support the Technology Preview Software in any way or to provide any Updates to Licensee. In the event VMware, in its sole discretion, supplies any Update to Licensee, the Update shall be deemed Technology Preview Software under this Agreement and shall be subject to the terms and conditions of this Agreement.
(f) Third-Party Software. The Technology Preview Software may enable a computer to run multiple instances of third-party guest operating systems and application programs. Licensee acknowledges that Licensee is responsible for obtaining any licenses necessary to operate any third-party software, including guest operating systems and application programs.
(g) Open Source Software. Except for Sections 5, 6 and 7, the terms and conditions of this Agreement shall not apply to any Open Source Software accompanying the Technology Preview Software. Any such Open Source Software is provided under the terms of the open source license agreement or copyright notice accompanying such Open Source Software or in the open source licenses file accompanying the Technology Preview Software.
3. TERM AND TERMINATION. Licensees rights with respect to the Technology Preview Software will terminate upon the earlier of (a) automatic expiration of the Technology Preview Software based on the system date, or (b) termination by VMware, in its sole discretion, of Licensees rights with respect to the Technology Preview Software provided under this Agreement upon notice on the VMware website. Upon any expiration or termination of rights with respect to the Technology Preview Software under this Agreement, the rights and licenses granted to Licensee under this Agreement shall immediately terminate, and Licensee shall immediately cease using, and will destroy or render practically inaccessible the Technology Preview Software, Documentation, and all other tangible items in Licensees possession or control that contain Confidential Information. The rights and obligations of the parties set forth in Sections 2(b), 2(c), 2(d), 2(e), 2(f), 2(g), 3, 4, 5, 6 and 7 shall survive termination or expiration of this Agreement for any reason.
4. CONFIDENTIALITY. (a) Confidentiality. "Confidential Information" means the Technology Preview Software, all information regarding the Technology Preview Software (including any trade secrets, know-how, inventions, techniques, processes, and algorithms embodied in the Technology Preview Software), Documentation, Performance Data, any Updates, and other information provided by VMware to Licensee under this Agreement, whether disclosed orally, in writing, or by examination or inspection, other than information that Licensee can demonstrate (i) was already known to Licensee, other than under an obligation of confidentiality, at the time of disclosure; (ii) was generally available in the public domain at the time of disclosure to Licensee; (iii) became generally available in the public domain after disclosure other than through any act or omission of Licensee; (iv) was subsequently lawfully disclosed to Licensee by a third party without any obligation of confidentiality; or (v) was independently developed by Licensee without use of or reference to any information or materials disclosed by VMware or its suppliers. If Licensee is required to disclose Confidential Information by applicable law or court order, Licensee shall notify VMware of the required disclosure promptly in writing and shall cooperate with VMware in any lawful action to contest or limit the scope of the required disclosure. Confidential Information shall include, without limitation, any information relating to VMware products, product roadmaps, and other technical, business, financial and product development plans, forecasts and strategies. Licensee shall not use any Confidential Information for any purpose other than as expressly authorized under this Agreement. In no event shall Licensee use the Technology Preview Software or any Confidential Information to develop, manufacture, market, sell, or distribute any product or service, including any VMware products. Licensee shall not disclose any Confidential Information to any third party. Without limiting the foregoing, Licensee shall use at least the same degree of care that it uses to prevent the disclosure of its own confidential information of like importance, but in no event less than reasonable care, to prevent the disclosure of such Confidential Information. (b) Additional Confidentiality Restrictions for Highly Confidential Technology Preview Software. For certain Technology Preview Software designated by VMware as highly confidential (“Highly Confidential Technology Preview Software”) in VMwares correspondence to you regarding this Technology Preview Software or in any Documentation, additional heightened confidentiality restrictions designated below will apply. (i) Licensee shall limit dissemination of Highly Confidential Technology Preview Software and related information concerning product features, future technologies and roadmaps only to Information Technology teams and/or software/solutions development teams of Licensee designated by VMware, and only to individuals on those teams who have a need to know the Confidential Information for purposes expressly authorized under this Agreement. For clarity and without limiting the generality of the foregoing, Licensee shall not disseminate any Highly Confidential Technology Preview Software to Licensee's sales and marketing field organizations. Licensee will assign an employee who will be primarily responsible (“Primary Contact”) for ensuring that the terms of this Agreement are complied with. (ii) Licensee acknowledges that damages for improper disclosure of Highly Confidential Technology Preview Software or related information concerning product features, future technologies and roadmaps may be irreparable and that monetary damages would be inadequate to compensate VMware for any breach of this Agreement. In the event that VMware reasonably believes that Licensee has disseminated certain of such Highly Confidential Technology Preview Software or related information concerning product features, future technologies and roadmaps to an unauthorized party, Licensee will be immediately removed from VMwares Technology Preview Software program and will not be permitted to participate in any VMware Technology Preview Software program in the future. Additionally, all rights and licenses granted to Licensee under this Agreement shall immediately terminate in accordance with Section 3 herein (Term and Termination). (c) Remedies. In addition to all other remedies available in law or otherwise, VMware is entitled to seek equitable relief, including injunctive relief, against the threatened breach of this Agreement or the continuation of any such breach.
5. LIMITATION OF LIABILITY. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE IS PROVIDED WITHOUT CHARGE FOR LIMITED EVALUATION PURPOSES. ACCORDINGLY, THE TOTAL LIABILITY OF VMWARE AND ITS LICENSORS ARISING OUT OF OR RELATED TO THIS AGREEMENT SHALL NOT EXCEED US$100.00. TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT SHALL VMWARE OR ITS LICENSORS HAVE LIABILITY FOR ANY INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL, OR CONSEQUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, OR LOSS OF BUSINESS INFORMATION), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY (INCLUDING WITHOUT LIMITATION, TORT, STATUTE, CONTRACT OR OTHER), EVEN IF VMWARE AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
6. WARRANTY DISCLAIMER. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE, OPEN SOURCE SOFTWARE, DOCUMENTATION, AND ANY UPDATES MAY CONTAIN ERRORS AND ARE PROVIDED FOR LIMITED EVALUATION ONLY. THE TECHNOLOGY PREVIEW SOFTWARE, THE OPEN SOURCE SOFTWARE, THE DOCUMENTATION, AND ANY UPDATES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE. VMWARE AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. Licensee acknowledges that VMware has not publicly announced the availability of the Technology Preview Software, that such Technology Preview Software may contain features currently under development, that VMware has not promised or guaranteed to Licensee that such Technology Preview Software will be announced or made available to anyone in the future, that VMware has no express or implied obligation to Licensee to announce or introduce the Technology Preview Software, that VMware has no obligation to introduce a product similar to or compatible with the Technology Preview Software, and that any version number (if any) referenced is subject to change and does not in any way represent VMwares commitment to release any product in the future. Accordingly, Licensee acknowledges that any research or development that it performs regarding the Technology Preview Software or any product associated with the Technology Preview Software is done entirely at Licensees own risk. Specifically, the Technology Preview Software may contain features, functionality or modules that will not be included in the production version of the Technology Preview Software, if released, or that will be marketed separately for additional fees.
7. OTHER PROVISIONS. (a) Governing Law. This Agreement, and all disputes arising out of or related thereto, shall be governed by and construed under the laws of the State of California without reference to conflict of laws principles. All such disputes shall be subject to the exclusive jurisdiction of the state and federal courts located in Santa Clara County, California, and the parties agree and submit to the personal and exclusive jurisdiction and venue of these courts. The United Nations Convention for the International Sale of Goods shall not apply. (b) Export Control.  The Technology Preview Software is of United States origin and is provided subject to the U.S. Export Administration Regulations. Diversion contrary to U.S. law is prohibited. Without limiting the foregoing, you agree that (i) you are not, and are not acting on behalf of, any person who is a citizen, national, or resident of, or who is controlled by the government of, Cuba, Iran, North Korea, Sudan, or Syria, or any other country to which the United States has prohibited export transactions; (ii) you are not, and are not acting on behalf of, any person or entity listed on the U.S. Treasury Department list of Specially Designated Nationals and Blocked Persons, or the U.S. Commerce Department Denied Persons List or Entity List; and (iii) you will not use the Technology Preview Software for, and will not permit the Technology Preview Software to be used for, any purposes prohibited by law, including, without limitation, for any prohibited development, design, manufacture or production of missiles or nuclear, chemical or biological weapons. U.S. Export Control Classification Numbers (ECCNs) may be found at VMware help page: http://www.vmware.com/help/export-control. (c) Modification. This is the entire agreement between the parties relating to the subject matter hereof and all other terms are rejected. No waiver or modification of this Agreement shall be valid unless in writing signed by each party. The waiver of a breach of any term hereof shall in no way be construed as a waiver of any other term or breach hereof. If any provision of this Agreement is held by a court of competent jurisdiction to be contrary to law, the remaining provisions of this Agreement shall remain in full force and effect. (d) Data Privacy. Licensee agrees that VMware may process technical and related usage information about Licensees use of the Technology Preview Software for statistical and analytical purposes. Usage information is collected strictly for internal statistical and analytical purposes for the development of VMware products and services. Licensee understands that any log files generated in order to obtain support from VMware may contain sensitive, confidential or personal information. Licensee should consider obfuscating any logs before sending them to VMware. VMwares privacy policy (http://www.vmware.com/help/privacy.html) shall apply.
8. ASSIGNMENT. Licensee shall not assign this Agreement or any rights or obligations hereunder, directly or indirectly, by operation of law, merger, acquisition of stock or assets, or otherwise, without the prior written consent of VMware. Any attempted assignment or transfer in violation of the foregoing will be null and void. Subject to the foregoing, this Agreement shall inure to the benefit of and be binding upon the parties and their respective successors and permitted assigns.
9. CONTACT INFORMATION. If you have any questions about this Agreement, please direct all correspondence to: VMware, Inc., 3401 Hillview Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. VMware is a trademark of VMware, Inc. and is registered in the U.S. and numerous other countries.
Rev. 2014Mar10

12
LICENSE.txt Normal file
View File

@@ -0,0 +1,12 @@
PowerCLI-Example-Scripts
Copyright 2021 VMware, Inc.
BSD 2-Clause License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,204 +1,554 @@
Function Backup-VCSAToFile {
<#
.NOTES
===========================================================================
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Backup-VCSAToFile {
<#
.NOTES
===========================================================================
Created by: Brian Graf
Date: October 30, 2016
Date: October 30, 2016
Organization: VMware
Blog: www.vtagion.com
Twitter: @vBrianGraf
Blog: www.vtagion.com
Twitter: @vBrianGraf
Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function will allow you to create a full or partial backup of your
VCSA appliance. (vSphere 6.5 and higher)
VCSA appliance. (vSphere 6.5 and higher)
.DESCRIPTION
Use this function to backup your VCSA to a remote location
.EXAMPLE
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword = "VMw@re123"
$Comment = "First API Backup"
$LocationType = "FTP"
$location = "10.144.99.5/vcsabackup-$((Get-Date).ToString('yyyy-MM-dd-hh-mm'))"
$LocationUser = "admin"
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$locationPassword = "VMw@re123"
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword = "VMw@re123"
$Comment = "First API Backup"
$LocationType = "FTP"
$location = "10.144.99.5/vcsabackup-$((Get-Date).ToString('yyyy-MM-dd-hh-mm'))"
$LocationUser = "admin"
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$locationPassword = "VMw@re123"
PS C:\> Backup-VCSAToFile -BackupPassword $BackupPassword -LocationType $LocationType -Location $location -LocationUser $LocationUser -LocationPassword $locationPassword -Comment "This is a demo" -ShowProgress -FullBackup
.NOTES
Credit goes to @AlanRenouf for sharing the base of this function with me which I was able to take and make more robust as well as add in progress indicators
You must be connected to the CisService for this to work, if you are not connected, the function will prompt you for your credentials
Credit goes to @AlanRenouf for sharing the base of this function with me which I was able to take and make more robust as well as add in progress indicators
You must be connected to the CisService for this to work, if you are not connected, the function will prompt you for your credentials
A CisService can also be supplied as a parameter.
If a -LocationType is not chosen, the function will default to FTP.
The destination location for a backup must be an empty folder (easiest to use the get-date cmdlet in the location)
-ShowProgress will give you a progressbar as well as updates in the console
-CommonBackup will only backup the config whereas -Fullbackup grabs the historical data as well
The destination location for a backup must be an empty folder (easiest to use the get-date cmdlet in the location)
-ShowProgress will give you a progressbar as well as updates in the console
-CommonBackup will only backup the config whereas -Fullbackup grabs the historical data as well
#>
param (
[Parameter(ParameterSetName=FullBackup)]
[switch]$FullBackup,
[Parameter(ParameterSetName=CommonBackup)]
[switch]$CommonBackup,
[ValidateSet('FTPS', 'HTTP', 'SCP', 'HTTPS', 'FTP')]
$LocationType = "FTP",
$Location,
$LocationUser,
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$LocationPassword,
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword,
$Comment = "Backup job",
[switch]$ShowProgress
)
Begin {
if (!($global:DefaultCisServers)){
Add-Type -Assembly System.Windows.Forms
[System.Windows.Forms.MessageBox]::Show("It appears you have not created a connection to the CisServer. You will now be prompted to enter your vCenter credentials to continue" , "Connect to CisServer") | out-null
$Connection = Connect-CisServer $global:DefaultVIServer
} else {
$Connection = $global:DefaultCisServers
}
if ($FullBackup) {$parts = @("common","seat")}
if ($CommonBackup) {$parts = @("common")}
}
Process{
$BackupAPI = Get-CisService com.vmware.appliance.recovery.backup.job
$CreateSpec = $BackupAPI.Help.create.piece.CreateExample()
$CreateSpec.parts = $parts
$CreateSpec.backup_password = $BackupPassword
$CreateSpec.location_type = $LocationType
$CreateSpec.location = $Location
$CreateSpec.location_user = $LocationUser
$CreateSpec.location_password = $LocationPassword
$CreateSpec.comment = $Comment
try {
$BackupJob = $BackupAPI.create($CreateSpec)
}
catch {
throw $_.Exception.Message
}
param (
[Parameter(ParameterSetName='FullBackup')]
[switch]$FullBackup,
[Parameter(ParameterSetName='CommonBackup')]
[switch]$CommonBackup,
[ValidateSet('FTPS', 'HTTP', 'SCP', 'HTTPS', 'FTP', 'SMB', 'SFTP')]
$LocationType = "FTP",
$Location,
$LocationUser,
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$LocationPassword,
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword,
$Comment = "Backup job",
[Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers,
[switch]$ShowProgress
)
Begin {
if ($CisServer.IsConnected) {
Write-Verbose "Connected to $($CisServer.Name)"
$connection = $CisServer
} elseif ($CisServer.gettype().name -eq "String") {
Write-Host "Prompting for CIS Server credentials. Connecting to $($CisServer)."
$Connection = Connect-CisServer $CisServer
} elseif ($global:DefaultCisServers) {
$connection = $global:DefaultCisServers
} elseif ($global:DefaultVIServer) {
Write-Host "Prompting for CIS Server credentials. Connecting to $($global:DefaultVIServer.name)."
$Connection = Connect-CisServer $global:DefaultVIServer
}
if (!$Connection) {
Write-Error "It appears you have not created a connection to the CisServer. Please Connect First and try command again. (Connect-CisServer)"
}
if ($FullBackup) {$parts = @("common","seat")}
if ($CommonBackup) {$parts = @("common")}
If ($ShowProgress){
do {
$BackupAPI.get("$($BackupJob.ID)") | select id, progress, state
$progress = ($BackupAPI.get("$($BackupJob.ID)").progress)
Write-Progress -Activity "Backing up VCSA" -Status $BackupAPI.get("$($BackupJob.ID)").state -PercentComplete ($BackupAPI.get("$($BackupJob.ID)").progress) -CurrentOperation "$progress% Complete"
start-sleep -seconds 5
} until ($BackupAPI.get("$($BackupJob.ID)").progress -eq 100 -or $BackupAPI.get("$($BackupJob.ID)").state -ne "INPROGRESS")
Write-Progress -Activity "Backing up VCSA" -Completed
$BackupAPI.get("$($BackupJob.ID)") | select id, progress, state
}
Else {
$BackupJob | select id, progress, state
}
}
End {}
# Per github issue 468 (https://github.com/vmware/PowerCLI-Example-Scripts/issues/468) adding some logic to account for SFTP/SCP handling in versions after VC 7.0.
$vCenterVersionNumber = (Get-CisService -Name 'com.vmware.appliance.system.version').get().version
if ( ($vCenterVersionNumber -ge 6.5 -AND $vCenterVersionNumber -lt 7.0 ) -AND $LocationType -eq 'SFTP' ) {
write-warning 'VCSA Backup for versions 6.5 and 6.7 use SCP, not SFTP. Adjusting the LocationType accordingly.'
$LocationType = 'SCP'
}
if ( $vCenterVersionNumber -ge 7.0 -AND $LocationType -eq 'SCP' ) {
write-warning 'VCSA Backup starting with version 7.0 use SFTP and not SCP. Adjusting the LocationType accordingly.'
$LocationType = 'SFTP'
}
}
Process{
$BackupAPI = Get-CisService 'com.vmware.appliance.recovery.backup.job'
$CreateSpec = $BackupAPI.Help.create.piece.CreateExample()
$CreateSpec.parts = $parts
$CreateSpec.backup_password = $BackupPassword
$CreateSpec.location_type = $LocationType
$CreateSpec.location = $Location
$CreateSpec.location_user = $LocationUser
$CreateSpec.location_password = $LocationPassword
$CreateSpec.comment = $Comment
try {
$BackupJob = $BackupAPI.create($CreateSpec)
} catch {
throw $_.Exception.Message
}
If ($ShowProgress){
do {
$BackupAPI.get("$($BackupJob.ID)") | Select-Object id, progress, state
$progress = ($BackupAPI.get("$($BackupJob.ID)").progress)
Write-Progress -Activity "Backing up VCSA" -Status $BackupAPI.get("$($BackupJob.ID)").state -PercentComplete ($BackupAPI.get("$($BackupJob.ID)").progress) -CurrentOperation "$progress% Complete"
Start-Sleep -seconds 5
} until ($BackupAPI.get("$($BackupJob.ID)").progress -eq 100 -or $BackupAPI.get("$($BackupJob.ID)").state -ne "INPROGRESS")
Write-Progress -Activity "Backing up VCSA" -Completed
$BackupAPI.get("$($BackupJob.ID)") | Select-Object id, progress, state
} Else {
$BackupJob | Select-Object id, progress, state
}
}
End {}
}
Function Get-VCSABackupJobs {
<#
.NOTES
===========================================================================
Created by: Brian Graf
Date: October 30, 2016
Organization: VMware
Blog: www.vtagion.com
Twitter: @vBrianGraf
.NOTES
===========================================================================
Created by: Brian Graf
Date: October 30, 2016
Organization: VMware
Blog: www.vtagion.com
Twitter: @vBrianGraf
Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
Get-VCSABackupJobs returns a list of all backup jobs VCSA has ever performed (vSphere 6.5 and higher)
.DESCRIPTION
Get-VCSABackupJobs returns a list of all backup jobs VCSA has ever performed
.EXAMPLE
PS C:\> Get-VCSABackupJobs
.EXAMPLE
PS C:\> Get-VCSABackupJobs -ShowNewest -CisServer "vcserver.sphere.local"
.NOTES
The values returned are read as follows:
YYYYMMDD-hhmmss-vcsabuildnumber
You can pipe the results of this function into the Get-VCSABackupStatus function
Get-VCSABackupJobs | select -First 1 | Get-VCSABackupStatus <- Most recent backup
YYYYMMDD-hhmmss-vcsabuildnumber
You can pipe the results of this function into the Get-VCSABackupStatus function
Get-VCSABackupJobs | select -First 1 | Get-VCSABackupStatus <- Most recent backup
#>
param (
[switch]$ShowNewest
)
Begin {
if (!($global:DefaultCisServers)){
[System.Windows.Forms.MessageBox]::Show("It appears you have not created a connection to the CisServer. You will now be prompted to enter your vCenter credentials to continue" , "Connect to CisServer") | out-null
$Connection = Connect-CisServer $global:DefaultVIServer
} else {
$Connection = $global:DefaultCisServers
}
}
Process{
$BackupAPI = Get-CisService com.vmware.appliance.recovery.backup.job
try {
if ($ShowNewest) {
$results = $BackupAPI.list()
$results[0]
} else {
$BackupAPI.list()
}
}
catch {
Write-Error $Error[0].exception.Message
}
}
End {}
param (
[Parameter(Mandatory=$false)][switch]$ShowNewest,
[Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers
)
Begin {
if ($CisServer.IsConnected) {
Write-Verbose "Connected to $($CisServer.Name)"
$connection = $CisServer
} elseif ($CisServer.gettype().name -eq "String") {
Write-Host "Prompting for CIS Server credentials. Connecting to $($CisServer)."
$Connection = Connect-CisServer $CisServer
} elseif ($global:DefaultCisServers) {
$connection = $global:DefaultCisServers
} elseif ($global:DefaultVIServer) {
Write-Host "Prompting for CIS Server credentials. Connecting to $($global:DefaultVIServer.name)."
$Connection = Connect-CisServer $global:DefaultVIServer
}
if (!$Connection) {
Write-Error "It appears you have not created a connection to the CisServer. Please Connect First and try command again. (Connect-CisServer)"
}
}
Process{
$BackupAPI = Get-CisService 'com.vmware.appliance.recovery.backup.job'
try {
if ($ShowNewest) {
$results = $BackupAPI.list()
$results[0]
} else {
$BackupAPI.list()
}
} catch {
Write-Error $Error[0].exception.Message
}
}
End {}
}
Function Get-VCSABackupStatus {
<#
.NOTES
===========================================================================
Created by: Brian Graf
Date: October 30, 2016
Organization: VMware
Blog: www.vtagion.com
Twitter: @vBrianGraf
.NOTES
===========================================================================
Created by: Brian Graf
Date: October 30, 2016
Organization: VMware
Blog: www.vtagion.com
Twitter: @vBrianGraf
Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
Returns the ID, Progress, and State of a VCSA backup (vSphere 6.5 and higher)
.DESCRIPTION
Returns the ID, Progress, and State of a VCSA backup
.EXAMPLE
.EXAMPLE
PS C:\> $backups = Get-VCSABackupJobs
$backups[0] | Get-VCSABackupStatus
$backups[0] | Get-VCSABackupStatus
.NOTES
The BackupID can be piped in from the Get-VCSABackupJobs function and can return multiple job statuses
#>
Param (
[parameter(ValueFromPipeline=$True)]
[string[]]$BackupID
)
Begin {
if (!($global:DefaultCisServers)){
[System.Windows.Forms.MessageBox]::Show("It appears you have not created a connection to the CisServer. You will now be prompted to enter your vCenter credentials to continue" , "Connect to CisServer") | out-null
$Connection = Connect-CisServer $global:DefaultVIServer
} else {
$Connection = $global:DefaultCisServers
}
$BackupAPI = Get-CisService com.vmware.appliance.recovery.backup.job
}
Process{
foreach ($id in $BackupID) {
$BackupAPI.get("$id") | select id, progress, state
}
}
End {}
Param (
[parameter(Mandatory=$false,ValueFromPipeline=$True)][string[]]$BackupID,
[Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers
)
Begin {
if ($CisServer.IsConnected) {
Write-Verbose "Connected to $($CisServer.Name)"
$connection = $CisServer
} elseif ($CisServer.gettype().name -eq "String") {
Write-Host "Prompting for CIS Server credentials. Connecting to $($CisServer)."
$Connection = Connect-CisServer $CisServer
} elseif ($global:DefaultCisServers) {
$connection = $global:DefaultCisServers
} elseif ($global:DefaultVIServer) {
Write-Host "Prompting for CIS Server credentials. Connecting to $($global:DefaultVIServer.name)."
$Connection = Connect-CisServer $global:DefaultVIServer
}
if (!$Connection) {
Write-Error "It appears you have not created a connection to the CisServer. Please Connect First and try command again. (Connect-CisServer)"
}
}
Process{
$BackupAPI = Get-CisService 'com.vmware.appliance.recovery.backup.job'
Foreach ($id in $BackupID) {
$BackupAPI.get("$id") | Select-Object id, progress, state
}
}
End {}
}
Function New-VCSASchedule {
<#
.NOTES
===========================================================================
Original Created by: Brian Graf
Blog: www.vtagion.com
Twitter: @vBrianGraf
Organization: VMware
Created / Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function will allow you to create a scheduled to backup your
VCSA appliance. (vSphere 6.7 and higher)
.DESCRIPTION
Use this function to create a schedule to backup your VCSA to a remote location
.EXAMPLE
The Below Create a schedule on Monday @11:30pm to FTP location 10.1.1.10:/vcsabackup/vcenter01
and keep 4 backups with a Encryption Passowrd of "VMw@re123"
$location = "ftp://10.1.1.10/vcsabackup/vcenter01"
$LocationUser = "admin"
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$locationPassword = "VMw@re123"
$BHour = 23
$BMin = 30
$BDays = @("Monday")
$MaxCount = 4
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword = "VMw@re123"
PS C:\> New-VCSASchedule -Location $location -LocationUser $LocationUser -LocationPassword $locationPassword -BackupHour $BHour -BackupMinute $BMin -backupDays $BDays -MaxCount $MaxCount -BackupPassword $BackupPassword
.EXAMPLE
The Below Create a schedule on Sunday & Wednesday @5:15am
to NFS location 10.1.1.10:/vcsabackup/vcenter01
keep 10 backups with a Encryption Passowrd of "VMw@re123"
with Event Data included (Seat) and will delete any existing schedule.
$location = "nfs://10.1.1.10/vcsabackup/vcenter01"
$LocationUser = "admin"
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$locationPassword = "VMw@re123"
$BHour = 5
$BMin = 15
$BDays = @("Sunday", "Monday")
$MaxCount = 10
[VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword = "VMw@re123"
PS C:\> New-VCSASchedule -IncludeSeat -force -Location $location -LocationUser $LocationUser -LocationPassword $locationPassword -BackupHour $BHour -BackupMinute $BMin -backupDays $BDays -MaxCount $MaxCount -BackupPassword $BackupPassword -CisServer "vcserver.sphere.local"
.NOTES
Credit goes to @AlanRenouf & @vBrianGraf for sharing the base of this function.
You must be connected to the CisService for this to work, if you are not connected, the function will prompt you for your credentials
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
param (
[Parameter(Mandatory=$true)]$Location,
[Parameter(Mandatory=$true)]$LocationUser,
[Parameter(Mandatory=$true)][VMware.VimAutomation.Cis.Core.Types.V1.Secret]$LocationPassword,
[Parameter(Mandatory=$false)][VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword,
[Parameter(Mandatory=$true)][ValidateRange(0,23)]$BackupHour,
[Parameter(Mandatory=$true)][ValidateRange(0,59)]$BackupMinute,
[Parameter(Mandatory=$true)][ValidateSet('MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY', IgnoreCase = $False)][Array]$BackupDays = $null,
[Parameter(Mandatory=$true)][Int]$MaxCount,
[Parameter(Mandatory=$false)]$BackupID = "default",
[Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers,
[Parameter(Mandatory=$false)][switch]$IncludeSeat,
[Parameter(Mandatory=$false)][switch]$Force
)
Begin {
if ($CisServer.IsConnected) {
Write-Verbose "Connected to $($CisServer.Name)"
$connection = $CisServer
} elseif ($CisServer.gettype().name -eq "String") {
Write-Host "Prompting for CIS Server credentials. Connecting to $($CisServer)."
$Connection = Connect-CisServer $CisServer
} elseif ($global:DefaultCisServers) {
$connection = $global:DefaultCisServers
} elseif ($global:DefaultVIServer) {
Write-Host "Prompting for CIS Server credentials. Connecting to $($global:DefaultVIServer.name)."
$Connection = Connect-CisServer $global:DefaultVIServer
}
if (!$Connection) {
Write-Error "It appears you have not created a connection to the CisServer. Please Connect First and try command again. (Connect-CisServer)"
}
}
Process{
if (!(Test-VCSAScheduleSupport)) {
Write-Error "This VCSA does not support Backup Schedules."
return
}
$BackupAPI = Get-CisService -name 'com.vmware.appliance.recovery.backup.schedules'
$CreateSpec = $BackupAPI.Help.create.spec.Create()
$CreateSpec.backup_password = $BackupPassword
$CreateSpec.location = $Location
$CreateSpec.location_user = $LocationUser
$CreateSpec.location_password = $LocationPassword
$CreateSpec.Enable = $true
$CreateSpec.recurrence_info.Hour = $BackupHour
$CreateSpec.recurrence_info.Minute = $BackupMinute
$CreateSpec.recurrence_info.Days = $BackupDays
$CreateSpec.retention_info.max_count = $MaxCount
if ($IncludeSeat) {
$CreateSpec.parts = @("seat","common")
} else {
$CreateSpec.parts = @("common")
}
$CurrentSchedule = $BackupAPI.list()
if ($CurrentSchedule.keys.value) {
if($Force -or $PSCmdlet.ShouldContinue($CurrentSchedule.keys.value,'Delete Old Schedule')){
$BackupAPI.delete($CurrentSchedule.keys.value)
} else {
Write-Error "There is an exisiting Schedule. Please delete before Creating a new one."
return
}
}
if ($PSCmdlet.ShouldProcess($BackupID, 'Create New Schedule.')) {
try {
$BackupJob = $BackupAPI.create($BackupID, $CreateSpec)
}
catch {
throw $_.Exception.Message
}
}
if ($BackupJob) {
Write-Host "Backup up Job Created."
return $BackupJob
}
}
End {}
}
Function Get-VCSASchedule {
<#
.NOTES
===========================================================================
Original Created by: Brian Graf
Blog: www.vtagion.com
Twitter: @vBrianGraf
Organization: VMware
Created / Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function will allow you to Get the scheduled backup of your
VCSA appliance. (vSphere 6.7 and higher)
.DESCRIPTION
Use this function to Get the backup schedule for your VCSA appliance.
.EXAMPLE
PS C:\> Get-VCSASchedule
.EXAMPLE
PS C:\> Get-VCSASchedule -ScheduleID 1 -CisServer "vcserver.sphere.local"
.NOTES
Credit goes to @AlanRenouf & @vBrianGraf for sharing the base of this function.
Returns a simplified object with the schedule details.
You must be connected to the CisService for this to work, if you are not connected, the function will prompt you for your credentials
#>
param (
[Parameter(Mandatory=$False,HelpMessage="Will Filter List By ScheduleID")]$ScheduleID,
[Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers
)
Begin {
if ($CisServer.IsConnected) {
Write-Verbose "Connected to $($CisServer.Name)"
$connection = $CisServer
} elseif ($CisServer.gettype().name -eq "String") {
Write-Host "Prompting for CIS Server credentials. Connecting to $($CisServer)."
$Connection = Connect-CisServer $CisServer
} elseif ($global:DefaultCisServers) {
$connection = $global:DefaultCisServers
} elseif ($global:DefaultVIServer) {
Write-Host "Prompting for CIS Server credentials. Connecting to $($global:DefaultVIServer.name)."
$Connection = Connect-CisServer $global:DefaultVIServer
}
if (!$Connection) {
Write-Error "It appears you have not created a connection to the CisServer. Please Connect First and try command again. (Connect-CisServer)"
}
}
Process{
if (!(Test-VCSAScheduleSupport)) {
Write-Error "This VCSA does not support Backup Schedules."
return
}
$BackupAPI = Get-CisService -name 'com.vmware.appliance.recovery.backup.schedules'
$Schedules = $BackupAPI.list()
if ($Schedules.count -ge 1) {
$ObjSchedule = @()
foreach ($Schedule in $Schedules) {
$ObjSchedule += $Schedule.values | Select-Object *,@{N = "ID"; e = {"$($schedule.keys.value)"}} -ExpandProperty recurrence_info -ExcludeProperty Help | Select-Object * -ExcludeProperty recurrence_info,Help | Select-Object * -ExpandProperty retention_info | Select-Object * -ExcludeProperty retention_info,Help
}
if ($ScheduleID) {
$ObjSchedule = $ObjSchedule | Where-Object {$_.ID -eq $ScheduleID}
}
return $ObjSchedule
} else {
Write-Information "No Schedule Defined."
}
}
End {}
}
Function Remove-VCSASchedule {
<#
.NOTES
===========================================================================
Original Created by: Brian Graf
Blog: www.vtagion.com
Twitter: @vBrianGraf
Organization: VMware
Created / Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
============================================================================
.SYNOPSIS
This function will remove any scheduled backups of your
VCSA appliance. (vSphere 6.7 and higher)
.DESCRIPTION
Use this function to remove the backup schedule for your VCSA appliance.
.EXAMPLE
PS C:\> Remove-VCSASchedule
.EXAMPLE
PS C:\> Remove-VCSASchedule -ScheduleID 1 -CisServer "vcserver.sphere.local"
.NOTES
Credit goes to @AlanRenouf & @vBrianGraf for sharing the base of this function.
You must be connected to the CisService for this to work, if you are not connected, the function will prompt you for your credentials
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param (
[Parameter(Mandatory=$false)]$ScheduleID = "default",
[Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers
)
Begin {
if ($CisServer.IsConnected) {
Write-Verbose "Connected to $($CisServer.Name)"
$connection = $CisServer
} elseif ($CisServer.gettype().name -eq "String") {
Write-Host "Prompting for CIS Server credentials. Connecting to $($CisServer)."
$Connection = Connect-CisServer $CisServer
} elseif ($global:DefaultCisServers) {
$connection = $global:DefaultCisServers
} elseif ($global:DefaultVIServer) {
Write-Host "Prompting for CIS Server credentials. Connecting to $($global:DefaultVIServer.name)."
$Connection = Connect-CisServer $global:DefaultVIServer
}
if (!$Connection) {
Write-Error "It appears you have not created a connection to the CisServer. Please Connect First and try command again. (Connect-CisServer)"
}
}
Process{
if (!(Test-VCSAScheduleSupport)) {
Write-Error "This VCSA does not support Backup Schedules."
return
}
if ($PSCmdlet.ShouldProcess($ScheduleID, "Removes Current Backup Schedule")) {
$BackupAPI = Get-CisService -name 'com.vmware.appliance.recovery.backup.schedules'
$BackupAPI.delete($ScheduleID)
}
}
End {}
}
Function Test-VCSAScheduleSupport {
<#
.NOTES
===========================================================================
Original Created by: Brian Graf
Blog: www.vtagion.com
Twitter: @vBrianGraf
Organization: VMware
Created / Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function will check to see if your VCSA supports Scheduled Backups.
(vSphere 6.7 and higher)
.DESCRIPTION
Use this function to check if your VCSA supports Scheduled Backups.
.EXAMPLE
PS C:\> Test-VCSAScheduleSupport
.EXAMPLE
PS C:\> Test-VCSAScheduleSupport -CisServer "vcserver.sphere.local"
.NOTES
Credit goes to @AlanRenouf & @vBrianGraf for sharing the base of this function.
You must be connected to the CisService for this to work, if you are not connected, the function will prompt you for your credentia
#>
param (
[Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers
)
Begin {
if ($CisServer.IsConnected) {
Write-Verbose "Connected to $($CisServer.Name)"
$connection = $CisServer
} elseif ($CisServer.gettype().name -eq "String") {
Write-Host "Prompting for CIS Server credentials. Connecting to $($CisServer)."
$Connection = Connect-CisServer $CisServer
} elseif ($global:DefaultCisServers) {
$connection = $global:DefaultCisServers
} elseif ($global:DefaultVIServer) {
Write-Host "Prompting for CIS Server credentials. Connecting to $($global:DefaultVIServer.name)."
$Connection = Connect-CisServer $global:DefaultVIServer
}
if (!$Connection) {
Write-Error "It appears you have not created a connection to the CisServer. Please Connect First and try command again. (Connect-CisServer)"
}
}
Process{
if ((Get-CisService).name -contains "com.vmware.appliance.recovery.backup.schedules" ) {
Write-Verbose "This VCSA does supports Backup Schedules."
return $true
} else {
Write-Verbose "This VCSA does not support Backup Schedules."
return $false
}
}
End {}
}

View File

@@ -1,11 +1,15 @@
Function Get-ContentLibrary {
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-ContentLibrary {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function lists all available vSphere Content Libaries
@@ -20,12 +24,12 @@
[Parameter(Mandatory=$false)][String]$LibraryName
)
$contentLibaryService = Get-CisService com.vmware.content.library
$libaryIDs = $contentLibaryService.list()
$contentLibraryService = Get-CisService com.vmware.content.library
$LibraryIDs = $contentLibraryService.list()
$results = @()
foreach($libraryID in $libaryIDs) {
$library = $contentLibaryService.get($libraryID)
foreach($libraryID in $LibraryIDs) {
$library = $contentLibraryService.get($libraryID)
# Use vCenter REST API to retrieve name of Datastore that is backing the Content Library
$datastoreService = Get-CisService com.vmware.vcenter.datastore
@@ -87,10 +91,10 @@ Function Get-ContentLibraryItems {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function lists all items within a given vSphere Content Library
@@ -108,18 +112,18 @@ Function Get-ContentLibraryItems {
[Parameter(Mandatory=$false)][String]$LibraryItemName
)
$contentLibaryService = Get-CisService com.vmware.content.library
$libaryIDs = $contentLibaryService.list()
$contentLibraryService = Get-CisService com.vmware.content.library
$LibraryIDs = $contentLibraryService.list()
$results = @()
foreach($libraryID in $libaryIDs) {
$library = $contentLibaryService.get($libraryId)
foreach($libraryID in $LibraryIDs) {
$library = $contentLibraryService.get($libraryId)
if($library.name -eq $LibraryName) {
$contentLibaryItemService = Get-CisService com.vmware.content.library.item
$itemIds = $contentLibaryItemService.list($libraryID)
$contentLibraryItemService = Get-CisService com.vmware.content.library.item
$itemIds = $contentLibraryItemService.list($libraryID)
foreach($itemId in $itemIds) {
$item = $contentLibaryItemService.get($itemId)
$item = $contentLibraryItemService.get($itemId)
if(!$LibraryItemName) {
$itemResult = [pscustomobject] @{
@@ -158,10 +162,10 @@ Function Get-ContentLibraryItemFiles {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function lists all item files within a given vSphere Content Library
@@ -179,28 +183,40 @@ Function Get-ContentLibraryItemFiles {
[Parameter(Mandatory=$false)][String]$LibraryItemName
)
$contentLibaryService = Get-CisService com.vmware.content.library
$libaryIDs = $contentLibaryService.list()
$contentLibraryService = Get-CisService com.vmware.content.library
$libraryIDs = $contentLibraryService.list()
$results = @()
foreach($libraryID in $libaryIDs) {
$library = $contentLibaryService.get($libraryId)
foreach($libraryID in $libraryIDs) {
$library = $contentLibraryService.get($libraryId)
if($library.name -eq $LibraryName) {
$contentLibaryItemService = Get-CisService com.vmware.content.library.item
$itemIds = $contentLibaryItemService.list($libraryID)
$contentLibraryItemService = Get-CisService com.vmware.content.library.item
$itemIds = $contentLibraryItemService.list($libraryID)
$DatastoreID = $library.storage_backings.datastore_id.Value
$Datastore = get-datastore -id "Datastore-$DatastoreID"
foreach($itemId in $itemIds) {
$itemName = ($contentLibaryItemService.get($itemId)).name
$contenLibraryItemFileSerice = Get-CisService com.vmware.content.library.item.file
$files = $contenLibraryItemFileSerice.list($itemId)
$itemName = ($contentLibraryItemService.get($itemId)).name
$contentLibraryItemFileSerice = Get-CisService com.vmware.content.library.item.file
$files = $contentLibraryItemFileSerice.list($itemId)
$contentLibraryItemStorageService = Get-CisService com.vmware.content.library.item.storage
foreach($file in $files) {
if($contentLibraryItemStorageService.get($itemId, $($file.name)).storage_backing.type -eq "DATASTORE"){
$filepath = $contentLibraryItemStorageService.get($itemId, $($file.name)).storage_uris.segments -notmatch '(^/$|^vmfs$*|^volumes$*|vsan:.*)' -join ''
$fullfilepath = "[$($datastore.name)] $filepath"
}
else{
$fullfilepath = "UNKNOWN"
}
if(!$LibraryItemName) {
$fileResult = [pscustomobject] @{
Name = $file.name;
Version = $file.version;
Size = $file.size;
Stored = $file.cached;
Path = $fullfilepath;
}
$results+=$fileResult
} else {
@@ -210,6 +226,7 @@ Function Get-ContentLibraryItemFiles {
Version = $file.version;
Size = $file.size;
Stored = $file.cached;
Path = $fullfilepath;
}
$results+=$fileResult
}
@@ -225,10 +242,10 @@ Function Set-ContentLibrary {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function updates the JSON Persistence property for a given Content Library
@@ -245,12 +262,12 @@ Function Set-ContentLibrary {
[Parameter(Mandatory=$false)][Switch]$JSONPersistenceDisabled
)
$contentLibaryService = Get-CisService com.vmware.content.library
$libaryIDs = $contentLibaryService.list()
$contentLibraryService = Get-CisService com.vmware.content.library
$LibraryIDs = $contentLibraryService.list()
$found = $false
foreach($libraryID in $libaryIDs) {
$library = $contentLibaryService.get($libraryId)
foreach($libraryID in $LibraryIDs) {
$library = $contentLibraryService.get($libraryId)
if($library.name -eq $LibraryName) {
$found = $true
break
@@ -281,10 +298,10 @@ Function New-ExtReplicatedContentLibrary {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function creates a new Subscriber Content Library from a JSON Persisted
@@ -331,8 +348,8 @@ Function New-ExtReplicatedContentLibrary {
$createSpec = $subscribeLibraryService.Help.create.create_spec.Create()
$createSpec.name = $LibraryName
$addResults = $createSpec.storage_backings.Add($StorageSpec)
$createSpec.subscription_info.automatic_sync_enabled = $false
$createSpec.subscription_info.on_demand = $true
$createSpec.subscription_info.automatic_sync_enabled = $AutoSync
$createSpec.subscription_info.on_demand = $OnDemand
$createSpec.subscription_info.subscription_url = $subscribeUrl
$createSpec.subscription_info.authentication_method = "NONE"
$createSpec.type = "SUBSCRIBED"
@@ -345,10 +362,10 @@ Function Remove-SubscribedContentLibrary {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function deletes a Subscriber Content Library
@@ -361,12 +378,12 @@ Function Remove-SubscribedContentLibrary {
[Parameter(Mandatory=$true)][String]$LibraryName
)
$contentLibaryService = Get-CisService com.vmware.content.library
$libaryIDs = $contentLibaryService.list()
$contentLibraryService = Get-CisService com.vmware.content.library
$LibraryIDs = $contentLibraryService.list()
$found = $false
foreach($libraryID in $libaryIDs) {
$library = $contentLibaryService.get($libraryId)
foreach($libraryID in $LibraryIDs) {
$library = $contentLibraryService.get($libraryId)
if($library.name -eq $LibraryName) {
$found = $true
break
@@ -387,10 +404,10 @@ Function New-LocalContentLibrary {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function creates a new Subscriber Content Library from a JSON Persisted
@@ -444,10 +461,10 @@ Function Remove-LocalContentLibrary {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function deletes a Local Content Library
@@ -460,12 +477,12 @@ Function Remove-LocalContentLibrary {
[Parameter(Mandatory=$true)][String]$LibraryName
)
$contentLibaryService = Get-CisService com.vmware.content.library
$libaryIDs = $contentLibaryService.list()
$contentLibraryService = Get-CisService com.vmware.content.library
$LibraryIDs = $contentLibraryService.list()
$found = $false
foreach($libraryID in $libaryIDs) {
$library = $contentLibaryService.get($libraryId)
foreach($libraryID in $LibraryIDs) {
$library = $contentLibraryService.get($libraryId)
if($library.name -eq $LibraryName) {
$found = $true
break
@@ -486,56 +503,56 @@ Function Copy-ContentLibrary {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function copies all library items from one Content Library to another
.PARAMETER SourceLibaryName
.PARAMETER SourceLibraryName
The name of the source Content Library to copy from
.PARAMETER DestinationLibaryName
.PARAMETER DestinationLibraryName
The name of the desintation Content Library to copy to
.PARAMETER DeleteSourceFile
Whther or not to delete library item from the source Content Library after copy
.EXAMPLE
Copy-ContentLibrary -SourceLibaryName Foo -DestinationLibaryName Bar
Copy-ContentLibrary -SourceLibraryName Foo -DestinationLibraryName Bar
.EXAMPLE
Copy-ContentLibrary -SourceLibaryName Foo -DestinationLibaryName Bar -DeleteSourceFile $true
Copy-ContentLibrary -SourceLibraryName Foo -DestinationLibraryName Bar -DeleteSourceFile $true
#>
param(
[Parameter(Mandatory=$true)][String]$SourceLibaryName,
[Parameter(Mandatory=$true)][String]$DestinationLibaryName,
[Parameter(Mandatory=$true)][String]$SourceLibraryName,
[Parameter(Mandatory=$true)][String]$DestinationLibraryName,
[Parameter(Mandatory=$false)][Boolean]$DeleteSourceFile=$false
)
$sourceLibraryId = (Get-ContentLibrary -LibraryName $SourceLibaryName).Id
$sourceLibraryId = (Get-ContentLibrary -LibraryName $SourceLibraryName).Id
if($sourceLibraryId -eq $null) {
Write-Host -ForegroundColor red "Unable to find Source Content Library named $SourceLibaryName"
Write-Host -ForegroundColor red "Unable to find Source Content Library named $SourceLibraryName"
exit
}
$destinationLibraryId = (Get-ContentLibrary -LibraryName $DestinationLibaryName).Id
$destinationLibraryId = (Get-ContentLibrary -LibraryName $DestinationLibraryName).Id
if($destinationLibraryId -eq $null) {
Write-Host -ForegroundColor Red "Unable to find Destination Content Library named $DestinationLibaryName"
Write-Host -ForegroundColor Red "Unable to find Destination Content Library named $DestinationLibraryName"
break
}
$sourceItemFiles = Get-ContentLibraryItems -LibraryName $SourceLibaryName
$sourceItemFiles = Get-ContentLibraryItems -LibraryName $SourceLibraryName
if($sourceItemFiles -eq $null) {
Write-Host -ForegroundColor red "Unable to retrieve Content Library Items from $SourceLibaryName"
Write-Host -ForegroundColor red "Unable to retrieve Content Library Items from $SourceLibraryName"
break
}
$contentLibaryItemService = Get-CisService com.vmware.content.library.item
$contentLibraryItemService = Get-CisService com.vmware.content.library.item
foreach ($sourceItemFile in $sourceItemFiles) {
# Check to see if file already exists in destination Content Library
$result = Get-ContentLibraryItems -LibraryName $DestinationLibaryName -LibraryItemName $sourceItemFile.Name
$result = Get-ContentLibraryItems -LibraryName $DestinationLibraryName -LibraryItemName $sourceItemFile.Name
if($result -eq $null) {
# Create CopySpec
$copySpec = $contentLibaryItemService.Help.copy.destination_create_spec.Create()
$copySpec = $contentLibraryItemService.Help.copy.destination_create_spec.Create()
$copySpec.library_id = $destinationLibraryId
$copySpec.name = $sourceItemFile.Name
$copySpec.description = $sourceItemFile.Description
@@ -545,7 +562,7 @@ Function Copy-ContentLibrary {
# Perform Copy
try {
Write-Host -ForegroundColor Cyan "Copying" $sourceItemFile.Name "..."
$copyResult = $contentLibaryItemService.copy($UniqueChangeId, $sourceItemFile.Id, $copySpec)
$copyResult = $contentLibraryItemService.copy($UniqueChangeId, $sourceItemFile.Id, $copySpec)
} catch {
Write-Host -ForegroundColor Red "Failed to copy" $sourceItemFile.Name
$Error[0]
@@ -556,7 +573,7 @@ Function Copy-ContentLibrary {
if($DeleteSourceFile) {
try {
Write-Host -ForegroundColor Magenta "Deleteing" $sourceItemFile.Name "..."
$deleteResult = $contentLibaryItemService.delete($sourceItemFile.Id)
$deleteResult = $contentLibraryItemService.delete($sourceItemFile.Id)
} catch {
Write-Host -ForegroundColor Red "Failed to delete" $sourceItemFile.Name
$Error[0]
@@ -570,7 +587,7 @@ Function Copy-ContentLibrary {
if($DeleteSourceFile) {
try {
Write-Host -ForegroundColor Magenta "Deleteing" $sourceItemFile.Name "..."
$deleteResult = $contentLibaryItemService.delete($sourceItemFile.Id)
$deleteResult = $contentLibraryItemService.delete($sourceItemFile.Id)
} catch {
Write-Host -ForegroundColor Red "Failed to delete" $sourceItemFile.Name
break
@@ -578,4 +595,190 @@ Function Copy-ContentLibrary {
}
}
}
}
Function New-VMTX {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function clones a VM to VM Template in Content Library (currently only supported on VMC)
.PARAMETER SourceVMName
The name of the source VM to clone
.PARAMETER VMTXName
The name of the VM Template in Content Library
.PARAMETER Description
Description of the VM template
.PARAMETER LibraryName
The name of the Content Library to clone to
.PARAMETER FolderName
The name of vSphere Folder (Defaults to Workloads for VMC)
.PARAMETER ResourcePoolName
The name of the vSphere Resource Pool (Defaults to Compute-ResourcePools for VMC)
.EXAMPLE
New-VMTX -SourceVMName "Windows10-BaseInstall" -VMTXName "Windows10-VMTX-Template" -LibraryName "VMC-CL-01"
#>
param(
[Parameter(Mandatory=$true)][String]$SourceVMName,
[Parameter(Mandatory=$true)][String]$VMTXName,
[Parameter(Mandatory=$false)][String]$Description,
[Parameter(Mandatory=$true)][String]$LibraryName,
[Parameter(Mandatory=$false)][String]$FolderName="Workloads",
[Parameter(Mandatory=$false)][String]$ResourcePoolName="Compute-ResourcePool"
)
$vmtxService = Get-CisService -Name "com.vmware.vcenter.vm_template.library_items"
$sourceVMId = ((Get-VM -Name $SourceVMName).ExtensionData.MoRef).Value
$libraryId = ((Get-ContentLibrary -LibraryName $LibraryName).Id).Value
$folderId = ((Get-Folder -Name $FolderName).ExtensionData.MoRef).Value
$rpId = ((Get-ResourcePool -Name $ResourcePoolName).ExtensionData.MoRef).Value
$vmtxCreateSpec = $vmtxService.Help.create.spec.Create()
$vmtxCreateSpec.source_vm = $sourceVMId
$vmtxCreateSpec.name = $VMTXName
$vmtxCreateSpec.description = $Description
$vmtxCreateSpec.library = $libraryId
$vmtxCreateSpec.placement.folder = $folderId
$vmtxCreateSpec.placement.resource_pool = $rpId
Write-Host "`nCreating new VMTX Template from $SourceVMName in Content Library $LibraryName ..."
$result = $vmtxService.create($vmtxCreateSpec)
}
Function New-VMFromVMTX {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function deploys a new VM from Template in Content Library (currently only supported in VMC)
.PARAMETER VMTXName
The name of the VM Template in Content Library to deploy from
.PARAMETER NewVMName
The name of the new VM to deploy
.PARAMETER FolderName
The name of vSphere Folder (Defaults to Workloads for VMC)
.PARAMETER ResourcePoolName
The name of the vSphere Resource Pool (Defaults to Compute-ResourcePools for VMC)
.PARAMETER NumCpu
The number of vCPU to configure for the new VM
.PARAMETER MemoryMb
The amount of memory (MB) to configure for the new VM
.PARAMETER PowerOn
To power on the VM after deploy
.EXAMPLE
New-VMFromVMTX -NewVMName "FooFoo" -VMTXName "FooBar" -PowerOn $true -NumCpu 4 -MemoryMB 2048
#>
param(
[Parameter(Mandatory=$true)][String]$VMTXName,
[Parameter(Mandatory=$true)][String]$NewVMName,
[Parameter(Mandatory=$false)][String]$FolderName="Workloads",
[Parameter(Mandatory=$false)][String]$ResourcePoolName="Compute-ResourcePool",
[Parameter(Mandatory=$false)][String]$DatastoreName="WorkloadDatastore",
[Parameter(Mandatory=$false)][Int]$NumCpu,
[Parameter(Mandatory=$false)][Int]$MemoryMB,
[Parameter(Mandatory=$false)][Boolean]$PowerOn=$false
)
$vmtxService = Get-CisService -Name "com.vmware.vcenter.vm_template.library_items"
$vmtxId = (Get-ContentLibraryItem -Name $VMTXName).Id
$folderId = ((Get-Folder -Name $FolderName).ExtensionData.MoRef).Value
$rpId = ((Get-ResourcePool -Name $ResourcePoolName).ExtensionData.MoRef).Value
$datastoreId = ((Get-Datastore -Name $DatastoreName).ExtensionData.MoRef).Value
$vmtxDeploySpec = $vmtxService.Help.deploy.spec.Create()
$vmtxDeploySpec.name = $NewVMName
$vmtxDeploySpec.powered_on = $PowerOn
$vmtxDeploySpec.placement.folder = $folderId
$vmtxDeploySpec.placement.resource_pool = $rpId
$vmtxDeploySpec.vm_home_storage.datastore = $datastoreId
$vmtxDeploySpec.disk_storage.datastore = $datastoreId
if($NumCpu) {
$vmtxDeploySpec.hardware_customization.cpu_update.num_cpus = $NumCpu
}
if($MemoryMB) {
$vmtxDeploySpec.hardware_customization.memory_update.memory = $MemoryMB
}
Write-Host "`nDeploying new VM $NewVMName from VMTX Template $VMTXName ..."
$results = $vmtxService.deploy($vmtxId,$vmtxDeploySpec)
}
Function New-SubscribedContentLibrary {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function creates a new Subscriber Content Library from Subscription URL
.PARAMETER LibraryName
The name of the new vSphere Content Library
.PARAMETER DatastoreName
The name of the vSphere Datastore to store the Content Library
.PARAMETER SubscriptionURL
The URL of the published Content Library
.PARAMETER SubscriptionThumbprint
The SSL Thumbprint for the published Content Library
.PARAMETER OnDemand
Specifies whether content is downloaded on-demand (e.g. no immediately)
.PARAMETER AutomaticSync
Specifies whether automatic synchronization with the external content library is enabled
.EXAMPLE
New-SubscribedContentLibrary -LibraryName NestedESXi -DatastoreName vsanDatastore -SubscriptionURL https://download3.vmware.com/software/vmw-tools/lib.json -SubscriptionThumbprint "7a:c4:08:2d:d3:55:56:af:9f:26:43:65:d0:31:99:0b:d2:f3:d8:69" -AutomaticSync
.EXAMPLE
New-SubscribedContentLibrary -LibraryName NestedESXi -DatastoreName vsanDatastore -SubscriptionURL https://download3.vmware.com/software/vmw-tools/lib.json -SubscriptionThumbprint "7a:c4:08:2d:d3:55:56:af:9f:26:43:65:d0:31:99:0b:d2:f3:d8:69" -OnDemand
#>
param(
[Parameter(Mandatory=$true)][String]$LibraryName,
[Parameter(Mandatory=$true)][String]$DatastoreName,
[Parameter(Mandatory=$true)][String]$SubscriptionURL,
[Parameter(Mandatory=$true)][String]$SubscriptionThumbprint,
[Parameter(Mandatory=$false)][Switch]$OnDemand,
[Parameter(Mandatory=$false)][Switch]$AutomaticSync
)
$datastore = Get-Datastore -Name $DatastoreName
if($datastore) {
$datastoreId = $datastore.ExtensionData.MoRef.Value
$subscribeLibraryService = Get-CisService -Name "com.vmware.content.subscribed_library"
$StorageSpec = [pscustomobject] @{
datastore_id = $datastoreId;
type = "DATASTORE";
}
$UniqueChangeId = [guid]::NewGuid().tostring()
$createSpec = $subscribeLibraryService.help.create.create_spec.create()
$createSpec.name = $LibraryName
$createSpec.type = "SUBSCRIBED"
$addResults = $createSpec.storage_backings.Add($StorageSpec)
if($OnDemand) { $OnDemandFlag = $true } else { $OnDemandFlag = $false }
if($AutomaticSync) { $AutomaticSyncFlag = $true } else { $AutomaticSyncFlag = $false }
$createSpec.subscription_info.on_demand = $OnDemandFlag
$createSpec.subscription_info.automatic_sync_enabled = $AutomaticSyncFlag
$createSpec.subscription_info.subscription_url = $SubscriptionURL
$createSpec.subscription_info.authentication_method = "NONE"
$createSpec.subscription_info.ssl_thumbprint = $SubscriptionThumbprint
Write-Host "Creating new Subscribed Content Library called $LibraryName ..."
$library = $subscribeLibraryService.create($UniqueChangeId, $createSpec)
}
}

View File

@@ -0,0 +1,315 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-XVCMStatus {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function returns whether Cross vCenter Workload Migration Utility is running or not
.EXAMPLE
Get-XVCMStatus
#>
$Uri = "http://localhost:8080/api/status" #Updated for 2.0, Old: "http://localhost:8080/api/ping"
$results = Invoke-WebRequest -Uri $Uri -Method GET -TimeoutSec 5
if($results.StatusCode -eq 200) {
Write-Host -ForegroundColor Green $results.Content
} else { Write-Host -ForegroundColor Red "Cross vCenter Workload Migration Utility is probably not running" }
}
Function Get-XVCMSite {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function returns all registered vCenter Servers
.EXAMPLE
Get-XVCMSite
#>
$Uri = "http://localhost:8080/api/sites"
$results = Invoke-WebRequest -Uri $Uri -Method GET
if($results.StatusCode -eq 200) {
($results.Content | ConvertFrom-Json)|select sitename,hostname,username
} else { Write-Host -ForegroundColor Red "Failed to retrieve VC Site Registration details" }
}
Function New-XVCMSite {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function registers a new vCenter Server endpoint
.PARAMETER SiteName
The display name for the particular vCenter Server to be registered
.PARAMETER VCHostname
The Hostname/IP Address of vCenter Server
.PARAMETER VCUsername
The VC Username of vCenter Server
.PARAMETER VCPassword
The VC Password of vCenter Server
.PARAMETER Insecure
Flag to disable SSL Verification checking, useful for lab environments
.EXAMPLE
New-XVCMSite -SiteName "SiteA" -VCHostname "vcenter65-1.primp-industries.com" -VCUsername "administrator@vsphere.local" -VCPassword "VMware1!" -Insecure
#>
param(
[Parameter(Mandatory=$true)][String]$SiteName,
[Parameter(Mandatory=$true)][String]$VCHostname,
[Parameter(Mandatory=$true)][String]$VCUsername,
[Parameter(Mandatory=$true)][String]$VCPassword,
[Parameter(Mandatory=$false)][Switch]$Insecure
)
$Uri = "http://localhost:8080/api/sites"
$insecureFlag = $false
if($Insecure) {
$insecureFlag = $true
}
$body = @{
"sitename"=$SiteName;
"hostname"=$VCHostname;
"username"=$VCUsername;
"password"=$VCPassword;
"insecure"=$insecureFlag;
}
$body = $body | ConvertTo-Json
Write-Host -ForegroundColor Cyan "Registering vCenter Server $VCHostname as $SiteName ..."
$results = Invoke-WebRequest -Uri $Uri -Method POST -Body $body -ContentType "application/json"
if($results.StatusCode -eq 200) {
Write-Host -ForegroundColor Green "Successfully registered $SiteName"
} else { Write-Host -ForegroundColor Red "Failed to register $SiteName" }
}
Function Remove-XVCMSite {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function removes vCenter Server endpoint
.PARAMETER SiteName
The name of the registered vCenter Server to remove
.EXAMPLE
Remove-XVCMSite -SiteName "SiteA"
#>
param(
[Parameter(Mandatory=$true)][String]$SiteName
)
$Uri = "http://localhost:8080/api/sites/$SiteName"
Write-Host -ForegroundColor Cyan "Deleting vCenter Server Site Registerion $SiteName ..."
$results = Invoke-WebRequest -Uri $Uri -Method DELETE
if($results.StatusCode -eq 200) {
Write-Host -ForegroundColor Green "Successfully deleted $SiteName"
} else { Write-Host -ForegroundColor Red "Failed to deleted $SiteName" }
}
Function New-XVCMRequest {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function initiates a migration request
.PARAMETER opType
The type of task, Relocate or Clone
.PARAMETER SrcSite
The name of the source vCenter Server
.PARAMETER DstSite
The name of the destination vCenter Server
.PARAMETER SrcDatacenter
The name of the source vSphere Datacenter
.PARAMETER DstDatacenter
The name of the destination vSphere Datacenter
.PARAMETER DstCluster
The name of the destination vSphere Cluster, set to null if DstHost is defined
.PARAMETER DstPool
The name of the destination vSphere Resource Pool
.PARAMETER DstFolder
The name of the destination vSphere Folder
.PARAMETER DstDatastore
The name of the destination Datastore
.PARAMETER DstHost
The name of the destination host. Set to null if DstCluster is defined
.PARAMETER srcVMs
List of VMs to migrate
.PARAMETER NetworkMapping
Hash table of the VM network mappings between your source and destination vCenter Server
.EXAMPLE
New-XVCMRequest -opType Relocate -SrcSite SiteA -DstSite SiteB `
-SrcDatacenter Datacenter-SiteA -DstDatacenter Datacenter-SiteB `
-DstCluster $null -DstHost VMhost1.test.lab `
-DstDatastore vsanDatastore `
-srcVMs @("PhotonOS-01","PhotonOS-02","PhotonOS-03","PhotonOS-04") `
-NetworkMapping @{"DVPG-VM Network 1"="DVPG-Internal Network";"DVPG-VM Network 2"="DVPG-External Network"}
.EXAMPLE
New-XVCMRequest -opType Clone -SrcSite OREGON -DstSite CALIF `
-SrcDatacenter SDDC-Datacenter -srcVMs @(“DUDE-ubuntu”) `
-DstDatacenter SDDC-Datacenter `
-DstCluster "Cluster-1" -DstHost $null `
-DstPool Compute-ResourcePool `
-DstFolder Workloads `
-DstDatastore WorkloadDatastore `
-NetworkMapping @{"OREGON-VMs-sddc"="CALIF-sddc-VMs"}
#>
param(
[Parameter(Mandatory=$true)][String]$opType, #Added by CPM for 2.0
[Parameter(Mandatory=$true)][String]$SrcSite,
[Parameter(Mandatory=$true)][String]$DstSite,
[Parameter(Mandatory=$true)][String]$SrcDatacenter,
[Parameter(Mandatory=$true)][String]$DstDatacenter,
[Parameter(Mandatory=$true)][AllowNull()] $DstCluster, #Added [AllowNull()], removed [String] by CPM for 2.0
[Parameter(Mandatory=$true)][String]$DstPool,
[Parameter(Mandatory=$true)][String]$DstFolder,
[Parameter(Mandatory=$true)][String]$DstDatastore,
[Parameter(Mandatory=$true)][AllowNull()] $DstHost, #Added by CPM for 2.0
[Parameter(Mandatory=$true)][String[]]$srcVMs,
[Parameter(Mandatory=$true)][Hashtable]$NetworkMapping
)
$Uri = "http://localhost:8080/api/tasks"
$body = @{
"sourceSite"=$SrcSite;
"targetSite"=$DstSite;
"sourceDatacenter"=$SrcDatacenter;
"targetDatacenter"=$dstDatacenter;
"targetPool"=$DstPool;
"targetFolder"=$DstFolder;
"targetCluster"=$DstCluster;
"targetDatastore"=$DstDatastore;
"targetHost"=$DstHost; #Added by CPM for 2.0
"networkMap"=$NetworkMapping;
"vmList"=$srcVMs;
"operationType"=$opType; #Added by CPM for 2.0
}
$body = $body | ConvertTo-Json
Write-Host -ForegroundColor Cyan "Initiating migration request ..."
$results = Invoke-WebRequest -Uri $Uri -Method POST -Body $body -ContentType "application/json"
if($results.StatusCode -eq 200) {
$taskId = ($results.Content | ConvertFrom-Json).requestId
Write-Host -ForegroundColor Green "Successfully issued migration with TaskID: $taskId"
} else { Write-Host -ForegroundColor Red "Failed to initiate migration request" }
}
Function Get-XVCMTask {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function retrieves either all migration tasks and/or a specific migration task
.PARAMETER Id
The task ID returned from initiating a migration
.EXAMPLE
Get-XVCMTask -Id <Task ID>
#>
param(
[Parameter(Mandatory=$false)][String]$Id
)
$Uri = "http://localhost:8080/api/tasks"
if($Id) {
$body = @{"requestId"=$Id}
$results = Invoke-WebRequest -Uri $Uri -Method GET -Body $body -ContentType "application/json"
} else {
$results = Invoke-WebRequest -Uri $Uri -Method GET
}
if($results.StatusCode -eq 200) {
$results.Content | ConvertFrom-Json
} else { Write-Host -ForegroundColor Red "Failed to retrieve tasks" }
}
Function Get-VMNetwork {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function returns the list of all VM Networks attached to
given VMs to help with initiating migration
.PARAMETER srcVMs
List of VMs to query their current VM Networks
.EXAMPLE
Get-VMNetwork -srcVMs @("PhotonOS-01","PhotonOS-02","PhotonOS-03","PhotonOS-04")
#>
param(
[Parameter(Mandatory=$false)][String[]]$srcVMs
)
if (-not $global:DefaultVIServers) { Write-Host -ForegroundColor red "No vCenter Server Connection found, please connect to your source vCenter Server using Connect-VIServer"; break }
$results = @()
if($srcVMs) {
foreach ($srcVM in $srcVMs) {
$vm = Get-VM -Name $srcVM
$networkDetails = $vm | Get-NetworkAdapter
$tmp = [pscustomobject] @{
Name = $srcVM;
Adapter = $networkDetails.name;
Network = $networkDetails.NetworkName;
}
$results+=$tmp
}
} else {
foreach ($vm in Get-VM) {
$networkDetails = $vm | Get-NetworkAdapter
$tmp = [pscustomobject] @{
Name = $vm.Name;
Adapter = $networkDetails.name;
Network = $networkDetails.NetworkName;
}
$results+=$tmp
}
}
$results
}

View File

@@ -34,7 +34,7 @@ Function Get-HostViews {
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
}
$allHosts = @()
$DShostsKeys = $allDatastores.extensiondata.host.key.value | sort | get-unique -asstring
$DShostsKeys = $allDatastores.extensiondata.host.key.value | sort-object | get-unique -asstring
$DShosts = foreach ($thisKey in $DShostsKeys) {($allDatastores.extensiondata.host | ? {$_.key.value -eq $thisKey})[0]}
$i = 1
foreach ($DSHost in $DSHosts){
@@ -47,7 +47,7 @@ Function Get-HostViews {
}
write-progress -activity "Collecting ESXi Host Views" -completed
$allHosts
}
}
}
Function Get-DatastoreMountInfo {
@@ -74,7 +74,7 @@ Function Get-DatastoreMountInfo {
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
}
$allDatastoreNAAs = foreach ($ds in $allDatastores) {$ds.ExtensionData.Info.vmfs.extent[0].diskname}
#Build the array of custom Host Objects
$allHosts = Get-HostViews -datastore $allDatastores
$output = @()
@@ -89,9 +89,9 @@ Function Get-DatastoreMountInfo {
$thisDatastore = $alldatastores | ? {$_.ExtensionData.Info.vmfs.extent[0].diskname -eq $device.canonicalName}
$hostviewDSAttachState = ""
if ($device.operationalState[0] -eq "ok") {
$hostviewDSAttachState = "Attached"
$hostviewDSAttachState = "Attached"
} elseif ($device.operationalState[0] -eq "off") {
$hostviewDSAttachState = "Detached"
$hostviewDSAttachState = "Detached"
} else {
$hostviewDSAttachState = $device.operationalstate[0]
}

View File

@@ -1,15 +1,15 @@
function Get-NICDetails {
<#
<#
.NOTES
===========================================================================
Created by: Markus Kraus
Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com
===========================================================================
Changelog:
2017.02 ver 1.0 Base Release
Changelog:
2017.02 ver 1.0 Base Release
===========================================================================
External Code Sources:
External Code Sources:
-
===========================================================================
Tested Against Environment:
@@ -35,11 +35,11 @@
#>
[CmdletBinding()]
param(
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[ValidateNotNullorEmpty()]
[String] $Clustername
)
Begin {
@@ -49,14 +49,14 @@ Begin {
$Validate = $False
thow "No Cluster '$myCluster' found!"
}
}
Process {
$MyView = @()
if ($Validate -eq $True) {
foreach ($myVMhost in ($myCluster | Get-VMHost)) {
$esxcli2 = Get-ESXCLI -VMHost $myVMhost -V2
@@ -85,7 +85,7 @@ Process {
}
}
$MyView
}

View File

@@ -1,15 +1,15 @@
function Get-NewAndRemovedVMs {
<#
<#
.NOTES
===========================================================================
Created by: Markus Kraus
Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com
===========================================================================
Changelog:
2016.12 ver 1.0 Base Release
Changelog:
2016.12 ver 1.0 Base Release
===========================================================================
External Code Sources:
External Code Sources:
https://github.com/alanrenouf/vCheck-vSphere
===========================================================================
Tested Against Environment:
@@ -22,10 +22,10 @@ function Get-NewAndRemovedVMs {
===========================================================================
.DESCRIPTION
This Function report newly created and deleted VMs by Cluster.
This Function report newly created and deleted VMs by Cluster.
.Example
Get-NewAndRemovedVMs -ClusterName Cluster* | ft -AutoSize
Get-NewAndRemovedVMs -ClusterName Cluster* | ft -AutoSize
.Example
Get-NewAndRemovedVMs -ClusterName Cluster01 -Days 90
@@ -51,7 +51,7 @@ param(
)
Begin {
function Get-VIEventPlus {
param(
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity,
[string[]]$EventType,
@@ -117,7 +117,7 @@ Begin {
{
$events | % { $_.createdTime = $_.createdTime.ToLocalTime() }
}
$events
}
}
@@ -125,7 +125,7 @@ Begin {
process {
$result = Get-VIEventPlus -Start ((get-date).adddays(-$Days)) -EventType @("VmCreatedEvent", "VmBeingClonedEvent", "VmBeingDeployedEvent","VmRemovedEvent")
$sortedResult = $result | Select CreatedTime, @{N='Cluster';E={$_.ComputeResource.Name}}, @{Name="VMName";Expression={$_.vm.name}}, UserName, @{N='Type';E={$_.GetType().Name}}, FullFormattedMessage | Sort CreatedTime
$sortedResult | where {$_.Cluster -like $ClusterName}
$sortedResult = $result | Select-Object CreatedTime, @{N='Cluster';E={$_.ComputeResource.Name}}, @{Name="VMName";Expression={$_.vm.name}}, UserName, @{N='Type';E={$_.GetType().Name}}, FullFormattedMessage
$sortedResult | where-object {$_.Cluster -like $ClusterName}
}
}

View File

@@ -1,16 +1,16 @@
function Get-VMmaxIOPS {
<#
<#
.NOTES
===========================================================================
Created by: Markus Kraus
Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com
===========================================================================
Changelog:
2016.10 ver 1.0 Base Release
Changelog:
2016.10 ver 1.0 Base Release
2016.11 ver 1.1 Added vSphere 6.5 Support, New Counters, More Error Handling
===========================================================================
External Code Sources:
External Code Sources:
http://www.lucd.info/2011/04/22/get-the-maximum-iops/
https://communities.vmware.com/thread/485386
===========================================================================
@@ -24,7 +24,7 @@ function Get-VMmaxIOPS {
===========================================================================
.DESCRIPTION
This Function will Create a VM Disk IOPS Report
This Function will Create a VM Disk IOPS Report
.Example
Get-VM TST* | Get-VMmaxIOPS -Minutes 60 | FT -Autosize
@@ -34,17 +34,17 @@ function Get-VMmaxIOPS {
Get-VMmaxIOPS -VMs $SampleVMs -Minutes 60
.PARAMETER VMs
Specify the VMs
Specify the VMs
.PARAMETER Minutes
Specify the Minutes to report (10080 is one Week)
Specify the Minutes to report (10080 is one Week)
#Requires PS -Version 4.0
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"}
#>
[CmdletBinding()]
param(
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$True, Position=0)]
[ValidateNotNullorEmpty()]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $VMs,
@@ -55,7 +55,7 @@ param(
Begin {
# none
}
Process {
Process {
if ($_.PowerState -eq "PoweredOn") {
#region: Global Definitions
[int]$TimeRange = "-" + $Minutes
@@ -82,7 +82,7 @@ Process {
#region: Creating Reports
Write-Verbose "$(Get-Date -Format G) Create Report..."
$reportPerf = @()
$reportPerf = @()
$reportPerf = $stats | Group-Object -Property {$_.Entity.Name},Instance | %{
New-Object PSObject -Property @{
VM = $_.Values[0]
@@ -98,7 +98,7 @@ Process {
}
Write-Verbose "$(Get-Date -Format G) Create Report completed"
#endregion
}
Else {
@@ -108,7 +108,7 @@ Process {
}
End {
# none
# none
}
}

View File

@@ -0,0 +1,98 @@
Function New-InstantClone {
<#
.NOTES
===========================================================================
Created by: William Lam
Date: Apr 29, 2018
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.SYNOPSIS
This function demonstrates the use of the new "Parentless" Instant Clone
API that was introduced in vSphere 6.7
.DESCRIPTION
Function to create new "Parentless" Instant Clones in vSphere 6.7
.EXAMPLE
$SourceVM = "Foo"
$newVMName = Foo-IC-1
$guestCustomizationValues = @{
"guestinfo.ic.hostname" = $newVMName
"guestinfo.ic.ipaddress" = "192.168.30.10"
"guestinfo.ic.netmask" = "255.255.255.0"
"guestinfo.ic.gateway" = "192.168.30.1"
"guestinfo.ic.dns" = "192.168.30.1"
}
New-InstantClone -SourceVM $SourceVM -DestinationVM $newVMName -CustomizationFields $guestCustomizationValues
.NOTES
Make sure that you have both a vSphere 6.7 env (VC/ESXi) as well as
as the latest PowerCLI 10.1 installed which is reuqired to use vSphere 6.7 APIs
#>
param(
[Parameter(Mandatory=$true)][String]$SourceVM,
[Parameter(Mandatory=$true)][String]$DestinationVM,
[Parameter(Mandatory=$true)][Hashtable]$CustomizationFields
)
$vm = Get-VM -Name $SourceVM
$config = @()
$CustomizationFields.GetEnumerator() | Foreach-Object {
$optionValue = New-Object VMware.Vim.OptionValue
$optionValue.Key = $_.Key
$optionValue.Value = $_.Value
$config += $optionValue
}
# SourceVM must either be running or running but in Frozen State
if($vm.PowerState -ne "poweredOn") {
Write-Host -ForegroundColor Red "Instant Cloning is only supported on a PoweredOn or Frozen VM"
break
}
# SourceVM == Powered On
if((Get-VM $SourceVM).ExtensionData.Runtime.InstantCloneFrozen -eq $false) {
# Retrieve all Network Adapters for SourceVM
$vmNetworkAdapters = @()
$devices = $vm.ExtensionData.Config.Hardware.Device
foreach ($device in $devices) {
if($device -is [VMware.Vim.VirtualEthernetCard]) {
$vmNetworkAdapters += $device
}
}
$spec = New-Object VMware.Vim.VirtualMachineInstantCloneSpec
$locationSpec = New-Object VMware.Vim.VirtualMachineRelocateSpec
# Disconect all NICs for new Instant Clone to ensure no dupe addresses on network
# post-Instant Clone workflow needs to renable after uypdating GuestOS
foreach ($vmNetworkAdapter in $vmNetworkAdapters) {
$networkName = $vmNetworkAdapter.backing.deviceName
$deviceConfigSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec
$deviceConfigSpec.Operation = "edit"
$deviceConfigSpec.Device = $vmNetworkAdapter
$deviceConfigSpec.Device.backing = New-Object VMware.Vim.VirtualEthernetCardNetworkBackingInfo
$deviceConfigSpec.device.backing.deviceName = $networkName
$connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
$connectable.MigrateConnect = "disconnect"
$deviceConfigSpec.Device.Connectable = $connectable
$locationSpec.DeviceChange += $deviceConfigSpec
}
$spec.Config = $config
$spec.Location = $locationSpec
$spec.Name = $DestinationVM
# SourceVM == Frozen
} else {
$spec = New-Object VMware.Vim.VirtualMachineInstantCloneSpec
$locationSpec = New-Object VMware.Vim.VirtualMachineRelocateSpec
$spec.Config = $config
$spec.Location = $locationSpec
$spec.Name = $DestinationVM
}
Write-Host "Creating Instant Clone $DestinationVM ..."
$task = $vm.ExtensionData.InstantClone_Task($spec)
$task1 = Get-Task -Id ("Task-$($task.value)")
$task1 | Wait-Task | Out-Null
}

View File

@@ -1,16 +1,16 @@
function Konfig-ESXi {
<#
<#
.NOTES
===========================================================================
Created by: Markus Kraus
Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com
===========================================================================
Changelog:
Changelog:
2016.12 ver 1.0 Base Release
2016.12 ver 1.1 ESXi 6.5 Tests, Minor enhancements
2016.12 ver 1.1 ESXi 6.5 Tests, Minor enhancements
===========================================================================
External Code Sources:
External Code Sources:
Function My-Logger : http://www.virtuallyghetto.com/
===========================================================================
Tested Against Environment:
@@ -18,7 +18,7 @@ function Konfig-ESXi {
PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1
PowerShell Version: 4.0, 5.0
OS Version: Windows 8.1, Server 2012 R2
Keyword: ESXi, NTP, SSH, Syslog, SATP,
Keyword: ESXi, NTP, SSH, Syslog, SATP,
===========================================================================
.DESCRIPTION
@@ -29,7 +29,7 @@ function Konfig-ESXi {
* Syslog
* Power Management
* HP 3PAR SATP/PSP Rule
* ...
* ...
.Example
Konfig-ESXi -VMHost myesxi.lan.local -NTP 192.168.2.1, 192.168.2.2 -syslog "udp://loginsight.lan.local:514"
@@ -51,14 +51,14 @@ function Konfig-ESXi {
#>
[CmdletBinding()]
param(
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[String] $VMHost,
[Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=1)]
[array]$NTP,
[Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=2)]
[String] $syslog
)
Begin {
@@ -75,11 +75,11 @@ Begin {
}
function Set-MyESXiOption {
[CmdletBinding()]
param(
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[String] $Name,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1)]
[String] $Value
[String] $Value
)
process {
$myESXiOption = Get-AdvancedSetting -Entity $ESXiHost -Name $Name
@@ -89,7 +89,7 @@ Begin {
}
else {
My-Logger " ESXi Option $Name already has Value $Value"
}
}
}
}
}
@@ -100,7 +100,7 @@ Process {
#region: Start vCenter Connection
My-Logger "Starting to Process ESXi Server Connection to $VMHost ..."
if (($global:DefaultVIServers).count -gt 0) {
Disconnect-VIServer -Force -Confirm:$False -ErrorAction SilentlyContinue
Disconnect-VIServer -Force -Confirm:$False -ErrorAction SilentlyContinue
}
$VIConnection = Connect-VIServer -Server $VMHost
if (-not $VIConnection.IsConnected) {
@@ -118,9 +118,9 @@ Process {
#endregion
if ($Validate -eq $True) {
#region: Enable SSH and disable SSH Warning
$SSHService = $ESXiHost | Get-VMHostService | where {$_.Key -eq 'TSM-SSH'}
$SSHService = $ESXiHost | Get-VMHostService | where {$_.Key -eq 'TSM-SSH'}
My-Logger "Starting SSH Service..."
if($SSHService.Running -ne $True){
Start-VMHostService -HostService $SSHService -Confirm:$false | Out-Null
@@ -140,12 +140,12 @@ Process {
#endregion
#region: Config NTP
My-Logger "Removing existing NTP Server..."
My-Logger "Removing existing NTP Server..."
try {
$ESXiHost | Remove-VMHostNtpServer -NtpServer (Get-VMHostNtpServer) -Confirm:$false
$ESXiHost | Remove-VMHostNtpServer -NtpServer (Get-VMHostNtpServer) -Confirm:$false
}
catch [System.Exception] {
Write-Warning "Error during removing existing NTP Servers."
Write-Warning "Error during removing existing NTP Servers."
}
My-Logger "Setting new NTP Servers..."
foreach ($myNTP in $NTP) {
@@ -154,16 +154,16 @@ Process {
My-Logger "Configure NTP Service..."
$NTPService = $ESXiHost | Get-VMHostService| Where-Object {$_.key -eq "ntpd"}
if($NTPService.Running -eq $True){
if($NTPService.Running -eq $True){
Stop-VMHostService -HostService $NTPService -Confirm:$false | Out-Null
}
if($NTPService.Policy -ne "on"){
if($NTPService.Policy -ne "on"){
Set-VMHostService -HostService $NTPService -Policy "on" -confirm:$False | Out-Null
}
My-Logger "Configure Local Time..."
$HostTimeSystem = Get-View $ESXiHost.ExtensionData.ConfigManager.DateTimeSystem
$HostTimeSystem.UpdateDateTime([DateTime]::UtcNow)
$HostTimeSystem = Get-View $ESXiHost.ExtensionData.ConfigManager.DateTimeSystem
$HostTimeSystem.UpdateDateTime([DateTime]::UtcNow)
My-Logger "Start NTP Service..."
Start-VMHostService -HostService $NTPService -confirm:$False | Out-Null
@@ -181,16 +181,16 @@ Process {
#endregion
#region: Configure Static HighPower
My-Logger "Setting PowerProfile to Static HighPower..."
My-Logger "Setting PowerProfile to Static HighPower..."
try {
$HostView = ($ESXiHost | Get-View)
(Get-View $HostView.ConfigManager.PowerSystem).ConfigurePowerPolicy(1)
}
catch [System.Exception] {
Write-Warning "Error during Configure Static HighPower. See latest errors..."
Write-Warning "Error during Configure Static HighPower. See latest errors..."
}
#endregion
#region: Conf Syslog
My-Logger "Setting Syslog Firewall Rule ..."
$SyslogFW = ($ESXiHost | Get-VMHostFirewallException | where {$_.Name -eq 'syslog'})
@@ -225,7 +225,7 @@ Process {
$esxcli2.storage.nmp.satp.rule.add.Invoke($arguments)
}
catch {
Write-Warning "Error during Configure HP 3PAR SATP/PSP Rule. See latest errors..."
Write-Warning "Error during Configure HP 3PAR SATP/PSP Rule. See latest errors..."
}
#endregion

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
@{
ModuleToProcess = 'NSXT.psm1'
ModuleVersion = '1.0.0.0'
@@ -7,7 +11,35 @@
Copyright = '(c) 2017. All rights reserved.'
Description = 'Powershell Module for NSX-T REST API Functions'
PowerShellVersion = '5.0'
FunctionsToExport = 'Get-NSXTComputeManager','Get-NSXTFabricNode','Get-NSXTFirewallRule','Get-NSXTIPPool','Get-NSXTLogicalSwitch','Get-NSXTManager','Get-NSXTTransportZone','Get-NSXTController'
FunctionsToExport = 'Get-NSXTBGPNeighbors',
'Get-NSXTComputeManager',
'Get-NSXTController',
'Get-NSXTEdgeCluster',
'Get-NSXTFabricNode',
'Get-NSXTFabricVM',
'Get-NSXTFirewallRule',
'Get-NSXTForwardingTable',
'Get-NSXTIPPool',
'Get-NSXTLogicalRouter',
'Get-NSXTLogicalRouterPorts',
'Get-NSXTLogicalSwitch',
'Get-NSXTManager',
'Get-NSXTNetworkRoutes',
'Get-NSXTRoutingTable',
'Get-NSXTTraceFlow',
'Get-NSXTTraceFlowObservations',
'Get-NSXTTransportNode',
'Get-NSXTTransportZone',
'Get-NSXTClusterNode',
'Set-NSXTIPPool',
'Set-NSXTLogicalRouter',
'Set-NSXTLogicalSwitch',
'Set-NSXTTraceFlow',
'Get-NSXTIPAMIPBlock',
'Set-NSXTIPAMIPBlock',
'Remove-NSXTIPAMIPBlock'
PrivateData = @{
PSData = @{
Tags = @('NSX-T','REST')

File diff suppressed because it is too large Load Diff

View File

@@ -30,18 +30,18 @@ add-type @"
.SYNOPSIS
Push Messages to VMware vRealize Log Insight.
.DESCRIPTION
Creates a Messages in VMware vRealize Log Insight via the Ingestion API
.EXAMPLE
Push-vLIMessage -vLIServer "loginsight.lan.local" -vLIAgentID "12862842-5A6D-679C-0E38-0E2BE888BB28" -Text "My Test"
.EXAMPLE
Push-vLIMessage -vLIServer "loginsight.lan.local" -vLIAgentID "12862842-5A6D-679C-0E38-0E2BE888BB28" -Text "My Test" -Hostname MyTEST -FieldName myTest -FieldContent myTest
.PARAMETER vLIServer
Specify the FQDN of your vRealize Log Insight Appliance
Specify the FQDN of your vRealize Log Insight Appliance
.PARAMETER vLIAgentID
Specify the vRealize Log Insight Agent ID, e.g. "12862842-5A6D-679C-0E38-0E2BE888BB28"
@@ -54,13 +54,13 @@ add-type @"
.PARAMETER FieldName
Specify the a Optional Field Name for vRealize Log Insight
.PARAMETER FieldContent
Specify the a Optional FieldContent for the Field in -FieldName for vRealize Log Insight
If FielName is missing and FieldContent is given, it will be ignored
#Requires PS -Version 3.0
#>
function Push-vLIMessage {
@@ -88,9 +88,9 @@ function Push-vLIMessage {
name = "hostname"
content = $Hostname
}
$Fields = @($Field_vLI, $Field_HostName)
if ($FieldName) {
$Field_Custom = [ordered]@{
name = $FieldName
@@ -98,14 +98,14 @@ function Push-vLIMessage {
}
$Fields += @($Field_Custom)
}
$Restcall = @{
messages = ([Object[]]([ordered]@{
text = ($Text)
fields = ([Object[]]$Fields)
}))
} | convertto-json -Depth 4
$Resturl = ("http://" + $vLIServer + ":9000/api/v1/messages/ingest/" + $vLIAgentID)
try
{

View File

@@ -0,0 +1,196 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Get-VMEvcMode {
<#
.SYNOPSIS
Gathers information on the EVC status of a VM
.DESCRIPTION
Will provide the EVC status for the specified VM
.NOTES
Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com
.PARAMETER Name
VM name which the function should be ran against
.EXAMPLE
Get-VMEvcMode -Name vmName
Retreives the EVC status of the provided VM
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)]
$Name
)
Process {
$evVM = @()
if ($name -is [string]) {$evVM += Get-VM -Name $Name -ErrorAction SilentlyContinue}
elseif ($name -is [array]) {
if ($name[0] -is [string]) {
$name | foreach {
$evVM += Get-VM -Name $_ -ErrorAction SilentlyContinue
}
}
elseif ($name[0] -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM = $name}
}
elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name}
if ($evVM -eq $null) {Write-Warning "No VMs found."}
else {
$output = @()
foreach ($v in $evVM) {
$report = "" | select Name,EVCMode
$report.Name = $v.Name
$report.EVCMode = $v.ExtensionData.Runtime.MinRequiredEVCModeKey
$output += $report
}
return $output
}
}
}
function Remove-VMEvcMode {
<#
.SYNOPSIS
Removes the EVC status of a VM
.DESCRIPTION
Will remove the EVC status for the specified VM
.NOTES
Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com
.PARAMETER Name
VM name which the function should be ran against
.EXAMPLE
Remove-VMEvcMode -Name vmName
Removes the EVC status of the provided VM
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)]
$Name
)
Process {
$evVM = @()
$updateVM = @()
if ($name -is [string]) {$evVM += Get-VM -Name $Name -ErrorAction SilentlyContinue}
elseif ($name -is [array]) {
if ($name[0] -is [string]) {
$name | foreach {
$evVM += Get-VM -Name $_ -ErrorAction SilentlyContinue
}
}
elseif ($name[0] -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM = $name}
}
elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name}
if ($evVM -eq $null) {Write-Warning "No VMs found."}
else {
foreach ($v in $evVM) {
if (($v.HardwareVersion -ge 'vmx-14' -and $v.PowerState -eq 'PoweredOff') -or ($v.Version -ge 'v14' -and $v.PowerState -eq 'PoweredOff')) {
$v.ExtensionData.ApplyEvcModeVM_Task($null, $true) | Out-Null
$updateVM += $v.Name
}
else {Write-Warning $v.Name + " does not have the minimum requirements of being Hardware Version 14 and powered off."}
}
if ($updateVM) {
Start-Sleep -Seconds 2
Get-VMEvcMode -Name $updateVM
}
}
}
}
function Set-VMEvcMode {
<#
.SYNOPSIS
Configures the EVC status of a VM
.DESCRIPTION
Will configure the EVC status for the specified VM
.NOTES
Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com
.PARAMETER Name
VM name which the function should be ran against
.PARAMETER EvcMode
The EVC Mode key which should be set
.EXAMPLE
Set-VMEvcMode -Name vmName -EvcMode intel-sandybridge
Configures the EVC status of the provided VM to be 'intel-sandybridge'
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)]
$Name,
[Parameter(Mandatory=$true,Position=1)]
[ValidateSet("intel-merom","intel-penryn","intel-nehalem","intel-westmere","intel-sandybridge","intel-ivybridge","intel-haswell","intel-broadwell","intel-skylake","amd-rev-e","amd-rev-f","amd-greyhound-no3dnow","amd-greyhound","amd-bulldozer","amd-piledriver","amd-steamroller","amd-zen")]
$EvcMode
)
Process {
$evVM = @()
$updateVM = @()
if ($name -is [string]) {$evVM += Get-VM -Name $Name -ErrorAction SilentlyContinue}
elseif ($name -is [array]) {
if ($name[0] -is [string]) {
$name | foreach {
$evVM += Get-VM -Name $_ -ErrorAction SilentlyContinue
}
}
elseif ($name[0] -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM = $name}
}
elseif ($name -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]) {$evVM += $name}
if ($evVM -eq $null) {Write-Warning "No VMs found."}
else {
$si = Get-View ServiceInstance
$evcMask = $si.Capability.SupportedEvcMode | where-object {$_.key -eq $EvcMode} | select -ExpandProperty FeatureMask
foreach ($v in $evVM) {
if (($v.HardwareVersion -ge 'vmx-14' -and $v.PowerState -eq 'PoweredOff') -or ($v.Version -ge 'v14' -and $v.PowerState -eq 'PoweredOff')) {
$v.ExtensionData.ApplyEvcModeVM_Task($evcMask, $true) | Out-Null
$updateVM += $v.Name
}
else {Write-Warning $v.Name + " does not have the minimum requirements of being Hardware Version 14 and powered off."}
}
if ($updateVM) {
Start-Sleep -Seconds 2
Get-VMEvcMode -Name $updateVM
}
}
}
}

View File

@@ -1,4 +1,8 @@
Function New-PHAProvider {
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function New-PHAProvider {
<#
.NOTES
===========================================================================

View File

@@ -1,17 +1,21 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Recommend-Sizing {
<#
<#
.NOTES
===========================================================================
Created by: Markus Kraus
Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com
===========================================================================
Changelog:
2016.11 ver 1.0 Base Release
Changelog:
2016.11 ver 1.0 Base Release
2016.11 ver 1.1 Optional Stats Collection
2016.11 ver 1.2 VM Stats from Realtime Data and new Counters
===========================================================================
External Code Sources:
External Code Sources:
http://www.lucd.info/2011/04/22/get-the-maximum-iops/
https://communities.vmware.com/thread/485386
===========================================================================
@@ -25,16 +29,16 @@ function Recommend-Sizing {
===========================================================================
.DESCRIPTION
This Function collects Basic vSphere Informations for a Hardware Sizing Recommandation. Focus is in Compute Ressources.
This Function collects Basic vSphere Informations for a Hardware Sizing Recommandation. Focus is in Compute Ressources.
.Example
Recommend-Sizing -ClusterNames Cluster01, Cluster02 -Stats -StatsRange 60 -Verbose
Recommend-Sizing -ClusterNames Cluster01, Cluster02 -Stats -StatsRange 60 -Verbose
.Example
Recommend-Sizing -ClusterNames Cluster01, Cluster02
Recommend-Sizing -ClusterNames Cluster01, Cluster02
.Example
Recommend-Sizing -ClusterNames Cluster01
Recommend-Sizing -ClusterNames Cluster01
.PARAMETER ClusterNames
List of your vSphere Cluser Names to process.
@@ -53,14 +57,14 @@ function Recommend-Sizing {
#>
[CmdletBinding()]
param(
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
[Array] $ClusterNames,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1, ParameterSetName = "Stats")]
[switch] $Stats,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=2, ParameterSetName = "Stats")]
[int] $StatsRange = 1440
[int] $StatsRange = 1440
)
Begin {
if ($Stats) {
@@ -70,7 +74,7 @@ Begin {
$Validate = $True
#region: Check Clusters
Write-Verbose "$(Get-Date -Format G) Starting Cluster Validation..."
Write-Verbose "$(Get-Date -Format G) Starting Cluster Validation..."
foreach ($ClusterName in $ClusterNames) {
$TestCluster = Get-Cluster -Name $ClusterName -ErrorAction SilentlyContinue -Verbose:$False
if(!($TestCluster)){
@@ -82,7 +86,7 @@ Begin {
$Validate = $False
}
}
Write-Verbose "$(Get-Date -Format G) Cluster Validation completed"
Write-Verbose "$(Get-Date -Format G) Cluster Validation completed"
#endregion
}
@@ -91,7 +95,7 @@ Process {
if ($Validate -eq $True) {
foreach ($ClusterName in $ClusterNames) {
#region: Get Cluster Objects
Write-Verbose "$(Get-Date -Format G) Collect $ClusterName Cluster Objects..."
Write-Verbose "$(Get-Date -Format G) Collect $ClusterName Cluster Objects..."
$Cluster = Get-Cluster -Name $ClusterName -Verbose:$False
$ClusterVMs = $Cluster | Get-VM -Verbose:$False
$ClusterVMsPoweredOn = $ClusterVMs | where {$_.PowerState -eq "PoweredOn"}
@@ -101,24 +105,24 @@ Process {
$HostsAverageMemoryUsage = $([math]::round( (($ClusterHosts | Measure-Object -Average -Property MemoryUsageGB).Average / ($ClusterHosts | Measure-Object -Average -Property MemoryTotalGB).Average) * 100,1 ))
$HostsAverageCpuUsageMhz = [math]::round( ($ClusterHosts | Measure-Object -Average -Property CpuUsageMhz).Average,1 )
$HostsAverageCpuUsage = $([math]::round( (($ClusterHosts | Measure-Object -Average -Property CpuUsageMhz).Average / ($ClusterHosts | Measure-Object -Average -Property CpuTotalMhz).Average) * 100,1 ))
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Cluster Objects completed"
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Cluster Objects completed"
#endregion
#region: CPU Calculation
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details..."
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details..."
$VMvCPUs = ($ClusterVMs | Measure-Object -Sum -Property NumCpu).sum
$LogicalThreads = $Cluster.ExtensionData.Summary.NumCpuThreads
$CpuCores = $Cluster.ExtensionData.Summary.NumCpuCores
$vCPUpCPUratio = [math]::round( $VMvCPUs / $LogicalThreads,1 )
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details completed."
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details completed."
#endregion
#region: Memory Calculation
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details..."
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details..."
$AllocatedVMMemoryGB = [math]::round( ($ClusterVMs | Measure-Object -Sum -Property MemoryGB).sum )
$PhysicalMemory = [math]::round( $Cluster.ExtensionData.Summary.TotalMemory / 1073741824,1 )
$MemoryUsage = [math]::round( ($AllocatedVMMemoryGB / $PhysicalMemory) * 100 ,1 )
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details completed"
Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details completed"
#endregion
if ($Stats) {
@@ -129,10 +133,10 @@ Process {
$VMStats = Get-Stat -Realtime -Stat $VMMetrics -Entity $ClusterVMsPoweredOn -Start $Start -Verbose:$False
Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) VM Stats completed"
#endregion
#region: Creating VM Stats Report
Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Stats Report..."
$ReportVMPerf = @()
$ReportVMPerf = @()
$ReportVMPerf = $VMStats | Group-Object -Property {$_.Entity.Name},Instance | %{
New-Object PSObject -Property @{
IOPSWriteAvg = ($_.Group | `
@@ -168,7 +172,7 @@ Process {
CapacityGB = $CapacityGB
}
$reportDiskSpace += $Report
}
}
}
}
Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Disk Space Report completed"
@@ -188,9 +192,9 @@ Process {
DrsEnabled = $Cluster.DrsEnabled
Hosts = $Cluster.ExtensionData.Summary.NumHosts
HostsAverageMemoryUsageGB = $HostsAverageMemoryUsageGB
HostsAverageMemoryUsage = "$HostsAverageMemoryUsage %"
HostsAverageMemoryUsage = "$HostsAverageMemoryUsage %"
HostsAverageCpuUsageMhz = $HostsAverageCpuUsageMhz
HostsAverageCpuUsage = "$HostsAverageCpuUsage %"
HostsAverageCpuUsage = "$HostsAverageCpuUsage %"
PhysicalCPUCores = $CpuCores
LogicalCPUThreads = $LogicalThreads
VMs = $ClusterVMs.count
@@ -198,7 +202,7 @@ Process {
VMvCPUs = $VMvCPUs
vCPUpCPUratio = "$vCPUpCPUratio : 1"
PhysicalMemoryGB = $PhysicalMemory
AllocatedVMMemoryGB = $AllocatedVMMemoryGB
AllocatedVMMemoryGB = $AllocatedVMMemoryGB
ClusterMemoryUsage = "$MemoryUsage %"
SumVMDiskSpaceGB = [math]::round( ($reportDiskSpace | Measure-Object -Sum -Property CapacityGB).sum, 1 )
SumDatastoreSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property CapacityGB).sum, 1 )
@@ -217,7 +221,7 @@ Process {
Else {
Write-Error "Validation Failed! Processing Skipped"
}
}
End {

1
Modules/SRM/.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.psd1 diff

1
Modules/SRM/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.zip

View File

@@ -0,0 +1,176 @@
<#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Depends on SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
# It is assumed that the connection to VC and SRM Server have already been made
Function Get-SrmConfigReportSite {
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
Get-SrmServer $SrmServer |
Format-Table -Wrap -AutoSize @{Label="SRM Site Name"; Expression={$_.ExtensionData.GetSiteName()} },
@{Label="SRM Host"; Expression={$_.Name} },
@{Label="SRM Port"; Expression={$_.Port} },
@{Label="Version"; Expression={$_.Version} },
@{Label="Build"; Expression={$_.Build} },
@{Label="SRM Peer Site Name"; Expression={$_.ExtensionData.GetPairedSite().Name} }
}
Function Get-SrmConfigReportPlan {
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
Get-SrmRecoveryPlan -SrmServer $SrmServer | %{
$rp = $_
$rpinfo = $rp.GetInfo()
$peerState = $rp.GetPeer().State
$pgs = Get-SrmProtectionGroup -RecoveryPlan $rp
$pgnames = $pgs | %{ $_.GetInfo().Name }
$output = "" | select plan, state, peerState, groups
$output.plan = $rpinfo.Name
$output.state = $rpinfo.State
$output.peerState = $peerState
if ($pgnames) {
$output.groups = [string]::Join(",`r`n", $pgnames)
} else {
$output.groups = "NONE"
}
$output
} | Format-Table -Wrap -AutoSize @{Label="Recovery Plan Name"; Expression={$_.plan} },
@{Label="Recovery State"; Expression={$_.state} },
@{Label="Peer Recovery State"; Expression={$_.peerState} },
@{Label="Protection Groups"; Expression={$_.groups}}
}
Function Get-SrmConfigReportProtectionGroup {
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
Get-SrmProtectionGroup -SrmServer $SrmServer | %{
$pg = $_
$pginfo = $pg.GetInfo()
$pgstate = $pg.GetProtectionState()
$peerState = $pg.GetPeer().State
$rps = Get-SrmRecoveryPlan -ProtectionGroup $pg
$rpnames = $rps | %{ $_.GetInfo().Name }
$output = "" | select name, type, state, peerState, plans
$output.name = $pginfo.Name
$output.type = $pginfo.Type
$output.state = $pgstate
$output.peerState = $peerState
if ($rpnames) {
$output.plans = [string]::Join(",`r`n", $rpnames)
} else {
$output.plans = "NONE"
}
$output
} | Format-Table -Wrap -AutoSize @{Label="Protection Group Name"; Expression={$_.name} },
@{Label="Type"; Expression={$_.type} },
@{Label="Protection State"; Expression={$_.state} },
@{Label="Peer Protection State"; Expression={$_.peerState} },
@{Label="Recovery Plans"; Expression={$_.plans} }
}
Function Get-SrmConfigReportProtectedDatastore {
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
Get-SrmProtectionGroup -SrmServer $SrmServer -Type "san" | %{
$pg = $_
$pginfo = $pg.GetInfo()
$pds = Get-SrmProtectedDatastore -ProtectionGroup $pg
$pds | %{
$pd = $_
$output = "" | select datacenter, group, name, capacity, free
$output.datacenter = $pd.Datacenter.Name
$output.group = $pginfo.Name
$output.name = $pd.Name
$output.capacity = $pd.CapacityGB
$output.free = $pd.FreeSpaceGB
$output
}
} | Format-Table -Wrap -AutoSize -GroupBy "datacenter" @{Label="Datastore Name"; Expression={$_.name} },
@{Label="Capacity GB"; Expression={$_.capacity} },
@{Label="Free GB"; Expression={$_.free} },
@{Label="Protection Group"; Expression={$_.group} }
}
Function Get-SrmConfigReportProtectedVm {
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$srmversion = Get-SrmServerVersion -SrmServer $SrmServer
$srmMajorVersion, $srmMinorVersion = $srmversion -split "\."
Get-SrmProtectionGroup -SrmServer $SrmServer | %{
$pg = $_
$pginfo = $pg.GetInfo()
$pvms = Get-SrmProtectedVM -ProtectionGroup $pg
$rps = Get-SrmRecoveryPlan -ProtectionGroup $pg
$rpnames = $rps | %{ $_.GetInfo().Name }
$pvms | %{
$pvm = $_
if ($srmMajorVersion -ge 6 -or ($srmMajorVersion -eq 5 -and $srmMinorVersion -eq 8)) {
$rs = $rps | Select -First 1 | %{ $_.GetRecoverySettings($pvm.Vm.MoRef) }
}
$output = "" | select group, name, moRef, needsConfiguration, state, plans, priority, finalPowerState, preCallouts, postCallouts
$output.group = $pginfo.Name
$output.name = $pvm.Vm.Name
$output.moRef = $pvm.Vm.MoRef # this is necessary in case we can't retrieve the name when VC is unavailable
$output.needsConfiguration = $pvm.NeedsConfiguration
$output.state = $pvm.State
$output.plans = [string]::Join(",`r`n", $rpnames)
if ($rs) {
$output.priority = $rs.RecoveryPriority
$output.finalPowerState = $rs.FinalPowerState
$output.preCallouts = $rs.PrePowerOnCallouts.Count
$output.postCallouts = $rs.PostPowerOnCallouts.Count
}
$output
}
} | Format-Table -Wrap -AutoSize @{Label="VM Name"; Expression={$_.name} },
@{Label="VM MoRef"; Expression={$_.moRef} },
@{Label="Needs Config"; Expression={$_.needsConfiguration} },
@{Label="VM Protection State"; Expression={$_.state} },
@{Label="Protection Group"; Expression={$_.group} },
@{Label="Recovery Plans"; Expression={$_.plans} },
@{Label="Recovery Priority"; Expression={$_.priority} },
@{Label="Final Power State"; Expression={$_.finalPowerState} },
@{Label="Pre-PowerOn Callouts"; Expression={$_.preCallouts} },
@{Label="Post-PowerOn Callouts"; Expression={$_.postCallouts} }
}
Function Get-SrmConfigReport {
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
Get-SrmConfigReportSite -SrmServer $SrmServer
Get-SrmConfigReportPlan -SrmServer $SrmServer
Get-SrmConfigReportProtectionGroup -SrmServer $SrmServer
Get-SrmConfigReportProtectedDatastore -SrmServer $SrmServer
Get-SrmConfigReportProtectedVm -SrmServer $SrmServer
}

View File

@@ -0,0 +1,43 @@
<#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# Depends on SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
# It is assumed that the connections to active VC and SRM Server have already been made
Import-Module Meadowcroft.SRM -Prefix Srm
$TagCategoryName = 'Meadowcroft.SRM.VM'
$TagCategoryDescription = 'Tag category for tagging VMs with SRM state'
# If the tag category doesn't exist, create it and the relevant tags
$TagCategory = Get-TagCategory -Name $TagCategoryName -ErrorAction SilentlyContinue
if (-Not $TagCategory) {
Write-Output "Creating Tag Category $TagCategoryName"
$TagCategory = New-TagCategory -Name $TagCategoryName -Description $TagCategoryDescription -EntityType 'VirtualMachine'
Write-Output "Creating Tag SrmProtectedVm"
New-Tag -Name 'SrmProtectedVm' -Category $TagCategory -Description "VM protected by VMware SRM"
Write-Output "Creating Tag SrmTestVm"
New-Tag -Name 'SrmTestVm' -Category $TagCategory -Description "Test VM instantiated by VMware SRM"
Write-Output "Creating Tag SrmPlaceholderVm"
New-Tag -Name 'SrmPlaceholderVm' -Category $TagCategory -Description "Placeholder VM used by VMware SRM"
}
$protectedVmTag = Get-Tag -Name 'SrmProtectedVm' -Category $TagCategory
$testVmTag = Get-Tag -Name 'SrmTestVm' -Category $TagCategory
$placeholderVmTag = Get-Tag -Name 'SrmPlaceholderVm' -Category $TagCategory
# Assign protected tag to a VM, use ready state to get "local" protected VMs
Get-SrmProtectedVM -State Ready | %{ New-TagAssignment -Tag $protectedVmTag -Entity $(Get-VIObjectByVIView $_.Vm) | Out-Null }
# Assign test tag to a VM
Get-SrmTestVM | %{ New-TagAssignment -Tag $testVmTag -Entity $_ | Out-Null }
# Assign placeholder tag to a VM
Get-SrmPlaceholderVM | %{ New-TagAssignment -Tag $placeholderVmTag -Entity $_ | Out-Null }

74
Modules/SRM/LICENSE.txt Normal file
View File

@@ -0,0 +1,74 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright 2017-2021 VMware, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,431 @@
<#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
<#
.SYNOPSIS
Get the subset of protection groups matching the input criteria
.PARAMETER Name
Return protection groups matching the specified name
.PARAMETER Type
Return protection groups matching the specified protection group
type. For SRM 5.0-5.5 this is either 'san' for protection groups
consisting of a set of replicated datastores or 'vr' for vSphere
Replication based protection groups.
.PARAMETER RecoveryPlan
Return protection groups associated with a particular recovery
plan
.PARAMETER SrmServer
the SRM server to use for this operation.
#>
Function Get-ProtectionGroup {
[cmdletbinding()]
Param(
[Parameter(position=1)][string] $Name,
[string] $Type,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan[]] $RecoveryPlan,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
begin {
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
$pgs = @()
}
process {
if ($RecoveryPlan) {
foreach ($rp in $RecoveryPlan) {
$pgs += $RecoveryPlan.GetInfo().ProtectionGroups
}
$pgs = Select_UniqueByMoRef($pgs)
} else {
$pgs += $api.Protection.ListProtectionGroups()
}
}
end {
$pgs | ForEach-Object {
$pg = $_
$pgi = $pg.GetInfo()
$selected = (-not $Name -or ($Name -eq $pgi.Name)) -and (-not $Type -or ($Type -eq $pgi.Type))
if ($selected) {
Add-Member -InputObject $pg -MemberType NoteProperty -Name "Name" -Value $pgi.Name
$pg
}
}
}
}
<#
.SYNOPSIS
Get the subset of protected VMs matching the input criteria
.PARAMETER Name
Return protected VMs matching the specified name
.PARAMETER State
Return protected VMs matching the specified state. For protected
VMs on the protected site this is usually 'ready', for
placeholder VMs this is 'shadowing'
.PARAMETER ProtectionGroup
Return protected VMs associated with particular protection
groups
#>
Function Get-ProtectedVM {
[cmdletbinding()]
Param(
[Parameter(position=1)][string] $Name,
[VMware.VimAutomation.Srm.Views.SrmProtectionGroupProtectionState] $State,
[VMware.VimAutomation.Srm.Views.SrmProtectionGroupProtectionState] $PeerState,
[switch] $ConfiguredOnly,
[switch] $UnconfiguredOnly,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup[]] $ProtectionGroup,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan[]] $RecoveryPlan,
[string] $ProtectionGroupName,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
if ($null -eq $ProtectionGroup) {
$ProtectionGroup = Get-ProtectionGroup -Name $ProtectionGroupName -RecoveryPlan $RecoveryPlan -SrmServer $SrmServer
}
$ProtectionGroup | ForEach-Object {
$pg = $_
$pg.ListProtectedVms() | ForEach-Object {
# try and update the view data for the protected VM
try {
$_.Vm.UpdateViewData()
} catch {
Write-Error $_
} finally {
$_
}
} | Where-object { -not $Name -or ($Name -eq $_.Vm.Name) } |
where-object { -not $State -or ($State -eq $_.State) } |
where-object { -not $PeerState -or ($PeerState -eq $_.PeerState) } |
where-object { ($ConfiguredOnly -and $_.NeedsConfiguration -eq $false) -or ($UnconfiguredOnly -and $_.NeedsConfiguration -eq $true) -or (-not $ConfiguredOnly -and -not $UnconfiguredOnly) }
}
}
<#
.SYNOPSIS
Get the unprotected VMs that are associated with a protection group
.PARAMETER ProtectionGroup
Return unprotected VMs associated with particular protection
groups. For VR protection groups this is VMs that are associated
with the PG but not configured, For ABR protection groups this is
VMs on replicated datastores associated with the group that are not
configured.
#>
Function Get-UnProtectedVM {
[cmdletbinding()]
Param(
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup[]] $ProtectionGroup,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan[]] $RecoveryPlan,
[string] $ProtectionGroupName,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
if ($null -eq $ProtectionGroup) {
$ProtectionGroup = Get-ProtectionGroup -Name $ProtectionGroupName -RecoveryPlan $RecoveryPlan -SrmServer $SrmServer
}
$associatedVMs = @()
$protectedVmRefs = @()
$ProtectionGroup | ForEach-Object {
$pg = $_
# For VR listAssociatedVms to get list of VMs
if ($pg.GetInfo().Type -eq 'vr') {
$associatedVMs += @($pg.ListAssociatedVms() | Get-VIObjectByVIView)
}
# TODO test this: For ABR get VMs on GetProtectedDatastore
if ($pg.GetInfo().Type -eq 'san') {
$pds = @(Get-ProtectedDatastore -ProtectionGroup $pg)
$pds | ForEach-Object {
$ds = Get-Datastore -id $_.MoRef
$associatedVMs += @(Get-VM -Datastore $ds)
}
}
# get protected VMs
$protectedVmRefs += @(Get-ProtectedVM -ProtectionGroup $pg | ForEach-Object { $_.Vm.MoRef } | Select-Object -Unique)
}
# get associated but unprotected VMs
$associatedVMs | Where-Object { $protectedVmRefs -notcontains $_.ExtensionData.MoRef }
}
#Untested as I don't have ABR setup in my lab yet
<#
.SYNOPSIS
Get the subset of protected Datastores matching the input criteria
.PARAMETER ProtectionGroup
Return protected datastores associated with particular protection
groups
#>
Function Get-ProtectedDatastore {
[cmdletbinding()]
Param(
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup[]] $ProtectionGroup,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan[]] $RecoveryPlan,
[string] $ProtectionGroupName,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
if (-not $ProtectionGroup) {
$ProtectionGroup = Get-ProtectionGroup -Name $ProtectionGroupName -RecoveryPlan $RecoveryPlan -SrmServer $SrmServer
}
$ProtectionGroup | ForEach-Object {
$pg = $_
if ($pg.GetInfo().Type -eq 'san') { # only supported for array based replication datastores
$pg.ListProtectedDatastores()
}
}
}
#Untested as I don't have ABR setup in my lab yet
<#
.SYNOPSIS
Get the replicated datastores that aren't associated with a protection group.
#>
Function Get-ReplicatedDatastore {
[cmdletbinding()]
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
$api.Protection.ListUnassignedReplicatedDatastores()
}
<#
.SYNOPSIS
Protect a VM using SRM
.PARAMETER ProtectionGroup
The protection group that this VM will belong to
.PARAMETER Vm
The virtual machine to protect
#>
Function Protect-VM {
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup] $ProtectionGroup,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine] $Vm,
[Parameter (ValueFromPipeline=$true)][VMware.Vim.VirtualMachine] $VmView
)
$moRef = Get_MoRefFromVmObj -Vm $Vm -VmView $VmView
$pgi = $ProtectionGroup.GetInfo()
#TODO query protection status first
if ($moRef) {
if ($pgi.Type -eq 'vr') {
$ProtectionGroup.AssociateVms(@($moRef))
}
$protectionSpec = New-Object VMware.VimAutomation.Srm.Views.SrmProtectionGroupVmProtectionSpec
$protectionSpec.Vm = $moRef
$protectTask = $ProtectionGroup.ProtectVms($protectionSpec)
while(-not $protectTask.IsComplete()) { Start-Sleep -Seconds 1 }
$protectTask.GetResult()
} else {
throw "Can't protect the VM, no MoRef found."
}
}
<#
.SYNOPSIS
Unprotect a VM using SRM
.PARAMETER ProtectionGroup
The protection group that this VM will be removed from
.PARAMETER Vm
The virtual machine to unprotect
#>
Function Unprotect-VM {
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup] $ProtectionGroup,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine] $Vm,
[Parameter (ValueFromPipeline=$true)][VMware.Vim.VirtualMachine] $VmView,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroupProtectedVm] $ProtectedVm
)
$moRef = Get_MoRefFromVmObj -Vm $Vm -VmView $VmView -ProtectedVm $ProtectedVm
$pgi = $ProtectionGroup.GetInfo()
$protectTask = $ProtectionGroup.UnprotectVms($moRef)
while(-not $protectTask.IsComplete()) { Start-Sleep -Seconds 1 }
if ($pgi.Type -eq 'vr') {
$ProtectionGroup.UnassociateVms(@($moRef))
}
$protectTask.GetResult()
}
<#
.SYNOPSIS
Get a protection group folder
.PARAMETER SrmServer
The SRM Server to query for the protection group folder
#>
Function Get-ProtectionGroupFolder {
[cmdletbinding()]
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
$folder = $api.Protection.GetProtectionGroupRootFolder()
return $folder
}
<#
.SYNOPSIS
Create a new protection group
.PARAMETER Name
The name of the protection group
.PARAMETER Description
Description of the protection group
.PARAMETER Folder
The protection group folder in which to create the new protection group
.PARAMETER ArrayReplication
Set if protection group is for replicating VMs using Array based replication
.PARAMETER vSphereReplication
Set if protection group is for replicating VMs with vSphere Replication
.PARAMETER VMs
For vSphere Replication based protection, the VMs to add to the replication
group. These should already be replicated.
.PARAMETER VMViews
For vSphere Replication based protection, the VMs to add to the replication
group. These should already be replicated.
.PARAMETER SrmServer
The SRM Server to perform the operation against
#>
Function New-ProtectionGroup {
[cmdletbinding(DefaultParameterSetName="VR", SupportsShouldProcess=$True, ConfirmImpact="Medium")]
[OutputType([VMware.VimAutomation.Srm.Views.SrmProtectionGroup])]
Param(
[Parameter (Mandatory=$true)] $Name,
$Description,
[VMware.VimAutomation.Srm.Views.SrmProtectionGroupFolder] $Folder,
[Parameter (ParameterSetName="ABR", Mandatory=$true)][switch] $ArrayReplication,
[Parameter (ValueFromPipeline=$true, ParameterSetName="ABR")][VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.Datastore[]] $Datastores,
[Parameter (ValueFromPipeline=$true, ParameterSetName="ABR")][VMware.Vim.Datastore[]] $DatastoreViews,
[Parameter (ParameterSetName="VR", Mandatory=$true)][switch] $vSphereReplication,
[Parameter (ValueFromPipeline=$true, ParameterSetName="VR")][VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $VMs,
[Parameter (ValueFromPipeline=$true, ParameterSetName="VR")][VMware.Vim.VirtualMachine[]] $VMViews,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint $SrmServer
[VMware.VimAutomation.Srm.Views.SrmCreateProtectionGroupTask] $task = $null
#get root folder if this wasn't specified as a parameter
if(-not $Folder) {
$Folder = Get-ProtectionGroupFolder -SrmServer $SrmServer
}
if ($vSphereReplication) {
#create list of managed object references from VM and/or VM view arrays
[VMware.Vim.ManagedObjectReference[]]$moRefs = @()
foreach ($vm in $VMs) {
$moRefs += Get_MoRefFromVmObj -Vm $Vm
}
foreach ($VmView in $VMViews) {
$moRefs += Get_MoRefFromVmObj -VmView $VmView
}
if ($pscmdlet.ShouldProcess($Name, "New")) {
$task = $api.Protection.CreateHbrProtectionGroup($Folder.MoRef, $Name, $Description, $moRefs)
}
} elseif ($ArrayReplication) {
#create list of managed object references from VM and/or VM view arrays
$moRefs = @()
foreach ($ds in $Datastores) {
$moRefs += $ds.ExtensionData.MoRef
}
foreach ($DsView in $DatastoreViews) {
$moRefs += $DsView.MoRef
}
if ($pscmdlet.ShouldProcess($Name, "New")) {
$task = $api.Protection.CreateAbrProtectionGroup($Folder.MoRef, $Name, $Description, $moRefs)
}
} else {
throw "Undetermined protection group type"
}
# Complete task
while(-not $task.IsCreateProtectionGroupComplete()) { Start-Sleep -Seconds 1 }
# Retrieve the protection group, and protect associated VMs
$pg = $task.GetNewProtectionGroup()
if ($pg) {
$unProtectedVMs = Get-UnProtectedVM -ProtectionGroup $pg
$unProtectedVMs | Protect-VM -ProtectionGroup $pg
}
return $pg
}
<#
.SYNOPSIS
Delete a protection group
.PARAMETER ProtectionGroup
The protection group to remove
.PARAMETER SrmServer
The SRM Server to perform the operation against
#>
Function Remove-ProtectionGroup {
[cmdletbinding(SupportsShouldProcess=$True, ConfirmImpact="High")]
[OutputType([VMware.VimAutomation.Srm.Views.RemoveProtectionGroupTask])]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup] $ProtectionGroup,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint $SrmServer
[VMware.VimAutomation.Srm.Views.RemoveProtectionGroupTask] $task = $null
$pginfo = $ProtectionGroup.GetInfo()
if ($pscmdlet.ShouldProcess($pginfo.Name, "Remove")) {
$task = $api.Protection.RemoveProtectionGroup($ProtectionGroup.MoRef)
}
return $task
}

View File

@@ -0,0 +1,565 @@
<#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
<#
.SYNOPSIS
Get the subset of recovery plans matching the input criteria
.PARAMETER Name
Return recovery plans matching the specified name
.PARAMETER ProtectionGroup
Return recovery plans associated with particular protection
groups
#>
Function Get-RecoveryPlan {
[cmdletbinding()]
Param(
[Parameter(position=1)][string] $Name,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup[]] $ProtectionGroup,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
begin {
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
$rps = @()
}
process {
if ($ProtectionGroup) {
foreach ($pg in $ProtectionGroup) {
$rps += $pg.ListRecoveryPlans()
}
$rps = Select_UniqueByMoRef($rps)
} else {
$rps += $api.Recovery.ListPlans()
}
}
end {
$rps | ForEach-Object {
$rp = $_
$rpi = $rp.GetInfo()
$selected = (-not $Name -or ($Name -eq $rpi.Name))
if ($selected) {
Add-Member -InputObject $rp -MemberType NoteProperty -Name "Name" -Value $rpi.Name
$rp
}
}
}
}
<#
.SYNOPSIS
Start a Recovery Plan action like test, recovery, cleanup, etc.
.PARAMETER RecoveryPlan
The recovery plan to start
.PARAMETER RecoveryMode
The recovery mode to invoke on the plan. May be one of "Test", "Cleanup", "Failover", "Migrate", "Reprotect"
#>
Function Start-RecoveryPlan {
[cmdletbinding(SupportsShouldProcess=$True, ConfirmImpact="High")]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true, Position=1)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan] $RecoveryPlan,
[VMware.VimAutomation.Srm.Views.SrmRecoveryPlanRecoveryMode] $RecoveryMode = [VMware.VimAutomation.Srm.Views.SrmRecoveryPlanRecoveryMode]::Test,
[bool] $SyncData = $True
)
# Validate with informative error messages
$rpinfo = $RecoveryPlan.GetInfo()
# Create recovery options
$rpOpt = New-Object VMware.VimAutomation.Srm.Views.SrmRecoveryOptions
$rpOpt.SyncData = $SyncData
# Prompt the user to confirm they want to execute the action
if ($pscmdlet.ShouldProcess($rpinfo.Name, $RecoveryMode)) {
if ($rpinfo.State -eq 'Protecting') {
throw "This recovery plan action needs to be initiated from the other SRM instance"
}
$RecoveryPlan.Start($RecoveryMode, $rpOpt)
}
}
<#
.SYNOPSIS
Stop a running Recovery Plan action.
.PARAMETER RecoveryPlan
The recovery plan to stop
#>
Function Stop-RecoveryPlan {
[cmdletbinding(SupportsShouldProcess=$True,ConfirmImpact="High")]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true, Position=1)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan] $RecoveryPlan
)
# Validate with informative error messages
$rpinfo = $RecoveryPlan.GetInfo()
# Prompt the user to confirm they want to cancel the running action
if ($pscmdlet.ShouldProcess($rpinfo.Name, 'Cancel')) {
$RecoveryPlan.Cancel()
}
}
<#
.SYNOPSIS
Retrieve the historical results of a recovery plan
.PARAMETER RecoveryPlan
The recovery plan to retrieve the history for
#>
Function Get-RecoveryPlanResult {
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true, Position=1)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan] $RecoveryPlan,
[VMware.VimAutomation.Srm.Views.SrmRecoveryPlanRecoveryMode] $RecoveryMode,
[VMware.VimAutomation.Srm.Views.SrmRecoveryResultResultState] $ResultState,
[DateTime] $StartedAfter,
[DateTime] $startedBefore,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
# Get the history objects
$history = $api.Recovery.GetHistory($RecoveryPlan.MoRef)
$resultCount = $history.GetResultCount()
if ($resultCount -gt 0) {
$results = $history.GetRecoveryResult($resultCount)
$results |
Where-Object { -not $RecoveryMode -or $_.RunMode -eq $RecoveryMode } |
Where-Object { -not $ResultState -or $_.ResultState -eq $ResultState } |
Where-Object { $null -eq $StartedAfter -or $_.StartTime -gt $StartedAfter } |
Where-Object { $null -eq $StartedBefore -or $_.StartTime -lt $StartedBefore }
}
}
<#
.SYNOPSIS
Exports a recovery plan result object to XML format
.PARAMETER RecoveryPlanResult
The recovery plan result to export
#>
Function Export-RecoveryPlanResultAsXml {
[cmdletbinding()]
[OutputType([xml])]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true, Position=1)][VMware.VimAutomation.Srm.Views.SrmRecoveryResult] $RecoveryPlanResult,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
$RecoveryPlan = $RecoveryPlanResult.Plan
$history = $api.Recovery.GetHistory($RecoveryPlan.MoRef)
$lines = $history.GetResultLength($RecoveryPlanResult.Key)
[xml] $history.RetrieveStatus($RecoveryPlanResult.Key, 0, $lines)
}
<#
.SYNOPSIS
Add a protection group to a recovery plan. This requires SRM 5.8 or later.
.PARAMETER RecoveryPlan
The recovery plan the protection group will be associated with
.PARAMETER ProtectionGroup
The protection group to associate with the recovery plan
#>
Function Add-ProtectionGroupToRecoveryPlan {
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true, Position=1)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan] $RecoveryPlan,
[Parameter (Mandatory=$true, ValueFromPipeline=$true, Position=2)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup] $ProtectionGroup
)
if ($RecoveryPlan -and $ProtectionGroup) {
foreach ($pg in $ProtectionGroup) {
try {
$RecoveryPlan.AddProtectionGroup($pg.MoRef)
} catch {
Write-Error $_
}
}
}
}
<#
.SYNOPSIS
Remove a protection group to a recovery plan. This requires SRM 6.5 or later.
.PARAMETER RecoveryPlan
The recovery plan the protection group will be disassociated from
.PARAMETER ProtectionGroup
The protection group to disassociate from the recovery plan
#>
Function Remove-ProtectionGroupFromRecoveryPlan {
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan] $RecoveryPlan,
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroup] $ProtectionGroup
)
if ($RecoveryPlan -and $ProtectionGroup) {
foreach ($pg in $ProtectionGroup) {
try {
$RecoveryPlan.RemoveProtectionGroupFromRecoveryPlan($pg.MoRef)
} catch {
Write-Error $_
}
}
}
}
<#
.SYNOPSIS
Get the recovery settings of a protected VM. This requires SRM 5.8 or later.
.PARAMETER RecoveryPlan
The recovery plan the settings will be retrieved from.
.PARAMETER Vm
The virtual machine to retieve recovery settings for.
#>
Function Get-RecoverySetting {
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan] $RecoveryPlan,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine] $Vm,
[Parameter (ValueFromPipeline=$true)][VMware.Vim.VirtualMachine] $VmView,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroupProtectedVm] $ProtectedVm
)
$moRef = Get_MoRefFromVmObj -Vm $Vm -VmView $VmView -ProtectedVm $ProtectedVm
if ($RecoveryPlan -and $moRef) {
$RecoveryPlan.GetRecoverySettings($moRef)
}
}
<#
.SYNOPSIS
Get the recovery settings of a protected VM. This requires SRM 5.8 or later.
.PARAMETER RecoveryPlan
The recovery plan the settings will be retrieved from.
.PARAMETER Vm
The virtual machine to configure recovery settings on.
.PARAMETER RecoverySettings
The recovery settings to configure. These should have been retrieved via a
call to Get-RecoverySettings
#>
Function Set-RecoverySetting {
[cmdletbinding(SupportsShouldProcess=$true, ConfirmImpact="Medium")]
Param(
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan] $RecoveryPlan,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine] $Vm,
[Parameter (ValueFromPipeline=$true)][VMware.Vim.VirtualMachine] $VmView,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroupProtectedVm] $ProtectedVm,
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings
)
$moRef = Get_MoRefFromVmObj -Vm $Vm -VmView $VmView -ProtectedVm $ProtectedVm
if ($RecoveryPlan -and $moRef -and $RecoverySettings) {
if ($PSCmdlet.ShouldProcess("$moRef", "Set")) {
$RecoveryPlan.SetRecoverySettings($moRef, $RecoverySettings)
}
}
}
<#
.SYNOPSIS
Create a new per-Vm command to add to the SRM Recovery Plan
.PARAMETER Command
The command script to execute.
.PARAMETER Description
The user friendly description of this script.
.PARAMETER Timeout
The number of seconds this command has to execute before it will be timedout.
.PARAMETER RunInRecoveredVm
For a post-power on command this flag determines whether it will run on the
recovered VM or on the SRM server.
#>
Function New-Command {
[cmdletbinding(SupportsShouldProcess=$true, ConfirmImpact="None")]
Param(
[Parameter (Mandatory=$true)][string] $Command,
[Parameter (Mandatory=$true)][string] $Description,
[int] $Timeout = 300,
[switch] $RunInRecoveredVm = $false
)
if($PSCmdlet.ShouldProcess("Description", "New")) {
$srmWsdlCmd = New-Object VMware.VimAutomation.Srm.WsdlTypes.SrmCommand
$srmCmd = New-Object VMware.VimAutomation.Srm.Views.SrmCommand -ArgumentList $srmWsdlCmd
$srmCmd.Command = $Command
$srmCmd.Description = $Description
$srmCmd.RunInRecoveredVm = $RunInRecoveredVm
$srmCmd.Timeout = $Timeout
$srmCmd.Uuid = [guid]::NewGuid()
return $srmCmd
}
}
<# Internal function #>
Function Add_Command {
[cmdletbinding()]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings,
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmCommand] $SrmCommand,
[Parameter (Mandatory=$true)][bool] $PostRecovery
)
if ($PostRecovery) {
$commands = $RecoverySettings.PostPowerOnCallouts
} else {
$commands = $RecoverySettings.PrePowerOnCallouts
}
if (-not $commands) {
$commands = New-Object System.Collections.Generic.List[VMware.VimAutomation.Srm.Views.SrmCallout]
}
$commands.Add($SrmCommand)
if ($PostRecovery) {
$RecoverySettings.PostPowerOnCallouts = $commands
} else {
$RecoverySettings.PrePowerOnCallouts = $commands
}
}
<#
.SYNOPSIS
Add an SRM command to the set of pre recovery callouts for a VM.
.PARAMETER RecoverySettings
The recovery settings to update. These should have been retrieved via a
call to Get-RecoverySettings
.PARAMETER SrmCommand
The command to add to the list.
#>
Function Add-PreRecoveryCommand {
[cmdletbinding()]
[OutputType([VMware.VimAutomation.Srm.Views.SrmRecoverySettings])]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings,
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmCommand] $SrmCommand
)
Add_Command -RecoverySettings $RecoverySettings -SrmCommand $SrmCommand -PostRecovery $false
return $RecoverySettings
}
<#
.SYNOPSIS
Remove an SRM command from the set of pre recovery callouts for a VM.
.PARAMETER RecoverySettings
The recovery settings to update. These should have been retrieved via a
call to Get-RecoverySettings
.PARAMETER SrmCommand
The command to remove from the list.
#>
Function Remove-PreRecoveryCommand {
[cmdletbinding(SupportsShouldProcess=$true, ConfirmImpact="Low")]
[OutputType([VMware.VimAutomation.Srm.Views.SrmRecoverySettings])]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings,
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmCommand] $SrmCommand
)
if ($pscmdlet.ShouldProcess($SrmCommand.Description, "Remove")) {
$RecoverySettings.PrePowerOnCallouts.Remove($SrmCommand)
}
return $RecoverySettings
}
<#
.SYNOPSIS
Add an SRM command to the set of post recovery callouts for a VM.
.PARAMETER RecoverySettings
The recovery settings to update. These should have been retrieved via a
call to Get-RecoverySettings
.PARAMETER SrmCommand
The command to add to the list.
#>
Function Add-PostRecoveryCommand {
[cmdletbinding()]
[OutputType([VMware.VimAutomation.Srm.Views.SrmRecoverySettings])]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings,
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmCommand] $SrmCommand
)
Add_Command -RecoverySettings $RecoverySettings -SrmCommand $SrmCommand -PostRecovery $true
return $RecoverySettings
}
<#
.SYNOPSIS
Remove an SRM command from the set of post recovery callouts for a VM.
.PARAMETER RecoverySettings
The recovery settings to update. These should have been retrieved via a
call to Get-RecoverySettings
.PARAMETER SrmCommand
The command to remove from the list.
#>
Function Remove-PostRecoveryCommand {
[cmdletbinding(SupportsShouldProcess=$true, ConfirmImpact="Low")]
[OutputType([VMware.VimAutomation.Srm.Views.SrmRecoverySettings])]
Param(
[Parameter (Mandatory=$true, ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmRecoverySettings] $RecoverySettings,
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmCommand] $SrmCommand
)
if ($pscmdlet.ShouldProcess($SrmCommand.Description, "Remove")) {
$RecoverySettings.PostPowerOnCallouts.Remove($SrmCommand)
}
return $RecoverySettings
}
<#
.SYNOPSIS
Create a new recovery plan
.PARAMETER Name
The name for this recovery plan
.PARAMETER Description
A description of the recovery plan
.PARAMETER Folder
The recovery plan folder in which to create this recovery plan. Will default to
the root recovery plan folder
.PARAMETER ProtectionGroups
The protection groups to associate with this recovery plan
.PARAMETER TestNetworkMappings
The test network mappings to configure as part of this recovery plan
.PARAMETER SrmServer
The SRM Server to operate against
#>
Function New-RecoveryPlan {
[cmdletbinding(SupportsShouldProcess=$true, ConfirmImpact="Medium")]
Param(
[Parameter (Mandatory=$true)][string] $Name,
[string] $Description,
[VMware.VimAutomation.Srm.Views.SrmRecoveryPlanFolder] $Folder,
[VMware.VimAutomation.Srm.Views.SrmProtectionGroup[]] $ProtectionGroups,
[VMware.VimAutomation.Srm.Views.SrmRecoveryTestNetworkMapping[]] $TestNetworkMappings,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
if (-not $Folder) {
$Folder = Get-RecoveryPlanFolder -SrmServer $SrmServer
}
$protectionGroupmRefs += @( $ProtectionGroups | ForEach-Object { $_.MoRef } | Select-Object -Unique)
[VMware.VimAutomation.Srm.Views.CreateRecoveryPlanTask] $task = $null
if ($PSCmdlet.ShouldProcess($Name, "New")) {
$task = $api.Recovery.CreateRecoveryPlan(
$Name,
$Folder.MoRef,
$protectionGroupmRefs,
$Description,
$TestNetworkMappings
)
}
while(-not $task.IsCreateRecoveryPlanComplete()) { Start-Sleep -Seconds 1 }
$task.GetNewRecoveryPlan()
}
<#
.SYNOPSIS
Remove a recovery plan permanently
.PARAMETER RecoveryPlan
The recovery plan to remove
.PARAMETER SrmServer
The SRM Server to operate against
#>
Function Remove-RecoveryPlan {
[cmdletbinding(SupportsShouldProcess=$True, ConfirmImpact="High")]
Param(
[Parameter (Mandatory=$true)][VMware.VimAutomation.Srm.Views.SrmRecoveryPlan] $RecoveryPlan,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
$rpinfo = $RecoveryPlan.GetInfo()
if ($pscmdlet.ShouldProcess($rpinfo.Name, "Remove")) {
$api.Recovery.DeleteRecoveryPlan($RecoveryPlan.MoRef)
}
}
<#
.SYNOPSIS
Get a recovery plan folder
.PARAMETER SrmServer
The SRM Server to query for the recovery plan folder
#>
Function Get-RecoveryPlanFolder {
[cmdletbinding()]
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
$folder = $api.Recovery.GetRecoveryPlanRootFolder()
return $folder
}

View File

@@ -0,0 +1,33 @@
<#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
<#
.SYNOPSIS
Trigger Discover Devices for Site Recovery Manager
.OUTPUTS
Returns discover devices task
#>
Function Start-DiscoverDevice {
[cmdletbinding(SupportsShouldProcess=$True, ConfirmImpact="Medium")]
[OutputType([VMware.VimAutomation.Srm.Views.DiscoverDevicesTask])]
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$api = Get-ServerApiEndpoint -SrmServer $SrmServer
$name = $SrmServer.Name
[VMware.VimAutomation.Srm.Views.DiscoverDevicesTask] $task = $null
if ($pscmdlet.ShouldProcess($name, "Rescan Storage Devices")) {
$task = $api.Storage.DiscoverDevices()
}
return $task
}

View File

@@ -0,0 +1,101 @@
<#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
#
# Module manifest for module 'Meadowcroft.Srm'
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'Meadowcroft.Srm.psm1'
# Version number of this module.
ModuleVersion = '0.2'
# ID used to uniquely identify this module
GUID = 'f9247009-9168-4a21-831b-819f82884ffe'
# Author of this module
Author = 'Ben Meadowcroft'
# Company or vendor of this module
CompanyName = 'VMware, Inc'
# Copyright statement for this module
Copyright = '(c) 2014 - 2017. All rights reserved.'
# Description of the functionality provided by this module
# Description = ''
# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @{ModuleName='VMware.VimAutomation.Srm'; ModuleVersion='6.5'}
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = 'Meadowcroft.Srm.Recovery.ps1','Meadowcroft.Srm.Protection.ps1','Meadowcroft.Srm.Storage.ps1'
# NestedModules = @()
# Functions to export from this module, note that internal functions use '_' not '-' as separator
FunctionsToExport = '*-*'
# Cmdlets to export from this module
CmdletsToExport = '*'
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module
AliasesToExport = '*'
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess
# PrivateData = ''
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
DefaultCommandPrefix = 'Srm'
}

View File

@@ -0,0 +1,156 @@
<#
Copyright 2017-2021 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
#>
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
# SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets
<#
.SYNOPSIS
This is intended to be an "internal" function only. It filters a
pipelined input of objects and elimiates duplicates as identified
by the MoRef property on the object.
.LINK
https://github.com/benmeadowcroft/SRM-Cmdlets/
#>
Function Select_UniqueByMoRef {
Param(
[Parameter (ValueFromPipeline=$true)] $in
)
process {
$moref = New-Object System.Collections.ArrayList
$in | Sort-Object | Select-Object MoRef -Unique | ForEach-Object { $moref.Add($_.MoRef) } > $null
$in | ForEach-Object {
if ($_.MoRef -in $moref) {
$moref.Remove($_.MoRef)
$_ #output
}
}
}
}
<#
.SYNOPSIS
This is intended to be an "internal" function only. It gets the
MoRef property of a VM from either a VM object, a VM view, or the
protected VM object.
#>
Function Get_MoRefFromVmObj {
Param(
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine] $Vm,
[Parameter (ValueFromPipeline=$true)][VMware.Vim.VirtualMachine] $VmView,
[Parameter (ValueFromPipeline=$true)][VMware.VimAutomation.Srm.Views.SrmProtectionGroupProtectedVm] $ProtectedVm
)
$moRef = $null
if ($Vm.ExtensionData.MoRef) { # VM object
$moRef = $Vm.ExtensionData.MoRef
} elseif ($VmView.MoRef) { # VM view
$moRef = $VmView.MoRef
} elseif ($protectedVm) {
$moRef = $ProtectedVm.Vm.MoRef
}
$moRef
}
<#
.SYNOPSIS
Lookup the srm instance for a specific server.
#>
Function Get-Server {
[cmdletbinding()]
Param(
[string] $SrmServerAddress,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$found = $null
if ($SrmServer) {
$found = $SrmServer
} elseif ($SrmServerAddress) {
# search for server address in default servers
$global:DefaultSrmServers | ForEach-Object {
if ($_.Name -ieq $SrmServerAddress) {
$found = $_
}
}
if (-not $found) {
throw "SRM server $SrmServerAddress not found. Connect-Server must be called first."
}
}
if (-not $found) {
#default result
$found = $global:DefaultSrmServers[0]
}
return $found;
}
<#
.SYNOPSIS
Retrieve the SRM Server Version
#>
Function Get-ServerVersion {
[cmdletbinding()]
Param(
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
$srm = Get-Server $SrmServer
$srm.Version
}
<#
.SYNOPSIS
Lookup the SRM API endpoint for a specific server.
#>
Function Get-ServerApiEndpoint {
[cmdletbinding()]
Param(
[string] $SrmServerAddress,
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer
)
[VMware.VimAutomation.Srm.Types.V1.SrmServer] $server = Get-Server -SrmServerAddress $SrmServerAddress -SrmServer $SrmServer
return $server.ExtensionData
}
<#
.SYNOPSIS
Get the placeholder VMs that are associated with SRM
#>
Function Get-PlaceholderVM {
[cmdletbinding()]
Param()
Get-VM @Args | Where-Object {$_.ExtensionData.Config.ManagedBy.extensionKey -like "com.vmware.vcDr*" -and $_.ExtensionData.Config.ManagedBy.Type -ieq 'placeholderVm'}
}
<#
.SYNOPSIS
Get the test VMs that are associated with SRM
#>
Function Get-TestVM {
[cmdletbinding()]
Param()
Get-VM @Args | Where-Object {$_.ExtensionData.Config.ManagedBy.extensionKey -like "com.vmware.vcDr*" -and $_.ExtensionData.Config.ManagedBy.Type -ieq 'testVm'}
}
<#
.SYNOPSIS
Get the VMs that are replicated using vSphere Replication. These may not be SRM
protected VMs.
#>
Function Get-ReplicatedVM {
[cmdletbinding()]
Param()
Get-VM @Args | Where-Object {($_.ExtensionData.Config.ExtraConfig | Where-Object { $_.Key -eq 'hbr_filter.destination' -and $_.Value } )}
}

10
Modules/SRM/NOTICE.txt Normal file
View File

@@ -0,0 +1,10 @@
Copyright (c) 2017-2021 VMware, Inc. All Rights Reserved.
This product is licensed to you under the Apache License version 2.0 (the "License"). You may not use this product except in compliance with the License.
This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
Copyright (c) 2021 VMware, Inc. All Rights Reserved.
This product is licensed to you under the BSD-2-Clause License. You may not use this product except in compliance with the License.

81
Modules/SRM/README.md Normal file
View File

@@ -0,0 +1,81 @@
# SRM PowerCLI Cmdlets
Helper functions for working with VMware SRM 6.5 with PowerCLI 6.5.1 or later. PowerShell 5.0 and above is required.
This module is provided for illustrative/educational purposes to explain how the PowerCLI access to the SRM public API can be used.
## Getting Started
### Getting the SRM cmdlets
The latest version of the software can be cloned from the git repository:
git clone https://github.com/benmeadowcroft/SRM-Cmdlets.git
Or downloaded as a [zip file](https://github.com/benmeadowcroft/SRM-Cmdlets/archive/master.zip).
Specific releases (compatible with earlier PowerCLI and SRM versions) can be downloaded via the [release page](https://github.com/benmeadowcroft/SRM-Cmdlets/releases).
### Deploy SRM-Cmdlets module
After cloning (or downloading and extracting) the PowerShell module, you can import the module into your current PowerShell session by by passing the path to `Meadowcroft.Srm.psd1` to the `Import-Module` cmdlet, e.g.:
Import-Module -Name .\SRM-Cmdlets\Meadowcroft.Srm.psd1
You can also install the module into the PowerShell path so it can be loaded implicitly. See [Microsoft's Installing Modules instructions](http://msdn.microsoft.com/en-us/library/dd878350) for more details on how to do this.
The module uses the default prefix of `Srm` for the custom functions it defines. This can be overridden when importing the module by setting the value of the `-Prefix` parameter when calling `Import-Module`.
### Connecting to SRM
After installing the module the next step is to connect to the SRM server. Details of how to do this are located in the [PowerCLI 6.5.1 User's Guide](http://pubs.vmware.com/vsphere-65/topic/com.vmware.powercli.ug.doc/GUID-A5F206CF-264D-4565-8CB9-4ED1C337053F.html)
$credential = Get-Credential
Connect-VIServer -Server vc-a.example.com -Credential $credential
Connect-SrmServer -Credential $credential -RemoteCredential $credential
At this point we've just been using the cmdlets provided by PowerCLI, the PowerCLI documentation also provides some examples of how to call the SRM API to perform various tasks. In the rest of this introduction we'll perform some of those tasks using the custom functions defined in this project.
### Report the Protected Virtual Machines and Their Protection Groups
Goal: Create a simple report listing the VMs protected by SRM and the protection group they belong to.
Get-SrmProtectionGroup | %{
$pg = $_
Get-SrmProtectedVM -ProtectionGroup $pg } | %{
$output = "" | select VmName, PgName
$output.VmName = $_.Vm.Name
$output.PgName = $pg.GetInfo().Name
$output
} | Format-Table @{Label="VM Name"; Expression={$_.VmName} },
@{Label="Protection group name"; Expression={$_.PgName}
}
### Report the Last Recovery Plan Test
Goal: Create a simple report listing the state of the last test of a recovery plan
Get-SrmRecoveryPlan | %{ $_ |
Get-SrmRecoveryPlanResult -RecoveryMode Test | select -First 1
} | Select Name, StartTime, RunMode, ResultState | Format-Table
### Execute a Recovery Plan Test
Goal: for a specific recovery plan, execute a test failover. Note the "local" SRM server we are connected to should be the recovery site in order for this to be successful.
Get-SrmRecoveryPlan -Name "Name of Plan" | Start-SrmRecoveryPlan -RecoveryMode Test
### Export the Detailed XML Report of the Last Recovery Plan Workflow
Goal: get the XML report of the last recovery plan execution for a specific recovery plan.
Get-SrmRecoveryPlan -Name "Name of Plan" | Get-SrmRecoveryPlanResult |
select -First 1 | Export-SrmRecoveryPlanResultAsXml
### Protect a Replicated VM
Goal: Take a VM replicated using vSphere Replication or Array Based Replication, add it to an appropriate protection group and configure it for protection
$pg = Get-SrmProtectionGroup "Name of Protection Group"
Get-VM vm-01a | Protect-SrmVM -ProtectionGroup $pg

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>SscConnection</Name>
<ViewSelectedBy>
<TypeName>SscConnection</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Width>30</Width>
<Label>Name</Label>
</TableColumnHeader>
<TableColumnHeader>
<Width>30</Width>
<Label>User</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Authenticated</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>User</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Authenticated</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>

View File

@@ -0,0 +1,129 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
#
# Module manifest for module 'SaltStackConfig'
#
# Generated by: Brian Wuchner
#
# Generated on: 11/28/2021
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'SaltStackConfig.psm1'
# Version number of this module.
ModuleVersion = '0.0.8'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = '9a36e984-2f63-450e-8c14-a6bccb18f87a'
# Author of this module
Author = 'Brian Wuchner'
# Company or vendor of this module
CompanyName = 'VMware'
# Copyright statement for this module
Copyright = '(c) VMware. All rights reserved.'
# Description of the functionality provided by this module
Description = 'Community sourced PowerShell wrapper module for the vRealize Automation SaltStack Config API.'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '4.0'
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = @('SaltStackConfig.Format.ps1xml')
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @('Connect-SscServer', 'Disconnect-SscServer', 'Get-SscActivity', 'Get-SscData', 'Get-SscJob', 'Get-SscMaster', 'Get-SscMinionCache', 'Get-SscReturn',
'Get-SscSchedule','Get-SscFile','Set-SscFile','New-SscFile','Remove-SscFile','Get-SscLicense','Get-SscvRALicense','Get-SscMinionKey','Set-SscMinionKey',
'Remove-SscMinionKey')
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

View File

@@ -0,0 +1,640 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Connect-SscServer {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
Use this function to create the cookie/header to connect to SaltStack Config RaaS API
.DESCRIPTION
This function will allow you to connect to a vRealize Automation SaltStack Config RaaS API.
A global variable will be set with the Servername & Cookie/Header value for use by other functions.
.EXAMPLE
PS C:\> Connect-SscServer -Server 'salt.example.com' -Username 'root' -Password 'VMware1!'
This will default to internal user authentication.
.EXAMPLE
PS C:\> Connect-SscServer -Server 'salt.example.com' -Username 'bwuchner' -Password 'MyPassword1!' -AuthSource 'LAB Directory'
This will use the 'Lab Directory' LDAP authentication source.
.EXAMPLE
PS C:\> Connect-SscServer -Server 'salt.example.com'
This will prompt for credentials
.EXAMPLE
$creds = Get-Credential
PS C:\> Connect-SscServer -Server 'salt.example.com' -Credential $creds -AuthSource 'LAB Directory'
This will connect to the 'LAB Directory' LDAP authentication source using a specified credential.
#>
param(
[Parameter(Mandatory=$true, Position=0)][string]$server,
[Parameter(Mandatory=$true, ParameterSetName='PlainText', Position=1)][string]$username,
[Parameter(Mandatory=$true, ParameterSetName='PlainText', Position=2)][ValidateNotNullOrEmpty()][string]$password,
[Parameter(Mandatory=$false, Position=3)][string]$AuthSource='internal',
[Parameter(Mandatory=$false, ParameterSetName='Credential')][PSCredential]$Credential,
[Parameter(Mandatory=$false)][Switch]$SkipCertificateCheck,
[Parameter(Mandatory=$false)][System.Net.SecurityProtocolType]$SslProtocol
)
if ($PSCmdlet.ParameterSetName -eq 'Credential' -AND $Credential -eq $null) { $Credential = Get-Credential}
if ($Credential) {
$username = $Credential.GetNetworkCredential().username
$password = $Credential.GetNetworkCredential().password
}
if ($SkipCertificateCheck) {
# This if statement is using example code from https://stackoverflow.com/questions/11696944/powershell-v3-invoke-webrequest-https-error
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
} # end if SkipCertificate Check
if ($SslProtocol) {
[System.Net.ServicePointManager]::SecurityProtocol = $SslProtocol
}
$loginBody = @{'username'=$username; 'password'=$password; 'config_name'=$AuthSource}
try {
$webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -SessionVariable ws
$ws.headers.Add('X-Xsrftoken', $webRequest.headers.'x-xsrftoken')
$webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -WebSession $ws -method POST -body (ConvertTo-Json $loginBody)
$webRequestJson = ConvertFrom-JSON $webRequest.Content
$global:DefaultSscConnection = New-Object psobject -property @{ 'SscWebSession'=$ws; 'Name'=$server; 'ConnectionDetail'=$webRequestJson;
'User'=$webRequestJson.attributes.config_name +'\'+ $username; 'Authenticated'=$webRequestJson.authenticated; PSTypeName='SscConnection' }
# Return the connection object
$global:DefaultSscConnection
} catch {
Write-Error ("Failure connecting to $server. " + $_)
} # end try/catch block
}
Function Disconnect-SscServer {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This function clears a previously created cookie/header used to connect to SaltStack Config
.DESCRIPTION
This function will clear the global variable used to connect to the vRealize Automation SaltStack Config RaaS API
.EXAMPLE
PS C:\> Disconnect-SscServer
#>
if ($global:DefaultSscConnection) {
$global:DefaultSscConnection = $null
} else {
Write-Error 'Could not find an existing connection.'
} # end if
}
Function Get-SscData {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
Use this function to call the SaltStack Config API.
Additional helper functions will call this function, this is where the majority of the logic will happen.
.DESCRIPTION
This function will pass resource/method/arguments to the vRealize Automation SaltStack Config RaaS API.
It depends on a global variable created by Connect-SscServer.
.EXAMPLE
PS C:\> Get-SscData -Resource 'minions' -Method 'get_minion_cache'
#>
param(
[Parameter(Mandatory=$true)][string]$resource,
[Parameter(Mandatory=$true)][string]$method,
[System.Collections.Hashtable]$kwarg
)
if (!$global:DefaultSscConnection) {
Write-Error 'You are not currently connected to any servers. Please connect first using Connect-SscServer.'
return;
} # end if
if (!$kwarg) {
$body = @{'resource'=$resource; 'method'=$method }
} else {
$body = @{'resource'=$resource; 'method'=$method; 'kwarg'=$kwarg }
}
try{
$jsonBody = $(ConvertTo-Json $body -Depth 4 -Compress )
write-debug "JSON Body: $jsonBody"
$output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.Name)/rpc" -body $jsonBody -ContentType 'application/json'
$outputJson = (ConvertFrom-Json $output.Content)
if ($outputJson.error) { Write-Error $outputJson.error }
if ($outputJson.warnings) { Write-Warning $outputJson.warnings }
return $outputJson.ret
} catch {
Write-Error $_.Exception.Message
}
}
# Lets include a couple sample/helper functions wrappers
Function Get-SscMaster {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return grain details about the SaltStack Config master node.
.DESCRIPTION
This wrapper function will call Get-SscData master.get_master_grains.
.EXAMPLE
PS C:\> Get-SscMaster
#>
(Get-SscData master get_master_grains).salt.grains
}
Function Get-SscMinionCache {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return the grain property cache of SaltStack Config minions.
.DESCRIPTION
This wrapper function will call Get-SscData minions.get_minion_cache.
.EXAMPLE
PS C:\> Get-SscMinion
#>
(Get-SscData minions get_minion_cache).results
}
Function Get-SscJob {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return configured SatlStack Config jobs.
.DESCRIPTION
This wrapper function will call Get-SscData job.get_jobs.
.EXAMPLE
PS C:\> Get-SscJob
#>
(Get-SscData job get_jobs).results
}
Function Get-SscSchedule {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return schedules for SaltStack Config.
.DESCRIPTION
This wrapper function will call Get-SscData schedule.get.
.EXAMPLE
PS C:\> Get-SscSchedule
#>
(Get-SscData schedule get).results
}
Function Get-SscReturn {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return job results from the job cache based on the provided arguments.
.DESCRIPTION
This wrapper function will call Get-SscData ret.get_returns with either Jid or MinionID.
.EXAMPLE
PS C:\> Get-SscReturn
.EXAMPLE
PS C:\> Get-SscReturn -Jid '20211122160147314949'
.EXAMPLE
PS C:\> Get-SscReturn -MinionID 't147-win22-01.lab.enterpriseadmins.org'
.EXAMPLE
PS C:\> Get-SscReturn -MinionID 't147-win22-01.lab.enterpriseadmins.org' -Jid '20211122160147314949'
#>
param(
[string]$jid,
[string]$MinionID
)
$kwarg = @{}
if ($jid) { $kwarg += @{'jid'=$jid} }
if ($MinionID) { $kwarg += @{'minion_id'=$MinionID} }
(Get-SscData ret get_returns $kwarg).results
}
Function Get-SscActivity {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: November 27, 2021
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return SaltStack Config commands that have been issued.
In the web interface this is similar to the Activity button.
.DESCRIPTION
This wrapper function will call Get-SscData cmd.get_cmds.
.EXAMPLE
PS C:\> Get-SscActivity
#>
(Get-SscData cmd get_cmds).results
}
Function Get-SscFile {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return file contents from the file server based on the provided arguments.
.DESCRIPTION
This wrapper function will call Get-SscData fs get_file and pass in specified saltenv and path parameters.
.EXAMPLE
PS C:\> Get-SscFile -saltenv 'sse' -path '/myfiles/file.sls'
.EXAMPLE
PS C:\> Get-SscFile -fileuuid '5e2483e8-a981-4e8c-9e83-01d1930413db'
#>
param(
[Parameter(Mandatory=$true, ParameterSetName='ByFileUUID', ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)][Alias('fileuuid')][string]$uuid,
[Parameter(Mandatory=$true, ParameterSetName='ByFilePath')][string]$saltenv,
[Parameter(Mandatory=$true, ParameterSetName='ByFilePath')][string]$path
)
$kwarg = @{}
if ($uuid) { $kwarg += @{'file_uuid'=$uuid } }
if ($saltenv) {
$kwarg += @{'saltenv'=$saltenv}
$kwarg += @{'path'=$path}
}
if ( Get-SscData fs file_exists $kwarg ) {
Get-SscData fs get_file $kwarg
} else {
if ($uuid) { Write-Error "File with UUID: $uuid not found." } else { Write-Error "File at path $saltenv $path not found." }
}
}
Function Set-SscFile {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will update file contents on the file server based on the provided arguments.
.DESCRIPTION
This wrapper function will call Get-SscData fs update_file and pass in specified fileuuid or saltenv and path parameters.
.EXAMPLE
PS C:\> Set-SscFile -saltenv 'sse' -path '/myfiles/file.sls' "#This is my content. `n#And so is this"
.EXAMPLE
PS C:\> Get-SscFile -saltenv 'sse' -path '/myfiles/file.sls' | Set-SscFile -contenttype 'text/x-yaml'
#>
[cmdletbinding(SupportsShouldProcess=$true,ConfirmImpact='High')]
param(
[Parameter(Mandatory=$true, ParameterSetName='ByFileUUID', ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)][Alias('fileuuid')][string]$uuid,
[Parameter(Mandatory=$true, ParameterSetName='ByFilePath')][string]$saltenv,
[Parameter(Mandatory=$true, ParameterSetName='ByFilePath')][string]$path,
[string]$content,
[ValidateSet('text/plain','text/x-python','application/json','text/x-yaml')][string]$contenttype
)
$kwarg = @{}
if ($uuid) { $kwarg += @{'file_uuid'=$uuid } }
if ($saltenv) {
$kwarg += @{'saltenv'=$saltenv}
$kwarg += @{'path'=$path}
}
# if the file exists, get its contents based on the correct parameterset. If it does not exist recommend the correct function.
if ( Get-SscData fs file_exists $kwarg ) {
if ( $PSCmdlet.ParameterSetName -eq 'ByFileUUID' ) {
$currentFile = Get-SscFile -fileuuid $uuid
} else {
$currentFile = Get-SscFile -saltenv $saltenv -path $path
}
} else {
Write-Error "Specified file does not exist, use New-SscFile instead."
return $null
}
if (!$content) { $content = $currentFile.contents }
$kwarg += @{'contents'=$content}
if (!$contenttype) { $contenttype = $currentfile.content_type }
$kwarg += @{'content_type'=$contenttype}
if ($PSCmdlet.ShouldProcess( "$($currentFile.saltenv)$($currentFile.path) ($($currentFile.uuid))" , 'update')) {
Get-SscData fs update_file $kwarg
}
}
Function New-SscFile {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will create a new file on the file server based on the provided arguments.
.DESCRIPTION
This wrapper function will call Get-SscData fs save_file and pass in specified saltenv and path parameters.
.EXAMPLE
PS C:\> New-SscFile -saltenv 'sse' -path '/myfiles/file.sls' -content '#this is my file content' -contenttype 'text/plain'
#>
param(
[Parameter(Mandatory=$true)][string]$saltenv,
[Parameter(Mandatory=$true)][string]$path,
[string]$content,
[ValidateSet('text/plain','text/x-python','application/json','text/x-yaml')][string]$contenttype
)
$kwarg = @{}
$kwarg += @{'saltenv'=$saltenv}
$kwarg += @{'path'=$path}
# if the file exists, get its contents based on the correct parameterset. If it does not exist recommend the correct function.
if ( Get-SscData fs file_exists $kwarg ) {
Write-Error "Specified file already exists, use Set-SscFile instead."
return $null
}
if ($content) { $kwarg += @{'contents'=$content} }
if ($contenttype) {
# if a contenttype is passed to the function we'll use it
$kwarg += @{'content_type'=$contenttype}
} else {
# and finally we'll default to text
$kwarg += @{'content_type' = 'text/plain' }
}
Get-SscData fs save_file $kwarg
}
Function Remove-SscFile {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will delete a specified file from the file server based on the provided arguments.
.DESCRIPTION
This wrapper function will call Get-SscData fs delete_file and pass in specified fileuuid or saltenv and path parameters.
.EXAMPLE
PS C:\> Remove-SscFile -saltenv 'sse' -path '/myfiles/file.sls'
.EXAMPLE
PS C:\> Get-SscFile -saltenv 'sse' -path '/myfiles/file.sls' | Remove-SscFile
#>
[cmdletbinding(SupportsShouldProcess=$true,ConfirmImpact='High')]
param(
[Parameter(Mandatory=$true, ParameterSetName='ByFileUUID', ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)][Alias('fileuuid')][string]$uuid,
[Parameter(Mandatory=$true, ParameterSetName='ByFilePath')][string]$saltenv,
[Parameter(Mandatory=$true, ParameterSetName='ByFilePath')][string]$path
)
$kwarg = @{}
if ($uuid) { $kwarg += @{'file_uuid'=$uuid } }
if ($saltenv) {
$kwarg += @{'saltenv'=$saltenv}
$kwarg += @{'path'=$path}
}
if ( Get-SscData fs file_exists $kwarg ) {
if ($PSCmdlet.ShouldProcess( $(if ($uuid) {$uuid} else {"$saltenv $path"}) , 'delete')) {
Get-SscData fs delete_file $kwarg
}
} else {
Write-Error "Specified file does not exist."
return $null
}
}
Function Get-SscLicense {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return license information for SaltStack Config.
.DESCRIPTION
This wrapper function will call Get-SscData license.get_current_license and return the desc property.
.EXAMPLE
PS C:\> Get-SscLicense
#>
(Get-SscData license get_current_license).desc
}
Function Get-SscvRALicense {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return vRealize Automation license information for SaltStack Config.
.DESCRIPTION
This wrapper function will call Get-SscData license.get_vra_license and return the serial and edition property.
.EXAMPLE
PS C:\> Get-SscvRALicense
#>
Get-SscData license get_vra_license
}
Function Get-SscMinionKey {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will return minion key state information for SaltStack Config.
.DESCRIPTION
This wrapper function will call Get-SscData minions.get_minion_key_state and return the minions key states.
Optionally a key state can be provided and the results will be filtered to only return the requested state.
.EXAMPLE
PS C:\> Get-SscMinionKeyState
.EXAMPLE
PS C:\> Get-SscMinionKeyState -key_state pending
#>
param(
[ValidateSet('accepted','rejected','pending','denied')][string]$state
)
$kwarg = @{}
if ($state) { $kwarg.add('key_state',$state) }
(Get-SscData minions get_minion_key_state $kwarg).results
}
Function Set-SscMinionKey {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will set minion key state information for SaltStack Config.
.DESCRIPTION
This wrapper function will call Get-SscData minions.set_minion_key_state and update the states for specific minions.
.EXAMPLE
PS C:\> Get-SscMinionKeyState |?{$_.name -eq 'server2022a'} | Set-SscMinionKeyState -state accept
.EXAMPLE
PS C:\> Set-SscMinionKeyState -master 'salt' -minion 'server2022a' -state reject -confirm:$false
#>
[cmdletbinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)][string]$master,
[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)][string]$minion,
[Parameter(Mandatory, ParameterSetName='accept')][switch]$accept,
[Parameter(Mandatory, ParameterSetName='reject')][switch]$reject
)
begin {
$collection = @()
}
process {
if ($PSCmdlet.ParameterSetName -eq 'accept') { $state = 'accept'}
if ($PSCmdlet.ParameterSetName -eq 'reject') { $state = 'reject'}
if ($PSCmdlet.ShouldProcess("$master : $minion" , $state)) {
$collection += ,@($master, $minion)
}
}
end {
$kwarg = @{}
$kwarg.Add('state', $state)
if ($state -eq 'reject') {$kwarg.Add('include_accepted', $true)}
if ($state -eq 'accept') {$kwarg.Add('include_rejected', $true)}
if ($state -eq 'accept' -OR $state -eq 'reject') {$kwarg.Add('include_denied',$true)}
$kwarg.Add('minions', @( $collection ) )
(Get-SscData minions set_minion_key_state $kwarg).task_ids
}
}
Function Remove-SscMinionKey {
<#
.NOTES
===========================================================================
Created by: Brian Wuchner
Date: February 12, 2022
Blog: www.enterpriseadmins.org
Twitter: @bwuch
===========================================================================
.SYNOPSIS
This wrapper function will delete a minion key for SaltStack Config.
.DESCRIPTION
This wrapper function will call Get-SscData minions.set_minion_key_state and remove the specified minion keys.
.EXAMPLE
PS C:\> Get-SscMinionKeyState |?{$_.name -eq 'server2022a'} | Remove-SscMinionKeyState
.EXAMPLE
PS C:\> Remove-SscMinionKeyState -master 'salt' -minion 'server2022a' -confirm:$false
#>
[cmdletbinding(SupportsShouldProcess=$true,ConfirmImpact='High')]
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)][string]$master,
[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)][string]$minion
)
begin {
$collection = @()
}
process {
if ($PSCmdlet.ShouldProcess("$master : $minion" , 'delete')) {
$collection += ,@($master, $minion)
}
}
end {
$kwarg = @{}
$kwarg.Add('state','delete')
$kwarg.Add('minions', @( $collection ) )
(Get-SscData minions set_minion_key_state $kwarg).task_ids
}
}

View File

@@ -1,15 +1,15 @@
function Set-CBT {
<#
<#
.NOTES
===========================================================================
Created by: Markus Kraus
Twitter: @VMarkus_K
Private Blog: mycloudrevolution.com
===========================================================================
Changelog:
2016.11 ver 1.0 Base Release
Changelog:
2016.11 ver 1.0 Base Release
===========================================================================
External Code Sources:
External Code Sources:
http://wahlnetwork.com/2015/12/01/change-block-tracking-cbt-powercli/
===========================================================================
Tested Against Environment:
@@ -22,13 +22,13 @@ function Set-CBT {
===========================================================================
.DESCRIPTION
This Function enables or disables CBT.
This Function enables or disables CBT.
.Example
Get-VN TST* | Set-CBT -DisableCBT
Get-VN TST* | Set-CBT -DisableCBT
.Example
Get-VN TST* | Set-CBT -EnableCBT
Get-VN TST* | Set-CBT -EnableCBT
.PARAMETER DisableCBT
Disables CBT for any VMs found with it enabled
@@ -41,7 +41,7 @@ function Set-CBT {
#>
[CmdletBinding()]
param(
param(
[Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage = "VMs to process")]
[ValidateNotNullorEmpty()]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $myVMs,
@@ -52,7 +52,7 @@ function Set-CBT {
[ValidateNotNullorEmpty()]
[Switch]$DisableCBT
)
Process {
Process {
$vmconfigspec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec
Write-Verbose -Message "Walking through given VMs"
@@ -60,7 +60,7 @@ Process {
{
if ($DisableCBT -and $myVM.ExtensionData.Config.ChangeTrackingEnabled -eq $true -and $myVM.ExtensionData.Snapshot -eq $null)
{
try
try
{
Write-Verbose -Message "Reconfiguring $($myVM.name) to disable CBT" -Verbose
$vmconfigspec.ChangeTrackingEnabled = $false
@@ -75,7 +75,7 @@ Process {
}
}
catch
catch
{
throw $myVM
}
@@ -94,13 +94,13 @@ Process {
$SnapShot | Remove-Snapshot -Confirm:$false
}
}
else
else
{
if ($myVM.ExtensionData.Snapshot -ne $null -and $EnableCBT)
if ($myVM.ExtensionData.Snapshot -ne $null -and $EnableCBT)
{
Write-Warning -Message "Skipping $($myVM.name) - Snapshots found"
}
elseif ($myVM.ExtensionData.Snapshot -ne $null -and $DisableCBT)
elseif ($myVM.ExtensionData.Snapshot -ne $null -and $DisableCBT)
{
Write-Warning -Message "Skipping $($myVM.name) - Snapshots found"
}

View File

@@ -1,40 +1,44 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Start-UNMAP {
<#
.SYNOPSIS
Process SCSI UNMAP on VMware Datastores
.DESCRIPTION
This Function will process SCSI UNMAP on VMware Datastores via ESXCLI -V2
.Example
Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5*
Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5*
.Example
Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5* -Verbose -WhatIf
.Notes
NAME: Start-UNMAP.psm1
AUTHOR: Markus Kraus
AUTHOR: Markus Kraus
LASTEDIT: 23.09.2016
VERSION: 1.0
KEYWORDS: VMware, vSphere, ESXi, SCSI, VAAI, UNMAP
.Link
http://mycloudrevolution.com/
#Requires PS -Version 4.0
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"}
#>
[CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact='High')]
param(
param(
[Parameter(Mandatory=$true, Position=0)]
[String]$ClusterName,
[Parameter(Mandatory=$true, Position=1)]
[String]$DSWildcard
)
Process {
$Validate = $true
$Validate = $true
#region: PowerCLI Session Timeout
Write-Verbose "Set Session Timeout ..."
$initialTimeout = (Get-PowerCLIConfiguration -Scope Session).WebOperationTimeoutSeconds
@@ -90,10 +94,10 @@ function Start-UNMAP {
}
#endregion
#region: Revert PowerCLI Session Timeout
#region: Revert PowerCLI Session Timeout
Write-Verbose "Revert Session Timeout ..."
Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds $initialTimeout -Confirm:$False | Out-Null
#endregion
}
}

View File

@@ -1,4 +1,9 @@
Function Get-VAMISummary {
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-VAMISummary {
<#
.NOTES
===========================================================================
@@ -17,7 +22,7 @@
Get-VAMISummary
#>
$systemVersionAPI = Get-CisService -Name 'com.vmware.appliance.system.version'
$results = $systemVersionAPI.get() | select product, type, version, build, install_time
$results = $systemVersionAPI.get() | select product, type, version, build, install_time, releasedate
$systemUptimeAPI = Get-CisService -Name 'com.vmware.appliance.system.uptime'
$ts = [timespan]::fromseconds($systemUptimeAPI.get().toString())
@@ -29,6 +34,7 @@
Version = $results.version;
Build = $results.build;
InstallTime = $results.install_time;
ReleaseDate = $results.releasedate;
Uptime = $uptime
}
$summaryResult
@@ -109,6 +115,7 @@ Function Get-VAMIAccess {
Console = $consoleAccess;
DCUI = $dcuiAccess;
BashShell = $shellAccess.enabled;
BashTimeout = $shellAccess.timeout;
SSH = $sshAccess
}
$accessResult
@@ -122,7 +129,10 @@ Function Get-VAMITime {
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 16, 2020
===========================================================================
.SYNOPSIS
This function retrieves the time and NTP info from VAMI interface (5480)
for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
@@ -131,12 +141,16 @@ Function Get-VAMITime {
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
Get-VAMITime
.NOTES
Modified script to account for Newer VCSA. Script supports 6.5 and 6.7 VCSAs
#>
$systemTimeAPI = Get-CisService -Name 'com.vmware.appliance.system.time'
$systemTimeAPI = ( Get-VAMIServiceAPI -NameFilter "system.time")
$timeResults = $systemTimeAPI.get()
$timeSync = (Get-CisService -Name 'com.vmware.appliance.techpreview.timesync').get()
$timeSyncMode = $timeSync.mode
$timeSyncMode = ( Get-VAMIServiceAPI -NameFilter "timesync").get()
if ($timeSyncMode.mode) {
$timeSyncMode = $timeSync.mode
}
$timeResult = [pscustomobject] @{
Timezone = $timeResults.timezone;
@@ -148,13 +162,84 @@ Function Get-VAMITime {
}
if($timeSyncMode -eq "NTP") {
$ntpServers = (Get-CisService -Name 'com.vmware.appliance.techpreview.ntp').get()
$timeResult.NTPServers = $ntpServers.servers
$timeResult.NTPStatus = $ntpServers.status
$ntpServers = ( Get-VAMIServiceAPI -NameFilter "ntp").get()
if ($ntpServers.servers) {
$timeResult.NTPServers = $ntpServers.servers
$timeResult.NTPStatus = $ntpServers.status
} else {
$timeResult.NTPServers = $ntpServers
$timeResult.NTPStatus = ( Get-VAMIServiceAPI -NameFilter "ntp").test(( Get-VAMIServiceAPI -NameFilter "ntp").get()).status
}
}
$timeResult
}
Function Set-VAMITimeSync {
<#
.NOTES
===========================================================================
Inspired by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function sets the time and NTP info from VAMI interface (5480)
for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
.DESCRIPTION
Function to return current Time and NTP information
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
Set-VAMITimeSync -SyncMode "NTP" -TimeZone "US/Pacific" -NTPServers "10.0.0.10,10.0.0.11,10.0.0.12"
.NOTES
Create script to Set NTP for Newer VCSA. Script supports 6.7 VCSAs
#>
param(
[Parameter(Mandatory=$true)]
[ValidateSet('Disabled', 'NTP', 'Host')]
[String]$SyncMode,
[Parameter(Mandatory=$False,HelpMessage="TimeZone Name needs to be in Posix Naming / Unix format")]
[String]$TimeZone,
[Parameter(Mandatory=$false,HelpMessage="NTP Servers need to be either a string separated by ',' or an array of servers")]
$NTPServers
)
$timeSyncMode = ( Get-VAMIServiceAPI -NameFilter "timesync").get()
if ($timeSyncMode.gettype().name -eq "PSCustomObject") {
if ($SyncMode.ToUpper() -ne $timeSyncMode.mode.toupper()) {
$timesyncapi = (Get-VAMIServiceAPI -NameFilter "timesync")
$timesyncconfig = $timesyncapi.help.set.config.createexample()
$timesyncconfig = $Sync
$timesyncapi.set($timesyncconfig)
}
} else {
if ($SyncMode.ToUpper() -ne $timeSyncMode.toupper()) {
$timesyncapi = (Get-VAMIServiceAPI -NameFilter "timesync")
$timesyncapi.set($Sync)
}
if ($NTPServers) {
$ntpapi = (Get-VAMIServiceAPI -NameFilter "ntp")
if ($NTPServers.gettype().Name -eq "String") {
$NTPServersArray = ($NTPServers -split ",").trim()
} else {
$NTPServersArray = $NTPServers
}
if ($NTPServersArray -ne $ntpapi.get()) {
$ntpapi.set($NTPServersArray)
}
}
if ($TimeZone) {
$timezoneapi = (Get-VAMIServiceAPI -NameFilter "timezone")
if ($TimeZone -ne ($timezoneapi.get())) {
$timezoneapi.set($TimeZone)
}
}
}
}
Function Get-VAMINetwork {
<#
.NOTES
@@ -163,6 +248,9 @@ Function Get-VAMINetwork {
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Modifed by: Michael Dunsdon, Mathieu Allegret
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function retrieves network information from VAMI interface (5480)
@@ -172,31 +260,35 @@ Function Get-VAMINetwork {
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
Get-VAMINetwork
.NOTES
Modified script to account for Newer VCSA. Script supports 6.5 and 6.7 VCSAs
#>
$netResults = @()
$Hostname = (Get-CisService -Name 'com.vmware.appliance.networking.dns.hostname').get()
$dns = (Get-CisService -Name 'com.vmware.appliance.networking.dns.servers').get()
$Hostname = (Get-VAMIServiceAPI -NameFilter "dns.hostname").get()
$dns = (Get-VAMIServiceAPI -NameFilter "dns.servers").get()
Write-Host "Hostname: " $hostname
Write-Host "DNS Servers: " $dns.servers
$interfaces = (Get-CisService -Name 'com.vmware.appliance.networking.interfaces').list()
$interfaces = (Get-VAMIServiceAPI -NameFilter "interfaces").list()
foreach ($interface in $interfaces) {
$ipv4API = (Get-CisService -Name 'com.vmware.appliance.techpreview.networking.ipv4')
$spec = $ipv4API.Help.get.interfaces.CreateExample()
$spec+= $interface.name
$ipv4result = $ipv4API.get($spec)
$ipv4API = (Get-VAMIServiceAPI -NameFilter "ipv4")
if ($ipv4API.help.get.psobject.properties.name -like "*_*") {
$ipv4result = $ipv4API.get($interface.Name)
$Updateable = $ipv4result.configurable
} else {
$ipv4result = $ipv4API.get(@($interface.Name))
$Updateable = $ipv4result.updateable
}
$interfaceResult = [pscustomobject] @{
Inteface = $interface.name;
MAC = $interface.mac;
Status = $interface.status;
Mode = $ipv4result.mode;
IP = $ipv4result.address;
Prefix = $ipv4result.prefix;
Gateway = $ipv4result.default_gateway;
Updateable = $ipv4result.updateable
Hostname = $Hostname
Inteface = $interface.name
MAC = $interface.mac
Status = $interface.status
Mode = $ipv4result.mode
IP = $ipv4result.address
Prefix = $ipv4result.prefix
Gateway = $ipv4result.default_gateway
DNSServers = $dns.servers
Updateable = $Updateable
}
$netResults += $interfaceResult
}
@@ -224,8 +316,8 @@ Function Get-VAMIDisks {
$storageAPI = Get-CisService -Name 'com.vmware.appliance.system.storage'
$disks = $storageAPI.list()
foreach ($disk in $disks | sort {[int]$_.disk.toString()}) {
$disk | Select Disk, Partition
foreach ($disk in $disks | Sort-Object {[int]$_.disk.toString()}) {
$disk | Select-Object Disk, Partition
}
}
@@ -286,6 +378,9 @@ Function Get-VAMIStorageUsed {
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 16, 2020
===========================================================================
.SYNOPSIS
This function retrieves the individaul OS partition storage utilization
@@ -295,70 +390,49 @@ Function Get-VAMIStorageUsed {
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
Get-VAMIStorageUsed
.NOTES
Modified script to account for Newer VCSA. Script supports 6.5 and 6.7 VCSAs.
Also modifed the static list of filesystems to be more dynamic in nature to account for the differences in VCSA versions.
#>
$monitoringAPI = Get-CisService 'com.vmware.appliance.monitoring'
$querySpec = $monitoringAPI.help.query.item.CreateExample()
# List of IDs from Get-VAMIStatsList to query
$querySpec.Names = @(
"storage.used.filesystem.autodeploy",
"storage.used.filesystem.boot",
"storage.used.filesystem.coredump",
"storage.used.filesystem.imagebuilder",
"storage.used.filesystem.invsvc",
"storage.used.filesystem.log",
"storage.used.filesystem.netdump",
"storage.used.filesystem.root",
"storage.used.filesystem.updatemgr",
"storage.used.filesystem.vcdb_core_inventory",
"storage.used.filesystem.vcdb_seat",
"storage.used.filesystem.vcdb_transaction_log",
"storage.totalsize.filesystem.autodeploy",
"storage.totalsize.filesystem.boot",
"storage.totalsize.filesystem.coredump",
"storage.totalsize.filesystem.imagebuilder",
"storage.totalsize.filesystem.invsvc",
"storage.totalsize.filesystem.log",
"storage.totalsize.filesystem.netdump",
"storage.totalsize.filesystem.root",
"storage.totalsize.filesystem.updatemgr",
"storage.totalsize.filesystem.vcdb_core_inventory",
"storage.totalsize.filesystem.vcdb_seat",
"storage.totalsize.filesystem.vcdb_transaction_log"
)
$querySpec.Names = ($monitoringAPI.list() | Where-Object {($_.name -like "*storage.used.filesystem*") -or ($_.name -like "*storage.totalsize.filesystem*") } | Select-Object id | Sort-Object -Property id).id.value
# Tuple (Filesystem Name, Used, Total) to store results
$storageStats = @{
"archive"=@{"name"="/storage/archive";"used"=0;"total"=0};
"autodeploy"=@{"name"="/storage/autodeploy";"used"=0;"total"=0};
"boot"=@{"name"="/boot";"used"=0;"total"=0};
"coredump"=@{"name"="/storage/core";"used"=0;"total"=0};
"core"=@{"name"="/storage/core";"used"=0;"total"=0};
"imagebuilder"=@{"name"="/storage/imagebuilder";"used"=0;"total"=0};
"invsvc"=@{"name"="/storage/invsvc";"used"=0;"total"=0};
"log"=@{"name"="/storage/log";"used"=0;"total"=0};
"netdump"=@{"name"="/storage/netdump";"used"=0;"total"=0};
"root"=@{"name"="/";"used"=0;"total"=0};
"updatemgr"=@{"name"="/storage/updatemgr";"used"=0;"total"=0};
"vcdb_core_inventory"=@{"name"="/storage/db";"used"=0;"total"=0};
"vcdb_seat"=@{"name"="/storage/seat";"used"=0;"total"=0};
"vcdb_transaction_log"=@{"name"="/storage/dblog";"used"=0;"total"=0}
"db"=@{"name"="/storage/db";"used"=0;"total"=0};
"seat"=@{"name"="/storage/seat";"used"=0;"total"=0};
"dblog"=@{"name"="/storage/dblog";"used"=0;"total"=0};
"swap"=@{"name"="swap";"used"=0;"total"=0}
}
$querySpec.interval = "DAY1"
$querySpec.function = "MAX"
$querySpec.start_time = ((get-date).AddDays(-1))
$querySpec.start_time = ((Get-Date).AddDays(-1))
$querySpec.end_time = (Get-Date)
$queryResults = $monitoringAPI.query($querySpec) | Select * -ExcludeProperty Help
$queryResults = $monitoringAPI.query($querySpec) | Select-Object * -ExcludeProperty Help
foreach ($queryResult in $queryResults) {
# Update hash if its used storage results
$key = ((($queryResult.name).toString()).split(".")[-1]) -replace "coredump","core" -replace "vcdb_","" -replace "core_inventory","db" -replace "transaction_log","dblog"
$value = [Math]::Round([int]($queryResult.data[1]).toString()/1MB,2)
if($queryResult.name -match "used") {
$key = (($queryResult.name).toString()).split(".")[-1]
$value = [Math]::Round([int]($queryResult.data[1]).toString()/1MB,2)
$storageStats[$key]["used"] = $value
# Update hash if its total storage results
} else {
$key = (($queryResult.name).toString()).split(".")[-1]
$value = [Math]::Round([int]($queryResult.data[1]).toString()/1MB,2)
$storageStats[$key]["total"] = $value
}
}
@@ -406,7 +480,6 @@ Function Get-VAMIService {
if($Name -ne "") {
$vMonAPI = Get-CisService 'com.vmware.appliance.vmon.service'
try {
$serviceStatus = $vMonAPI.get($name,0)
$serviceString = [pscustomobject] @{
@@ -423,7 +496,6 @@ Function Get-VAMIService {
} else {
$vMonAPI = Get-CisService 'com.vmware.appliance.vmon.service'
$services = $vMonAPI.list_details()
$serviceResult = @()
foreach ($key in $services.keys | Sort-Object -Property Value) {
$serviceString = [pscustomobject] @{
@@ -448,7 +520,7 @@ Function Start-VAMIService {
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
===========================================================================
.SYNOPSIS
This function retrieves list of services in VAMI interface (5480)
for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
@@ -470,8 +542,8 @@ Function Start-VAMIService {
$vMonAPI = Get-CisService 'com.vmware.appliance.vmon.service'
try {
Write-Host "Starting $name service ..."
$vMonAPI.start($name)
Write-Host "Starting $Name service ..."
$vMonAPI.start($Name)
} catch {
Write-Error $Error[0].exception.Message
}
@@ -507,8 +579,8 @@ Function Stop-VAMIService {
$vMonAPI = Get-CisService 'com.vmware.appliance.vmon.service'
try {
Write-Host "Stopping $name service ..."
$vMonAPI.stop($name)
Write-Host "Stopping $Name service ..."
$vMonAPI.stop($Name)
} catch {
Write-Error $Error[0].exception.Message
}
@@ -556,15 +628,20 @@ Function Get-VAMIUser {
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.SYNOPSIS
This function retrieves VAMI local users using VAMI interface (5480)
Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 16, 2020
===========================================================================
.SYNOPSIS
This function retrieves VAMI local users using VAMI interface (5480)
for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
.DESCRIPTION
Function to retrieve VAMI local users
.EXAMPLE
.DESCRIPTION
Function to retrieve VAMI local users
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
Get-VAMIUser
.NOTES
Modified script to account for Newer VCSA. Script supports 6.5 and 6.7 VCSAs.
#>
param(
[Parameter(
@@ -575,42 +652,57 @@ Function Get-VAMIUser {
[String]$Name
)
$userAPI = Get-CisService 'com.vmware.appliance.techpreview.localaccounts.user'
$userAPI = Get-VAMIServiceAPI -NameFilter "accounts"
$UserResults = @()
$userResults = @()
# Get a list of users
try {
$Users = $UserAPI.list()
} catch {
write-error $_
}
if($Name -ne "") {
try {
$user = $userAPI.get($name)
# Apply filtering if Name input is provided
if ($Name -ne '' -AND $Name -ne $null) {
# For 6.5 API, the username is part of the list returnset; for 6.7/7.x API the value from the list is the username. Because of this we will use an OR filter to account for either case.
$Users = $Users | Where-Object {$_.username -eq $name -OR $_.value -eq $name}
}
$userString = [pscustomobject] @{
User = $user.username
Name = $user.fullname
Email = $user.email
Status = $user.status
PasswordStatus = $user.passwordstatus
Role = $user.role
if ($Users.status) {
# This is for 6.5 API, which has a status property; in newer API response there is an enabled property with values of True/False
foreach ($User in $Users) {
$UserString = [pscustomobject] @{
User = $User.username
Name = $User.fullname
Email = $User.email
Enabled = if ($User.status -eq 'enabled' ) { $true } else { $false }
Status = $User.status
LastPasswordChange = $null
PasswordExpiresAt = $null
PasswordStatus = $User.passwordstatus
Roles = @($User.role)
}
$userResults += $userString
} catch {
Write-Error $Error[0].exception.Message
$UserResults += $UserString
}
} else {
$users = $userAPI.list()
foreach ($user in $users) {
$userString = [pscustomobject] @{
User = $user.username
Name = $user.fullname
Email = $user.email
Status = $user.status
PasswordStatus = $user.passwordstatus
Role = $user.role
# This is for 6.7/7.0+ API response
foreach ($User in $Users) {
$UserInfo = $userAPI.get($User.Value)
$UserString = [pscustomobject] @{
User = $User.value
Name = $UserInfo.fullname
Email = $UserInfo.email
Enabled = $UserInfo.enabled
Status = if ($userInfo.enabled ) { 'enabled' } else { 'disabled' }
LastPasswordChange = $UserInfo.last_password_change
PasswordExpiresAt = $UserInfo.password_expires_at
PasswordStatus = if ($UserInfo.has_password) { if ((!!$UserInfo.password_expires_at) -and ( (Get-Date) -lt [datetime]$UserInfo.password_expires_at)) {'valid'} else {'expired'}} else { 'notset'}
Roles = $UserInfo.roles
}
$userResults += $userString
$UserResults += $UserString
}
}
$userResults
$UserResults
}
Function New-VAMIUser {
@@ -621,53 +713,148 @@ Function New-VAMIUser {
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.SYNOPSIS
This function to create new VAMI local user using VAMI interface (5480)
Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 16, 2020
===========================================================================
.SYNOPSIS
This function to create new VAMI local user using VAMI interface (5480)
for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
.DESCRIPTION
Function to create a new VAMI local user
.EXAMPLE
.DESCRIPTION
Function to create a new VAMI local user
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
New-VAMIUser -name lamw -fullname "William Lam" -role "operator" -email "lamw@virtuallyghetto.com" -password "VMware1!"
New-VAMIUser -name lamw -fullname "William Lam" -role "operator" -email "lamw@virtuallyghetto.com" -password "VMware1!" -passwordexpires -passwordexpiresat "1/1/1970" -maxpasswordage 90
.NOTES
Modified script to account for Newer VCSA. Script supports 6.5 and 6.7 VCSAs.
Also added new Parameters to script.
#>
param(
[Parameter(
Mandatory=$true)
]
[String]$name,
[Parameter(
Mandatory=$true)
]
[String]$fullname,
[Parameter(
Mandatory=$true)
]
[ValidateSet("admin","operator","superAdmin")][String]$role,
[Parameter(
Mandatory=$false)
]
[String]$email="",
[Parameter(
Mandatory=$true)
]
[String]$password
[Parameter(Mandatory=$true)]
[String]$Name,
[Parameter(Mandatory=$true)]
[String]$FullName,
[Parameter(Mandatory=$true)]
[ValidateSet("admin","operator","superAdmin")]
[String]$Role,
[Parameter(Mandatory=$false)]
[String]$Email="",
[Parameter(Mandatory=$true)]
[String]$Password,
[Parameter(Mandatory=$false)]
[switch]$PasswordExpires,
[Parameter(Mandatory=$false)]
[String]$PasswordExpiresAt = $null,
[Parameter(Mandatory=$false)]
[String]$MaxPasswordAge = 90
)
$userAPI = Get-CisService 'com.vmware.appliance.techpreview.localaccounts.user'
$createSpec = $userAPI.Help.add.config.CreateExample()
$userAPI = Get-VAMIServiceAPI -NameFilter "accounts"
if ($userAPI.name -eq 'com.vmware.appliance.techpreview.localaccounts.user') {
$CreateSpec = $UserAPI.Help.add.config.Create()
} else {
$CreateSpec = $UserAPI.Help.create.config.Create()
}
$createSpec.username = $name
$createSpec.fullname = $fullname
$createSpec.role = $role
$createSpec.email = $email
$createSpec.password = [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$password
$CreateSpec.email = $Email
$CreateSpec.password = [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$Password
try {
Write-Host "Creating new user $name ..."
$userAPI.add($createSpec)
} catch {
Write-Error $Error[0].exception.Message
if ($CreateSpec.psobject.properties.name -contains "username") {
# This is for 6.5 API
$CreateSpec.username = $Name
$CreateSpec.fullname = $FullName
$CreateSpec.role = $Role
try {
Write-Host "Creating new user $Name ..."
$UserAPI.add($CreateSpec)
} catch {
Write-Error $Error[0].exception.Message
}
} else {
# This is for 6.7/7.0+ API
$CreateSpec.full_name = $FullName
$CreateSpec.roles = @($Role)
$CreateSpec.password_expires = [string]$PasswordExpires
$CreateSpec.password_expires_at = $PasswordExpiresAt
$CreateSpec.max_days_between_password_change = $MaxPasswordAge
try {
Write-Host "Creating new user $Name ..."
$UserAPI.create($Name, $CreateSpec)
} catch {
Write-Error $_
}
}
}
Function Update-VAMIUser {
<#
.NOTES
===========================================================================
Inspired by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function to update fields of a VAMI local user using VAMI interface (5480)
for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
.DESCRIPTION
Function to update fields of a VAMI local user
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
Update-VAMIUser -name lamw -fullname "William Lam" -role "operator" -email "lamw@virtuallyghetto.com" -password "VMware1!" -passwordexpires -passwordexpiresat "1/1/1970" -maxpasswordage 90
.NOTES
Created script to allow updating of an exisiting user account. Script supports 6.5 and 6.7 VCSAs.
#>
param(
[Parameter(Mandatory=$true)]
[String]$Name,
[Parameter(Mandatory=$false)]
[String]$FullName,
[Parameter(Mandatory=$false)]
[ValidateSet("admin","operator","superAdmin")]
[String]$Role,
[Parameter(Mandatory=$false)]
[String]$Email="",
[Parameter(Mandatory=$false)]
[String]$Password = $null,
[Parameter(Mandatory=$false)]
[switch]$PasswordExpires,
[Parameter(Mandatory=$false)]
[String]$PasswordExpiresAt = $null,
[Parameter(Mandatory=$false)]
[String]$MaxPasswordAge = 90
)
$userAPI = Get-VAMIServiceAPI -NameFilter "accounts"
$UpdateSpec = $UserAPI.Help.set.config.CreateExample()
$UpdateSpec.fullname = $FullName
$UpdateSpec.role = $Role
$UpdateSpec.email = $Email
if ($UpdateSpec.psobject.properties.name -contains "username") {
$UpdateSpec.username = $Name
try {
Write-Host "Updating Settings for user $Name ..."
$UserAPI.set($UpdateSpec)
} catch {
Write-Error $Error[0].exception.Message
}
} else {
$UpdateSpec.password = [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$Password
$UpdateSpec.password_expires = $PasswordExpires
$UpdateSpec.password_expires_at = $PasswordExpiresAt
$UpdateSpec.max_days_between_password_change = $MaxPasswordAge
try {
Write-Host "Updating Settings for user $Name ..."
$UserAPI.update($Name, $UpdateSpec)
} catch {
Write-Error $Error[0].exception.Message
}
}
}
@@ -679,32 +866,30 @@ Function Remove-VAMIUser {
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.SYNOPSIS
This function to remove VAMI local user using VAMI interface (5480)
Modifed by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function to remove VAMI local user using VAMI interface (5480)
for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
.DESCRIPTION
Function to remove VAMI local user
.EXAMPLE
.DESCRIPTION
Function to remove VAMI local user
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
Get-VAMIAccess
.NOTES
Modified script to account for Newer VCSA. Script supports 6.5 and 6.7 VCSAs.
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(
Mandatory=$true)
]
[String]$name,
[Parameter(
Mandatory=$false)
]
[boolean]$confirm=$false
[Parameter(Mandatory=$true)]
[String]$Name
)
if(!$confirm) {
$answer = Read-Host -Prompt "Do you want to delete user $name (Y or N)"
if($answer -eq "Y" -or $answer -eq "y") {
$userAPI = Get-CisService 'com.vmware.appliance.techpreview.localaccounts.user'
Begin {}
Process{
if($PSCmdlet.ShouldProcess($Name,'Delete')) {
$userAPI = Get-VAMIServiceAPI -NameFilter "accounts"
try {
Write-Host "Deleting user $name ..."
$userAPI.delete($name)
@@ -713,4 +898,41 @@ Function Remove-VAMIUser {
}
}
}
}
End{}
}
Function Get-VAMIServiceAPI {
<#
.NOTES
===========================================================================
Inspired by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
Created by: Michael Dunsdon
Twitter: @MJDunsdon
Date: September 21, 2020
===========================================================================
.SYNOPSIS
This function returns the Service Api Based on a String of Service Name.
.DESCRIPTION
Function to find and get service api based on service name string
.EXAMPLE
Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1!
Get-VAMIUser -NameFilter "accounts"
.NOTES
Script supports 6.5 and 6.7 VCSAs.
Function Gets all Service Api Names and filters the list based on NameFilter
If Multiple Serivces are returned it takes the Top one.
#>
param(
[Parameter(Mandatory=$true)]
[String]$NameFilter
)
$ServiceAPI = Get-CisService | Where-Object {$_.name -like "*$($NameFilter)*"}
if (($ServiceAPI.count -gt 1) -and $NameFilter) {
$ServiceAPI = ($ServiceAPI | Sort-Object -Property Name)[0]
}
return $ServiceAPI
}

View File

@@ -1,3 +1,7 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-VCHAConfig {
<#
.NOTES

72
Modules/VCSA/VCSA.psm1 Normal file
View File

@@ -0,0 +1,72 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-VCSAPasswordPolicy {
<#
.DESCRIPTION Retrieves vCenter Server Appliance SSO and Local OS Password Policy Configuration
.NOTES Author: William Lam
.PARAMETER VCSAName
Inventory name of the VCSA VM
.PARAMETER VCSARootPassword
Root password for VCSA VM
.PARAMETER SSODomain
SSO Domain of the VCSA VM
.PARAMETER SSOPassword
Administrator password for the SSO Domain of the VCSA VM
.EXAMPLE
Get-VCSAPasswordPolicy -VCSAName "MGMT-VCSA-01" -VCSARootPassword "VMware1!" -SSODomain "vsphere.local" -SSOPassword "VMware1!"
#>
Param (
[Parameter(Mandatory=$true)][String]$VCSAName,
[Parameter(Mandatory=$true)][String]$VCSARootPassword,
[Parameter(Mandatory=$true)][String]$SSODomain,
[Parameter(Mandatory=$true)][String]$SSOPassword
)
$vm = Get-Vm -Name $VCSAName
if($vm) {
$a,$b = $SSODomain.split(".")
$ssoPasswordPolicy = Invoke-VMScript -ScriptText "/opt/likewise/bin/ldapsearch -h localhost -w $SSOPassword -x -D `"cn=Administrator,cn=Users,dc=$a,dc=$b`" -b `"cn=password and lockout policy,dc=$a,dc=$b`" | grep vmwPassword" -vm $vm -GuestUser "root" -GuestPassword $VCSARootPassword
$localOSPasswordPolicy = Invoke-VMScript -ScriptText "cat /etc/login.defs | grep -v '#' | grep PASS" -vm $vm -GuestUser "root" -GuestPassword $VCSARootPassword
Write-Host -ForegroundColor green "`nSSO Password Policy: "
$ssoPasswordPolicy
Write-Host -ForegroundColor green "`nLocalOS Password Policy: "
$localOSPasswordPolicy
} else {
Write-Host "`nUnable to find VCSA named $VCSAName"
}
}
Function Get-VCSAIdentitySource {
<#
.DESCRIPTION Retrieves vCenter Server Appliance Identity Source Configuration
.NOTES Author: William Lam
.PARAMETER VCSAName
Inventory name of the VCSA VM
.PARAMETER VCSARootPassword
Root password for VCSA VM
.EXAMPLE
Get-VCSAIdentitySource -VCSAName "MGMT-VCSA-01" -VCSARootPassword "VMware1!"
#>
Param (
[Parameter(Mandatory=$true)][String]$VCSAName,
[Parameter(Mandatory=$true)][String]$VCSARootPassword
)
$vm = Get-Vm -Name $VCSAName
if($vm) {
$identitySources = Invoke-VMScript -ScriptText "/opt/vmware/bin/sso-config.sh -get_identity_sources 2> /dev/null | sed -ne '/^*/,$ p'" -vm $vm -GuestUser "root" -GuestPassword $VCSARootPassword
Write-Host -ForegroundColor green "`nIdentity Sources: "
$identitySources
} else {
Write-Host "`nUnable to find VCSA named $VCSAName"
}
}

View File

@@ -0,0 +1,7 @@
# Example module for using SecretManagement and SecretStore to save PowerCLI credentials
This module demonstrates how users can use the the Microsoft.PowerShell.SecretManagement and Microsoft.PowerShell.SecretStore modules to save their PowerCLI credentials.
The module supports PowerShell 5.1 and PowerShell 7.0 and above.

View File

@@ -0,0 +1,138 @@
#
# Module manifest for module 'VMware.VISecret'
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'VMware.VISecret.psm1'
# Version number of this module.
ModuleVersion = '1.0.0.0'
# Supported PSEditions
CompatiblePSEditions = @('Desktop', 'Core')
# ID used to uniquely identify this module
GUID = '66124b00-4095-4a1f-9940-f91622009b15'
# Author of this module
Author = 'VMware'
# Company or vendor of this module
CompanyName = 'VMware'
# Copyright statement for this module
Copyright = 'Copyright (c) VMware, Inc. All rights reserved.'
# Description of the functionality provided by this module
Description = 'Module to enable easy use of Microsoft.PowerShell.SecretManagement module in VMware context'
# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '5.1'
# Name of the PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(
@{"ModuleName"="VMware.VimAutomation.Core";"ModuleVersion"="1.0.0.0"}
@{"ModuleName"="Microsoft.PowerShell.SecretManagement";"ModuleVersion"="1.1.2"}
@{"ModuleName"="Microsoft.PowerShell.SecretStore";"ModuleVersion"="1.0.6"}
)
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
#FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Initialize-VISecret',
'New-VISecret',
'Get-VISecret',
'Remove-VISecret',
'Connect-VIServerWithSecret'
)
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = @()
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
# Prerelease string of this module
# Prerelease = ''
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false
# External dependent modules of this module
# ExternalModuleDependencies = @()
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

View File

@@ -0,0 +1,314 @@
<#
.SYNOPSIS
This cmdlet downloads the dependencies and intializes the default settings of the VISecret module
.PARAMETER Vault
The vault to save the credentials to. The default value is "VMwareSecretStore"
.DESCRIPTION
This cmdlet downloads the dependecies and initializes the default settings of the VISecret module.
It uses Microsoft.PowerShell.SecretStore as a default vault and sets it in no password mode, so that
the credentials are encrypted, but the user is not prompted for a password. If you want to use a different
vault or to use it with a password you should initialize those settings manually and not use this cmdlet.
.EXAMPLE
PS C:\> Initialize-VISecret
Initializes the default settings of the VISecret module
#>
function Initialize-VISecret {
[CmdletBinding()]
param(
[string]$Vault = "VMwareSecretStore"
)
process {
Set-SecretStoreConfiguration -Scope CurrentUser -Authentication None -Interaction None -Confirm:$false
Register-SecretVault -Name $Vault -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
}
}
<#
.SYNOPSIS
This cmdlet saves new credential in the secret vault or updates it if it already exists.
.DESCRIPTION
This cmdlet saves new credential in the secret vault or updates it if it already exists.
.PARAMETER Server
The IP address or the hostname of the server to save the credential for
.PARAMETER Password
The password to be saved in the secret vault
.PARAMETER SecureStringPassword
The SecureString password to be saved in the secret vault
.PARAMETER User
The username for which to save the credential
.PARAMETER Vault
The vault to save the credential to. The default value is "VMwareSecretStore"
.EXAMPLE
PS C:\> New-VISecret -Server 10.10.10.10 -User administrator@vsphere.local -password pass
Saves the password for the administrator@vsphere.local user on the 10.10.10.10 server in the secret vault
#>
function New-VISecret {
[CmdletBinding()]
[Alias("Set-VISecret")]
param (
[Parameter(Mandatory=$true)]
[string]$Server,
[Parameter(Mandatory=$true)]
[string]$User,
[string]$Password,
[securestring]$SecureStringPassword,
[string]$Vault
)
begin {
if ([string]::IsNullOrWhiteSpace($password) -and (-not $secureStringPassword)) {
Throw "Either Password or SecureStringPassword parameter needs to be specified"
}
if (-not [string]::IsNullOrWhiteSpace($password) -and $secureStringPassword) {
Throw "Password and SecureStringPassword parameters cannot be both specified at the same time"
}
}
process {
$params = @{
"Name" = "VISecret|"+$server+"|"+$User
}
if ($password) {
$params += @{"Secret" = $password}
} elseif ($secureStringPassword) {
$params += @{"SecureStringSecret" = $secureStringPassword}
} elseif ($Vault) {
$params += @{"Vault" = $Vault}
}
Set-Secret @params
}
}
<#
.SYNOPSIS
Retrieves a credential from the secret store vault.
.DESCRIPTION
Retrieves a credential from the secret store vault.
.PARAMETER Server
The IP address or the hostname of the server to retrieve the credential for
.PARAMETER User
The username for which to retrieve the credential
.PARAMETER AsPlainText
Specifies that a credential should be returned as a String (in plain text) instead of a SecureString.
To ensure security, you should avoid using plaintext strings whenever possible.
.PARAMETER Vault
The vault to retrieve the credential from. The default value is "VMwareSecretStore"
.EXAMPLE
PS C:\> $securePassword = Get-VISecret -Server 10.10.10.10 -User administrator@vsphere.local
Retrieves the password for the administrator@vsphere.local user on the 10.10.10.10 server from the secret vault
#>
function Get-VISecret {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]$Server,
[Parameter(Mandatory=$true)]
[string]$User,
[switch]$AsPlainText,
[string]$Vault
)
process {
$params = @{
"Name" = "VISecret|"+$server+"|"+$User
}
if ($AsPlainText.IsPresent) {
$params += @{"AsPlainText" = $AsPlainText.ToBool()}
} elseif ($Vault) {
$params += @{"Vault" = $Vault}
}
Get-Secret @params
}
}
<#
.SYNOPSIS
Removes a credential from the vault.
.DESCRIPTION
Removes a credential from the vault.
.PARAMETER Server
The IP address or the hostname of the server to remove the credential for
.PARAMETER User
The username for which to remove the credential
.PARAMETER Vault
The vault to remove the credential from. The default value is "VMwareSecretStore"
.EXAMPLE
PS C:\> Remove-VISecret -Server 10.10.10.10 -User administrator@vsphere.local
Removes the password for the administrator@vsphere.local user on the 10.10.10.10 server from the vault
#>
function Remove-VISecret {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]$Server,
[Parameter(Mandatory=$true)]
[string]$User,
[string]$Vault
)
process {
$params = @{
"Name" = "VISecret|"+$server+"|"+$User
}
if ($Vault) {
$params += @{"Vault" = $Vault}
}
Remove-Secret @params
}
}
<#
.SYNOPSIS
This cmdlet establishes a connection to a vCenter Server system.
.DESCRIPTION
This cmdlet establishes a connection to a vCenter Server system.
If a credential object or username and password the cmdlet uses them to connect and if the
-SaveCredential parameter is specified saves them in the vault. If only username
is specified the cmdlet uses the server name and the user name to search for the password in the
vault.
.PARAMETER Server
Specifies the IP address or the DNS name of the vSphere server to which you want to connect.
.PARAMETER User
Specifies the user name you want to use for authenticating with the server.
.PARAMETER Password
Specifies the password you want to use for authenticating with the server.
.PARAMETER Credential
Specifies a PSCredential object that contains credentials for authenticating with the server.
.PARAMETER AllLinked
Indicates whether you want to connect to vCenter Server in linked mode. If you specify $true
for the -AllLinked parameter and the server to which you want to connect is a part of a federation
vCenter Server, you'll be connected to all members of the linked vCenter Server. To use this
option, PowerCLI must be configured to work in multiple servers connection mode. To configure
PowerCLI to support multiple servers connection, specify Multiple for the DefaultVIServerMode
parameter of the Set-PowerCLIConfiguration cmdlet.
.PARAMETER Force
Suppresses all user interface prompts during the cmdlet execution.
.PARAMETER NotDefault
Indicates that you do not want to include the server to which you connect into the $defaultVIServers variable.
.PARAMETER Port
Specifies the port on the server you want to use for the connection.
.PARAMETER Protocol
Specifies the Internet protocol you want to use for the connection. It can be either http or https.
.PARAMETER SaveCredentials
Indicates that you want to save the specified credentials in the vault.
.PARAMETER Vault
The vault to save the credential to. The default value is "VMwareSecretStore"
.EXAMPLE
Connect-VIServer -Server 10.10.10.10 -User administrator@vsphere.local
Connects to a vSphere server using the saved credential for the specified user
.EXAMPLE
Connect-VIServer -Server 10.10.10.10 -User administrator@vsphere.local -Password pass -SaveCredential
Connects to a vSphere server using the specified username and password and saves them in the vault
#>
function Connect-VIServerWithSecret {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]$Server,
[string]$User,
[string]$Password,
[pscredential]$Credential,
[switch]$AllLinked,
[switch]$Force,
[switch]$NotDefault,
[int]$Port,
[string]$Protocol,
[switch]$SaveCredentials,
[string]$Vault
)
begin {
if ([string]::IsNullOrWhiteSpace($User) -and (-not $Credential)) {
if ($global:defaultUser) {
$User = $global:defaultUser
} else {
Throw "Either User or Credential parameters needs to be specified"
}
}
if ((-not [string]::IsNullOrWhiteSpace($User) -or -not [string]::IsNullOrWhiteSpace($Password)) -and $Credential) {
Throw "User/Password and Credential parameters cannot be both specified at the same time"
}
}
process {
$params = @{
"Server" = $Server
"AllLinked" = $AllLinked
"Force" = $Force
"NotDefault" = $NotDefault
}
if ($Protocol) {
$params += @{"Protocol" = $Protocol}
}
if ($Port) {
$params += @{"Port" = $Port}
}
if ($User) {
if (-not $Password) {
if ($Vault) {
$secret = Get-Secret -Name ("VISecret|"+$server+"|"+$User) -Vault $Vault -ErrorAction SilentlyContinue
} else {
$secret = Get-Secret -Name ("VISecret|"+$server+"|"+$User) -ErrorAction SilentlyContinue
}
if (-not $secret) {
Throw "No password has been found for this server and user in the password vault"
}
$Credential = New-Object System.Management.Automation.PSCredential ($User, $secret)
}
else {
$securePass = ConvertTo-SecureString -String $Password -AsPlainText
$Credential = New-Object System.Management.Automation.PSCredential ($User, $securePass)
}
}
$params += @{"Credential" = $Credential}
Connect-VIServer @params
if ($SaveCredentials) {
New-VISecret -Server $Server -User $User -SecureStringPassword $Credential.Password -Vault $Vault
}
}
}

View File

@@ -1,5 +1,9 @@
function Get-VMCPSettings {
<#
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Get-VMCPSettings {
<#
.NOTES
===========================================================================
Created on: 10/27/2015 9:25 PM
@@ -11,7 +15,7 @@
Modified on: 10/11/2016
Modified by: Erwan Quélin
Twitter: @erwanquelin
Github: https://github.com/equelin
Github: https://github.com/equelin
===========================================================================
.DESCRIPTION
This function will allow users to view the VMCP settings for their clusters
@@ -94,7 +98,7 @@
}
function Set-VMCPSettings {
<#
<#
.NOTES
===========================================================================
Created on: 10/27/2015 9:25 PM
@@ -106,7 +110,7 @@ function Set-VMCPSettings {
Modified on: 10/11/2016
Modified by: Erwan Quélin
Twitter: @erwanquelin
Github: https://github.com/equelin
Github: https://github.com/equelin
===========================================================================
.DESCRIPTION
This function will allow users to enable/disable VMCP and also allow
@@ -147,21 +151,21 @@ function Set-VMCPSettings {
.EXAMPLE
Set-VMCPSettings -cluster LAB-CL -enableVMCP:$True -VmStorageProtectionForPDL `
restartAggressive -VmStorageProtectionForAPD restartAggressive `
-VmTerminateDelayForAPDSec 2000 -VmReactionOnAPDCleared reset
-VmTerminateDelayForAPDSec 2000 -VmReactionOnAPDCleared reset
This will enable VMCP and configure the Settings on cluster LAB-CL
.EXAMPLE
Set-VMCPSettings -cluster LAB-CL -enableVMCP:$False -VmStorageProtectionForPDL `
disabled -VmStorageProtectionForAPD disabled `
-VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none
-VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none
This will disable VMCP and configure the Settings on cluster LAB-CL
.EXAMPLE
Set-VMCPSettings -enableVMCP:$False -VmStorageProtectionForPDL `
disabled -VmStorageProtectionForAPD disabled `
-VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none
-VmTerminateDelayForAPDSec 600 -VmReactionOnAPDCleared none
This will disable VMCP and configure the Settings on all clusters available
#>
@@ -173,7 +177,7 @@ function Set-VMCPSettings {
ValueFromPipelineByPropertyName=$True,
HelpMessage='What is the Cluster Name?')]
$cluster,
[Parameter(Mandatory=$False,
ValueFromPipeline=$False,
HelpMessage='$True=Enabled $False=Disabled')]
@@ -184,24 +188,24 @@ function Set-VMCPSettings {
HelpMessage='Actions that can be taken in response to a PDL event')]
[ValidateSet("disabled","warning","restartAggressive")]
[string]$VmStorageProtectionForPDL,
[Parameter(Mandatory=$False,
ValueFromPipeline=$False,
HelpMessage='Options available for an APD response')]
[ValidateSet("disabled","restartConservative","restartAggressive","warning")]
[string]$VmStorageProtectionForAPD,
[Parameter(Mandatory=$False,
ValueFromPipeline=$False,
HelpMessage='Value in seconds')]
[Int]$VmTerminateDelayForAPDSec,
[Parameter(Mandatory=$False,
ValueFromPipeline=$False,
HelpMessage='This setting will instruct vSphere HA to take a certain action if an APD event is cleared')]
[ValidateSet("reset","none")]
[string]$VmReactionOnAPDCleared,
[Parameter(Mandatory=$False)]
[VMware.VimAutomation.Types.VIServer[]]$Server = $global:DefaultVIServers
)
@@ -232,14 +236,14 @@ function Set-VMCPSettings {
# Create the object we will configure
$settings = New-Object VMware.Vim.ClusterConfigSpecEx
$settings.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
# Based on $enableVMCP switch
if ($enableVMCP -eq $false) {
# Based on $enableVMCP switch
if ($enableVMCP -eq $false) {
$settings.dasConfig.vmComponentProtecting = "disabled"
}
elseif ($enableVMCP -eq $true) {
$settings.dasConfig.vmComponentProtecting = "enabled"
}
}
elseif ($enableVMCP -eq $true) {
$settings.dasConfig.vmComponentProtecting = "enabled"
}
#Create the VMCP object to work with
$settings.dasConfig.defaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings
@@ -295,7 +299,7 @@ function Set-VMCPSettings {
} else {
$settings.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmTerminateDelayForAPDSec = $ActualSettings.'APD Timeout (Seconds)'
}
# Reaction On APD Cleared
If ($PSBoundParameters.ContainsKey('VmReactionOnAPDCleared')) {
$settings.dasConfig.defaultVmSettings.vmComponentProtectionSettings.vmReactionOnAPDCleared = "$VmReactionOnAPDCleared"

View File

@@ -112,7 +112,7 @@ function Get-VmfsDatastoreIncrease
Datastore = $Datastore.Name
CanonicalName = $disk.CanonicalName
Model = "$($disk.Vendor.TrimEnd(' ')).$($disk.Model.TrimEnd(' ')).$($disk.Revision.TrimEnd(' '))"
DiskSizeGB = $partInfo[0].Layout.Total.BlockSize * $hdPartInfo[0].Layout.Total.Block / 1GB
DiskSizeGB = $partInfo[0].Layout.Total.BlockSize * $partInfo[0].Layout.Total.Block / 1GB
DiskBlocks = $partInfo[0].Layout.Total.Block
DiskBlockMB = $partInfo[0].Layout.Total.BlockSize/1MB
AvailableGB = [math]::Round($partMax - $partUsed, 2)
@@ -181,7 +181,7 @@ function New-VmfsDatastoreIncrease
{
$lun = $hScsiDisk | where{ $_.CanonicalName -eq $dsOpt.Spec.Extent.DiskName }
$partInfo = $hsSys.RetrieveDiskPartitionInfo($lun.DeviceName)
$partMax = ($vmfsExpOpt[0].Info.Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
$partMax = ($expOpt[0].Info.Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
Measure-Object -Sum | select -ExpandProperty Sum)/1GB
$partUsed = ($partInfo[0].Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
Measure-Object -Sum | select -ExpandProperty Sum)/1GB

View File

@@ -1,4 +1,4 @@
# Script Module : VMToolsManagement
# Script Module : VMToolsManagement
# Version : 1.0
# Copyright © 2017 VMware, Inc. All Rights Reserved.
@@ -37,10 +37,10 @@ New-VIProperty -Name ToolsBuildNumber -Object VirtualMachine -Value {
Function Get-VMToolsInfo {
<#
.SYNOPSIS
This cmdlet retrieves the VMTools info of specified virtual machines.
This advanced function retrieves the VMTools info of specified virtual machines.
.DESCRIPTION
This cmdlet retrieves the VMTools version and build number info of specified virtual machines.
This advanced function retrieves the VMTools version and build number info of specified virtual machines.
.PARAMETER VM
Specifies the virtual machines which you want to get the VMTools info of.
@@ -50,7 +50,7 @@ Function Get-VMToolsInfo {
C:\PS> $VCServer = Connect-VIServer -Server <vCenter Server IP> -User <vCenter User> -Password <vCenter Password>
C:\PS> Get-VM -Server $VCServer | Get-VMToolsInfo
Retrieves VMTools info of all virtual machines which run in the $VCServer vCetner Server.
Retrieves VMTools info of all virtual machines which run in the $VCServer vCenter Server.
.EXAMPLE
C:\PS> Get-VM "*rhel*" | Get-VMToolsInfo
@@ -74,7 +74,7 @@ Function Get-VMToolsInfo {
Retrieves VMTools info of virtual machines which run on the "MyESXiHostName" ESXi host.
.NOTES
This cmdlet assumes that you are connected to at least one vCenter Server system.
This advanced function assumes that you are connected to at least one vCenter Server system.
The tools build number is not supported in VMTools before 10.2.0
.NOTES
@@ -100,17 +100,17 @@ Function Get-VMToolsInfo {
)
Process {
Get-VM $VM | Select Name, @{Name="ToolsVersion"; Expression={$_.Guest.ToolsVersion}}, ToolsBuildNumber
Get-VM $VM | Select-Object Name, @{Name="ToolsVersion"; Expression={$_.Guest.ToolsVersion}}, ToolsBuildNumber
}
}
Function Get-VMToolsInstallLastError {
<#
.SYNOPSIS
This cmdlet retrieves the error code of last VMTools installation.
This advanced function retrieves the error code of last VMTools installation.
.DESCRIPTION
This cmdlet retrieves the error code of last VMTools installation on specified virtual machines.
This advanced function retrieves the error code of last VMTools installation on specified virtual machines.
.PARAMETER VM
Specifies the virtual machines which you want to get the error code of.
@@ -120,7 +120,7 @@ Function Get-VMToolsInstallLastError {
C:\PS> $VCServer = Connect-VIServer -Server <vCenter Server IP> -User <vCenter User> -Password <vCenter Password>
C:\PS> Get-VM -Server $VCServer | Get-VMToolsInstallLastError
Retrieves the last VMTools installation error code of all virtual machines which run in the $VCServer vCetner Server.
Retrieves the last VMTools installation error code of all virtual machines which run in the $VCServer vCenter Server.
.EXAMPLE
C:\PS> Get-VM "*win*" | Get-VMToolsInstallLastError
@@ -144,7 +144,7 @@ Function Get-VMToolsInstallLastError {
Retrieves the last VMTools installation error code of virtual machines which run on the "MyESXiHostName" ESXi host.
.NOTES
This cmdlet assumes that you are connected to at least one vCenter Server system.
This advanced function assumes that you are connected to at least one vCenter Server system.
.NOTES
Author : Daoyuan Wang
@@ -171,7 +171,7 @@ Function Get-VMToolsInstallLastError {
Process {
$result = @()
foreach ($_ in $VM) {
$errorCodeInfo = $_.ExtensionData.Config.ExtraConfig.GetEnumerator() | where {$_.Key -eq "guestinfo.toolsInstallErrCode"}
$errorCodeInfo = $_.ExtensionData.Config.ExtraConfig.GetEnumerator() | Where-Object {$_.Key -eq "guestinfo.toolsInstallErrCode"}
$info = New-Object PSObject
$info | Add-Member -type NoteProperty -name VmName -value $_.Name
@@ -186,10 +186,10 @@ Function Get-VMToolsInstallLastError {
Function Get-VMToolsGuestInfo {
<#
.SYNOPSIS
This cmdlet retrieves the guest info of specified virtual machines.
This advanced function retrieves the guest info of specified virtual machines.
.DESCRIPTION
This cmdlet retrieves the guest info such as HostName, IP, ToolsStatus, ToolsVersion,
This advanced function retrieves the guest info such as HostName, IP, ToolsStatus, ToolsVersion,
ToolsInstallType and GuestFamily of specified virtual machines.
.PARAMETER VM
@@ -200,7 +200,7 @@ Function Get-VMToolsGuestInfo {
C:\PS> $VCServer = Connect-VIServer -Server <vCenter Server IP> -User <vCenter User> -Password <vCenter Password>
C:\PS> Get-VM -Server $VCServer | Get-VMToolsGuestInfo
Retrieves guest info of all virtual machines which run in the $VCServer vCetner Server.
Retrieves guest info of all virtual machines which run in the $VCServer vCenter Server.
.EXAMPLE
C:\PS> Get-VM "*win*" | Get-VMToolsGuestInfo
@@ -236,7 +236,7 @@ Function Get-VMToolsGuestInfo {
Retrieves guest info of virtual machines which run on the "MyESXiHostName" ESXi host.
.NOTES
This cmdlet assumes that you are connected to at least one vCenter Server system.
This advanced function assumes that you are connected to at least one vCenter Server system.
.NOTES
Author : Daoyuan Wang
@@ -261,7 +261,7 @@ Function Get-VMToolsGuestInfo {
)
Process {
Get-VM $VM | Select Name, @{Name="HostName"; Expression={$_.Guest.HostName}},
Get-VM $VM | Select-Object Name, @{Name="HostName"; Expression={$_.Guest.HostName}},
@{Name="IP"; Expression={$_.Guest.ExtensionData.IpAddress}},
@{Name="ToolsStatus"; Expression={$_.Guest.ExtensionData.ToolsStatus}},
@{Name="ToolsVersion"; Expression={$_.Guest.ToolsVersion}},
@@ -274,10 +274,10 @@ Function Get-VMToolsGuestInfo {
Function Get-VMByToolsInfo {
<#
.SYNOPSIS
This cmdlet retrieves the virtual machines with specified VMTools info.
This advanced function retrieves the virtual machines with specified VMTools info.
.DESCRIPTION
This cmdlet retrieves the virtual machines with specified VMTools version,
This advanced function retrieves the virtual machines with specified VMTools version,
running status or version status.
.PARAMETER VM
@@ -297,7 +297,7 @@ Function Get-VMByToolsInfo {
C:\PS> $VCServer = Connect-VIServer -Server <vCenter Server IP> -User <vCenter User> -Password <vCenter Password>
C:\PS> Get-VM -Server $VCServer | Get-VMByToolsInfo
Retrieves the virtual machines with VMTools not running in vCetner Server $VCServer.
Retrieves the virtual machines with VMTools not running in vCenter Server $VCServer.
.EXAMPLE
C:\PS> Get-VM | Get-VMByToolsInfo -ToolsRunningStatus guestToolsNotRunning
@@ -328,7 +328,7 @@ Function Get-VMByToolsInfo {
Retrieves the virtual machines with VMTools that need to upgrade on the "MyESXiHostName" ESXi host.
.NOTES
This cmdlet assumes that you are connected to at least one vCenter Server system.
This advanced function assumes that you are connected to at least one vCenter Server system.
.NOTES
Author : Daoyuan Wang
@@ -361,9 +361,9 @@ Function Get-VMByToolsInfo {
[String] $ToolsRunningStatus,
[Parameter(Mandatory=$false)]
[ValidateSet("guestToolsNotInstalled",
"guestToolsNeedUpgrade",
"guestToolsCurrent",
[ValidateSet("guestToolsNotInstalled",
"guestToolsNeedUpgrade",
"guestToolsCurrent",
"guestToolsUnmanaged")]
[String] $ToolsVersionStatus
)
@@ -376,65 +376,60 @@ Function Get-VMByToolsInfo {
}
if ($ToolsVersion) {
$vmList = $vmList | Where {$_.Guest.ToolsVersion -like $ToolsVersion}
$vmList = $vmList | Where-Object {$_.Guest.ToolsVersion -like $ToolsVersion}
}
if ($ToolsRunningStatus) {
$vmList = $vmList | Where {$_.Guest.ExtensionData.ToolsRunningStatus -eq $ToolsRunningStatus}
$vmList = $vmList | Where-Object {$_.Guest.ExtensionData.ToolsRunningStatus -eq $ToolsRunningStatus}
}
if ($ToolsVersionStatus) {
$vmList = $vmList | Where {$_.Guest.ExtensionData.ToolsVersionStatus -eq $ToolsVersionStatus}
$vmList = $vmList | Where-Object {$_.Guest.ExtensionData.ToolsVersionStatus -eq $ToolsVersionStatus}
}
$vmList
}
}
Function Set-VMToolsUpgradePolicy {
Function Get-VMToolsUpgradePolicy {
<#
.SYNOPSIS
This cmdlet sets the VMTool's upgrade policy to "upgradeAtPowerCycle".
This advanced function retrieves the VMTools upgrade policy info of specified virtual machines.
.DESCRIPTION
This cmdlet sets the VMTool's upgrade policy to "upgradeAtPowerCycle" of specified virtual machines.
This advanced function retrieves the VMTools upgrade policy info of specified virtual machines.
.PARAMETER VM
Specifies the virtual machines which you want to set the VMTool's upgrade policy of.
Specifies the virtual machines which you want to query VMTools status of.
.EXAMPLE
C:\PS> Import-Module .\VMToolsManagement.psm1
C:\PS> $VCServer = Connect-VIServer -Server <vCenter Server IP> -User <vCenter User> -Password <vCenter Password>
C:\PS> Get-VM -Server $VCServer | Set-VMToolsUpgradePolicy
Sets VMTool's upgrade policy to "upgradeAtPowerCycle" of all virtual machines in the $VCServer vCetner Server.
C:\PS> Get-VM "*rhel*" | Get-VMToolsUpgradePolicy
Name VMToolsUpgradePolicy
------ ----------------------
111394-RHEL-6.8-0 manual
111394-RHEL-6.8-1 manual
111393-RHEL-Server-7.2 upgradeAtPowerCycle
Retrieves VMTools upgrade policy info of virtual machines with name containing "rhel".
.EXAMPLE
C:\PS> Get-VM "*win*" | Set-VMToolsUpgradePolicy
Sets VMTool's upgrade policy to "upgradeAtPowerCycle" of virtual machines with name containing "win".
C:\PS> Get-VM -Location "MyClusterName" | Get-VMToolsUpgradePolicy
Retrieves VMTools upgrade policy info from virtual machines which run in the "MyClusterName" cluster.
.EXAMPLE
C:\PS> Get-VM -Location "MyClusterName" | Set-VMToolsUpgradePolicy
Sets VMTool's upgrade policy to "upgradeAtPowerCycle" of virtual machines in the "MyClusterName" cluster.
.EXAMPLE
C:\PS> Get-VMHost "MyESXiHostName" | Get-VM | Set-VMToolsUpgradePolicy
Sets VMTool's upgrade policy to "upgradeAtPowerCycle" of virtual machines on the "MyESXiHostName" ESXi host.
C:\PS> Get-VMHost "MyESXiHostName" | Get-VM | Get-VMToolsUpgradePolicy
Retrieves VMTools upgrade policyinfo of virtual machines which run on the "MyESXiHostName" ESXi host.
.NOTES
This cmdlet assumes that you are connected to at least one vCenter Server system.
This advanced function assumes that you are connected to at least one vCenter Server system.
.NOTES
Author : Daoyuan Wang
Author email : daoyuanw@vmware.com
Author : Kyle Ruddy
Author email : kmruddy@gmail.com
Version : 1.0
==========Tested Against Environment==========
VMware vSphere Hypervisor(ESXi) Version : 6.5 (build 4564106)
VMware vCenter Server Version : 6.5 (build 4602587)
PowerCLI Version : PowerCLI 6.5 (build 4624819)
VMware vSphere Hypervisor(ESXi) Version : 6.5 (build 7388607)
VMware vCenter Server Version : 6.5 (build 7312210)
PowerCLI Version : PowerCLI 6.5 (build 7155375)
PowerShell Version : 5.1
#>
@@ -448,8 +443,81 @@ Function Set-VMToolsUpgradePolicy {
[ValidateNotNullOrEmpty()]
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $VM
)
Process {
Get-VM $VM | Select-Object Name, @{Name="VMToolsUpgradePolicy"; Expression={$_.ExtensionData.Config.Tools.ToolsUpgradePolicy}}
}
}
Function Set-VMToolsUpgradePolicy {
<#
.SYNOPSIS
This advanced function sets the VMTool's upgrade policy to either "manual" or "upgradeAtPowerCycle".
.DESCRIPTION
This advanced function sets the VMTool's upgrade policy to either "manual" or "upgradeAtPowerCycle" of specified virtual machines.
.PARAMETER VM
Specifies the virtual machines which you want to set the VMTool's upgrade policy of.
.EXAMPLE
C:\PS> Import-Module .\VMToolsManagement.psm1
C:\PS> $VCServer = Connect-VIServer -Server <vCenter Server IP> -User <vCenter User> -Password <vCenter Password>
C:\PS> Get-VM -Server $VCServer | Set-VMToolsUpgradePolicy -UpgradePolicy manual
Sets VMTool's upgrade policy to "manual" of all virtual machines in the $VCServer vCenter Server.
.EXAMPLE
C:\PS> Get-VM "*win*" | Set-VMToolsUpgradePolicy -UpgradePolicy upgradeAtPowerCycle
Sets VMTool's upgrade policy to "upgradeAtPowerCycle" of virtual machines with name containing "win".
.EXAMPLE
C:\PS> Get-VM -Location "MyClusterName" | Set-VMToolsUpgradePolicy -UpgradePolicy upgradeAtPowerCycle
Sets VMTool's upgrade policy to "upgradeAtPowerCycle" of virtual machines in the "MyClusterName" cluster.
.EXAMPLE
C:\PS> Get-VMHost "MyESXiHostName" | Get-VM | Set-VMToolsUpgradePolicy -UpgradePolicy manual
Sets VMTool's upgrade policy to "manual" of virtual machines on the "MyESXiHostName" ESXi host.
.NOTES
This advanced function assumes that you are connected to at least one vCenter Server system.
.NOTES
Author : Daoyuan Wang
Author email : daoyuanw@vmware.com
Version : 1.1
Update Author : Kyle Ruddy
Update email : kmruddy@gmail.com
==========Tested Against Environment==========
VMware vSphere Hypervisor(ESXi) Version : 6.5 (build 4564106)(build 7388607)
VMware vCenter Server Version : 6.5 (build 4602587)(build 7312210)
PowerCLI Version : PowerCLI 6.5 (build 4624819)(build 7155375)
PowerShell Version : 5.1
#>
[CmdletBinding(SupportsShouldProcess)]
Param (
[Parameter(Mandatory=$true,
ValueFromPipeLine = $true,
ValueFromPipelinebyPropertyName=$True,
Position = 0)]
[ValidateNotNullOrEmpty()]
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $VM,
[Parameter(Mandatory=$false,
Position = 1)]
[ValidateSet("upgradeAtPowerCycle",
"manual")]
[String] $UpgradePolicy
)
Begin {
$UpgradePolicy = "upgradeAtPowerCycle"
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = $UpgradePolicy
@@ -463,6 +531,7 @@ Function Set-VMToolsUpgradePolicy {
if ($vmView.Config.Tools.ToolsUpgradePolicy -ne $UpgradePolicy) {
Write-Verbose "Applying 'upgradeAtPowerCycle' setting to $($_.Name)..."
$vmView.ReconfigVM($vmConfigSpec)
Get-VMToolsUpgradePolicy -VM $_
}
}
}
@@ -471,10 +540,10 @@ Function Set-VMToolsUpgradePolicy {
Function Invoke-VMToolsListProcessInVM {
<#
.Synopsis
This cmdlet lists the processes in the virtual machine.
This advanced function lists the processes in the virtual machine.
.Description
This cmdlet lists the running processes in the virtual machine.
This advanced function lists the running processes in the virtual machine.
.PARAMETER VM
Specifies the virtual machine which you want to list the processes of.
@@ -503,7 +572,7 @@ Function Invoke-VMToolsListProcessInVM {
List the processes in the "MyVMName" VM.
.NOTES
This cmdlet lists processes in the guest OS of virtual machine.
This advanced function lists processes in the guest OS of virtual machine.
A VMTools should already be running in the guest OS.
.NOTES
@@ -559,10 +628,10 @@ Function Invoke-VMToolsListProcessInVM {
Function Update-VMToolsImageLocation {
<#
.Synopsis
This cmdlet updates the link /productLocker in ESXi host.
This advanced function updates the link /productLocker in ESXi host.
.Description
This cmdlet updates the link /productLocker in ESXi host directly to avoid host reboot.
This advanced function updates the link /productLocker in ESXi host directly to avoid host reboot.
.Parameter VMHost
Specifies the ESXi host on which you want to update the /productLocker link.
@@ -574,7 +643,7 @@ Function Update-VMToolsImageLocation {
Specifies the password you want to use for authenticating with the ESXi host.
.Parameter ImageLocation
Specifies the new image location where you want /producterLocker to link.
Specifies the new image location Where-Object you want /producterLocker to link.
.Example
C:\PS> Import-Module .\VMToolsManagement.psm1
@@ -586,9 +655,9 @@ Function Update-VMToolsImageLocation {
Update the link /producterLocker on $SampleHost to point to '/locker/packages/6.5.0/'.
.NOTES
This cmdlet connects to ESXi host to execute shell command directly.
This advanced function connects to ESXi host to execute shell command directly.
Make sure the SSH service on ESXi host is enabled, and a SSH library(Posh-SSH or SSH-Sessions etc.)
for powershell is already installed on client where you call This cmdlet.
for powershell is already installed on client Where-Object you call this advanced function.
You can instal Posh-SSH by executing:
iex (New-Object Net.WebClient).DownloadString("https://gist.github.com/darkoperator/6152630/raw/c67de4f7cd780ba367cccbc2593f38d18ce6df89/instposhsshdev")
For SSH-Sessions installation and usage, please refer to
@@ -628,7 +697,7 @@ Function Update-VMToolsImageLocation {
Process {
if (-not (Get-Command New-SSHSession)) {
Throw "This cmdlet depends on SSH library. Please ensure a SSH library is already installed!"
Throw "This advanced function depends on SSH library. Please ensure a SSH library is already installed!"
}
$password = new-object System.Security.SecureString
@@ -656,18 +725,21 @@ Function Update-VMToolsImageLocation {
}
}
Function Update-VMToolsConfInVM {
Function Set-VMToolsConfInVM {
<#
.Synopsis
This cmdlet updates the tools.conf content in guest OS.
This advanced function sets the tools.conf content in guest OS.
.Description
This cmdlet copies the tools.conf in gueset OS of virtual machine to localhost,
then updates it locally by setting "vmtoolsd.level = info" and copies it back to the guest OS.
This advanced function copies the tools.conf in gueset OS of virtual machine to localhost,
then sets it locally by setting "vmtoolsd.level" to a valid level and copies it back to the guest OS.
.PARAMETER VM
Specifies the virtual machine to update.
.PARAMETER LogLevel
Specifies the desired log level to log.
.Parameter GuestUser
Specifies the user name you want to use for authenticating with the guest OS.
@@ -684,16 +756,18 @@ Function Update-VMToolsConfInVM {
Updates the tools.conf in $SampleVM, changes the vmtoolsd log level to info ("vmtoolsd.level = info") for example.
.NOTES
This cmdlet updates the tools.conf in guest OS. A VMTools should already be running in the guest OS.
This advanced function updates the tools.conf in guest OS. A VMTools should already be running in the guest OS.
.NOTES
Author : Daoyuan Wang
Author email : daoyuanw@vmware.com
Version : 1.0
Version : 1.1
Update Author : Kyle Ruddy
Update email : kmruddy@gmail.com
==========Tested Against Environment==========
VMware vSphere Hypervisor(ESXi) Version : 6.5 (build 4564106)
VMware vCenter Server Version : 6.5 (build 4602587)
PowerCLI Version : PowerCLI 6.5 (build 4624819)
VMware vSphere Hypervisor(ESXi) Version : 6.5 (build 4564106)(build 7388607)
VMware vCenter Server Version : 6.5 (build 4602587)(build 7312210)
PowerCLI Version : PowerCLI 6.5 (build 4624819)(build 7155375)
PowerShell Version : 5.1
#>
@@ -707,6 +781,17 @@ Function Update-VMToolsConfInVM {
[ValidateNotNullOrEmpty()]
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine] $VM,
[Parameter(Mandatory=$true,
Position = 1)]
[ValidateSet("none",
"critical",
"error",
"warning",
"message",
"info",
"debug")]
[String] $LogLevel,
[Parameter(Mandatory=$true)]
[String] $GuestUser,
@@ -756,7 +841,7 @@ Function Update-VMToolsConfInVM {
# Updates tools.conf by setting vmtoolsd.level = info, just for example.
#############################################################################
$confContent = Get-Content $localToolsConfFile
$updatedContent = "vmtoolsd.level = info"
$updatedContent = "vmtoolsd.level = $LogLevel"
Write-Verbose "Editing tools.conf (set 'vmtoolsd.level = info' for example)..."
if ($confContent -match "vmtoolsd\.level") {
@@ -775,19 +860,23 @@ Function Update-VMToolsConfInVM {
-GuestUser $GuestUser -GuestPassword $GuestPassword -Force -ErrorAction:Stop
} catch {
Write-Error "Failed to update tools.conf of $VM"
Write-Verbose "Removing the local tools configuration file"
Remove-Item $localToolsConfFile
return
}
Write-Host "The tools.conf updated in $VM successfully." -ForegroundColor Green
Write-Verbose "Removing the local tools configuration file"
Remove-Item $localToolsConfFile
}
}
Function Invoke-VMToolsVIBInstall {
<#
.SYNOPSIS
This cmdlet installs VMTool VIB in ESXi hosts.
This advanced function installs VMTool VIB in ESXi hosts.
.DESCRIPTION
This cmdlet installs VMTool VIB in specified ESXi hosts.
This advanced function installs VMTool VIB in specified ESXi hosts.
.PARAMETER VMHost
Specifies the ESXi hosts which you want to install VMTool VIB in.
@@ -816,7 +905,7 @@ Function Invoke-VMToolsVIBInstall {
Installs VMTool VIB in ESXi host of the "MyClusterName" cluster.
.NOTES
This cmdlet assumes that you are connected to at least one vCenter Server system.
This advanced function assumes that you are connected to at least one vCenter Server system.
.NOTES
Author : Daoyuan Wang
@@ -846,7 +935,7 @@ Function Invoke-VMToolsVIBInstall {
foreach ($_ in $VMHost) {
$esxcli = Get-EsxCLI -VMHost $_ -V2
$result = $esxcli.software.vib.list.Invoke() | where {$_.name -match 'tools'}
$result = $esxcli.software.vib.list.Invoke() | Where-Object {$_.name -match 'tools'}
Write-Verbose "Existing tools VIB on $_ before installing: $($result.Name)_$($result.Version)"
# Install VIBs
@@ -861,7 +950,7 @@ Function Invoke-VMToolsVIBInstall {
Write-Error "Failed to install VMTools VIB package!"
} else {
Write-Verbose $result.Message
$result = $esxcli.software.vib.list.Invoke() | where {$_.name -match 'tools'}
$result = $esxcli.software.vib.list.Invoke() | Where-Object {$_.name -match 'tools'}
Write-Verbose "Tools VIB on $_ after installing: $($result.Name)_$($result.Version)"
Write-Host "VMTools VIB package installed on $_ successfully." -ForegroundColor Green
}
@@ -872,10 +961,10 @@ Function Invoke-VMToolsVIBInstall {
Function Invoke-VMToolsUpgradeInVMs {
<#
.SYNOPSIS
This cmdlet upgrades VMTools to the version bundled by ESXi host.
This advanced function upgrades VMTools to the version bundled by ESXi host.
.DESCRIPTION
This cmdlet upgrades VMTools of specified virtual machines to the version
This advanced function upgrades VMTools of specified virtual machines to the version
bundled by ESXi host. You can also specify the number of virtual machines
to upgrade in parallel.
@@ -896,7 +985,7 @@ Function Invoke-VMToolsUpgradeInVMs {
C:\PS> $VCServer = Connect-VIServer -Server <vCenter Server IP> -User <vCenter User> -Password <vCenter Password>
C:\PS> Get-VM -Server $VCServer | Invoke-VMToolsUpgradeInVMs -MaxParallelUpgrades 5
Upgrades VMTools of all virtual machines in the $VCServer vCetner Server, 5 at a time in parallel.
Upgrades VMTools of all virtual machines in the $VCServer vCenter Server, 5 at a time in parallel.
.EXAMPLE
C:\PS> Get-VM | Invoke-VMToolsUpgradeInVMs -GuestOSType windows -MaxParallelUpgrades 1 | ft -Autosize
@@ -929,7 +1018,7 @@ Function Invoke-VMToolsUpgradeInVMs {
Upgrades VMTools of virtual machines on the "MyESXiHostName" ESXi host, 5 at a time.
.NOTES
This cmdlet assumes an old VMTools is already running in the virtual machine.
This advanced function assumes an old VMTools is already running in the virtual machine.
.NOTES
Author : Daoyuan Wang
@@ -1026,7 +1115,7 @@ Function Invoke-VMToolsUpgradeInVMs {
# Load PowerCLI module and connect to VCServer, as child thread environment is independent with parent
if(-not $global:DefaultVIServer) {
$moduleName = "vmware.vimautomation.core"
if(-not (Get-Module | Where {$_.name -eq $moduleName})) {
if(-not (Get-Module | Where-Object {$_.name -eq $moduleName})) {
try {
Import-Module $moduleName -ErrorAction SilentlyContinue | Out-Null
}
@@ -1130,7 +1219,7 @@ Function Invoke-VMToolsUpgradeInVMs {
End {
#Verify all threads completed
while (($jobs | Where {$_.Handle.iscompleted -ne Completed}).Count -gt 0) {
while (($jobs | Where-Object {$_.Handle.iscompleted -ne "Completed"}).Count -gt 0) {
Start-Sleep -Seconds 5
}
@@ -1146,4 +1235,4 @@ Function Invoke-VMToolsUpgradeInVMs {
}
}
Export-ModuleMember *-*
Export-ModuleMember *-*

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Markus Kraus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,5 +1,5 @@
#
# Modulmanifest für das Modul "PSGet_VMware-vCD-Module"
# Modulmanifest f<EFBFBD>r das Modul "PSGet_VMware-vCD-Module"
#
# Generiert von: Markus
#
@@ -8,52 +8,52 @@
@{
# Die diesem Manifest zugeordnete Skript- oder Binärmoduldatei.
# Die diesem Manifest zugeordnete Skript- oder Bin<EFBFBD>rmoduldatei.
# RootModule = ''
# Die Versionsnummer dieses Moduls
ModuleVersion = '1.0.0'
ModuleVersion = '1.3.0'
# ID zur eindeutigen Kennzeichnung dieses Moduls
GUID = '1ef8a2de-ca22-4c88-8cdb-e00f35007d2a'
# Autor dieses Moduls
Author = 'Markus'
Author = 'Markus Kraus'
# Unternehmen oder Hersteller dieses Moduls
CompanyName = 'mycloudrevolution.com'
# Urheberrechtserklärung für dieses Modul
# Urheberrechtserkl<EFBFBD>rung f<EFBFBD>r dieses Modul
Copyright = '(c) 2017 Markus. Alle Rechte vorbehalten.'
# Beschreibung der von diesem Modul bereitgestellten Funktionen
# Description = ''
Description = 'This a POwerShell Module based on VMware PowerCLI vCloud Director Module to extend its function'
# Die für dieses Modul mindestens erforderliche Version des Windows PowerShell-Moduls
# Die f<EFBFBD>r dieses Modul mindestens erforderliche Version des Windows PowerShell-Moduls
# PowerShellVersion = ''
# Der Name des für dieses Modul erforderlichen Windows PowerShell-Hosts
# Der Name des f<EFBFBD>r dieses Modul erforderlichen Windows PowerShell-Hosts
# PowerShellHostName = ''
# Die für dieses Modul mindestens erforderliche Version des Windows PowerShell-Hosts
# Die f<EFBFBD>r dieses Modul mindestens erforderliche Version des Windows PowerShell-Hosts
# PowerShellHostVersion = ''
# Die für dieses Modul mindestens erforderliche Microsoft .NET Framework-Version
# Die f<EFBFBD>r dieses Modul mindestens erforderliche Microsoft .NET Framework-Version
# DotNetFrameworkVersion = ''
# Die für dieses Modul mindestens erforderliche Version der CLR (Common Language Runtime)
# Die f<EFBFBD>r dieses Modul mindestens erforderliche Version der CLR (Common Language Runtime)
# CLRVersion = ''
# Die für dieses Modul erforderliche Prozessorarchitektur ("Keine", "X86", "Amd64").
# Die f<EFBFBD>r dieses Modul erforderliche Prozessorarchitektur ("Keine", "X86", "Amd64").
# ProcessorArchitecture = ''
# Die Module, die vor dem Importieren dieses Moduls in die globale Umgebung geladen werden müssen
# RequiredModules = @()
# Die Module, die vor dem Importieren dieses Moduls in die globale Umgebung geladen werden m<EFBFBD>ssen
RequiredModules = @('VMware.VimAutomation.Cloud')
# Die Assemblys, die vor dem Importieren dieses Moduls geladen werden müssen
# Die Assemblys, die vor dem Importieren dieses Moduls geladen werden m<EFBFBD>ssen
# RequiredAssemblies = @()
# Die Skriptdateien (PS1-Dateien), die vor dem Importieren dieses Moduls in der Umgebung des Aufrufers ausgeführt werden.
# Die Skriptdateien (PS1-Dateien), die vor dem Importieren dieses Moduls in der Umgebung des Aufrufers ausgef<EFBFBD>hrt werden.
# ScriptsToProcess = @()
# Die Typdateien (.ps1xml), die beim Importieren dieses Moduls geladen werden sollen
@@ -63,14 +63,16 @@ Copyright = '(c) 2017 Markus. Alle Rechte vorbehalten.'
# FormatsToProcess = @()
# Die Module, die als geschachtelte Module des in "RootModule/ModuleToProcess" angegebenen Moduls importiert werden sollen.
NestedModules = @('functions\Invoke-MyOnBoarding.psm1',
NestedModules = @('functions\Invoke-MyOnBoarding.psm1',
'functions\New-MyEdgeGateway.psm1',
'functions\New-MyOrg.psm1',
'functions\New-MyOrgAdmin.psm1',
'functions\New-MyOrgVdc.psm1')
'functions\New-MyOrg.psm1',
'functions\New-MyOrgAdmin.psm1',
'functions\New-MyOrgVdc.psm1',
'functions\New-MyOrgNetwork.psm1'
)
# Aus diesem Modul zu exportierende Funktionen
FunctionsToExport = 'Invoke-MyOnBoarding', 'New-MyEdgeGateway', 'New-MyOrg', 'New-MyOrgAdmin', 'New-MyOrgVdc'
FunctionsToExport = 'Invoke-MyOnBoarding', 'New-MyEdgeGateway', 'New-MyOrg', 'New-MyOrgAdmin', 'New-MyOrgVdc', 'New-MyOrgNetwork'
# Aus diesem Modul zu exportierende Cmdlets
CmdletsToExport = '*'
@@ -90,28 +92,28 @@ AliasesToExport = '*'
# Liste aller Dateien in diesem Modulpaket
# FileList = @()
# Die privaten Daten, die an das in "RootModule/ModuleToProcess" angegebene Modul übergeben werden sollen. Diese können auch eine PSData-Hashtabelle mit zusätzlichen von PowerShell verwendeten Modulmetadaten enthalten.
# Die privaten Daten, die an das in "RootModule/ModuleToProcess" angegebene Modul <EFBFBD>bergeben werden sollen. Diese k<EFBFBD>nnen auch eine PSData-Hashtabelle mit zus<EFBFBD>tzlichen von PowerShell verwendeten Modulmetadaten enthalten.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
Tags = @('VMware', 'vCloud', 'PowerCLI', 'vCloudDirector', 'Automation', 'EdgeGateway', 'OrgNetwork')
# A URL to the license for this module.
# LicenseUri = ''
LicenseUri = 'https://github.com/mycloudrevolution/VMware-vCD-Module/blob/master/LICENSE'
# A URL to the main website for this project.
# ProjectUri = ''
ProjectUri = 'https://github.com/mycloudrevolution/VMware-vCD-Module'
# A URL to an icon representing this module.
# IconUri = ''
IconUri = 'https://github.com/mycloudrevolution/VMware-vCD-Module/blob/master/media/vCD_Small.png'
# ReleaseNotes of this module
# ReleaseNotes = ''
# External dependent modules of this module
# ExternalModuleDependencies = ''
ExternalModuleDependencies = 'VMware.VimAutomation.Cloud'
} # End of PSData hashtable
@@ -120,7 +122,7 @@ PrivateData = @{
# HelpInfo-URI dieses Moduls
# HelpInfoURI = ''
# Standardpräfix für Befehle, die aus diesem Modul exportiert werden. Das Standardpräfix kann mit "Import-Module -Prefix" überschrieben werden.
# Standardpr<EFBFBD>fix f<EFBFBD>r Befehle, die aus diesem Modul exportiert werden. Das Standardpr<EFBFBD>fix kann mit "Import-Module -Prefix" <EFBFBD>berschrieben werden.
# DefaultCommandPrefix = ''
}

View File

@@ -1,6 +1,4 @@
#Requires -Version 4
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
Function Invoke-MyOnBoarding {
Function Invoke-MyOnBoarding {
<#
.SYNOPSIS
Creates all vCD Objecst for a new IAAS Customer
@@ -158,18 +156,22 @@ Function Invoke-MyOnBoarding {
if ($Configs.OrgVdc.ExternalNetwork -and $Configs.OrgVdc.EdgeGateway -like "Yes"){
Write-Host "Edge Gateway for Org VDC '$($Configs.OrgVdc.Name)' Requested!"
$Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool `
$Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool `
-StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -Org $Configs.Org.Name -Enabled:$Enabled
$EdgeName = $Configs.Org.Name + "-ESG01"
$EdgeName = $Configs.Org.Name + "-ESG01"
$Trash = New-MyEdgeGateway -Name $EdgeName -OrgVDCName $Configs.OrgVdc.Name -Orgname $Configs.Org.Name -ExternalNetwork $Configs.OrgVdc.ExternalNetwork `
-IPAddress $Configs.OrgVdc.IPAddress -SubnetMask $Configs.OrgVdc.SubnetMask -Gateway $Configs.OrgVdc.Gateway -IPRangeStart $Configs.OrgVdc.IPRangeStart -IPRangeEnd $Configs.OrgVdc.IPRangeEnd
}
elseif ($Configs.OrgVdc.ExternalNetwork -and $Configs.OrgVdc.EdgeGateway -like "No"){
Write-Host "External Network for Org VDC '$($Configs.OrgVdc.Name)' Requested!"
elseif ($Configs.OrgVdc.ExternalNetwork -and $Configs.OrgVdc.EdgeGateway -like "No"){
$Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool `
-StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -ExternalNetwork $Configs.OrgVdc.ExternalNetwork -Org $Configs.Org.Name -Enabled:$Enabled
}
else {
Write-Host "No external Connection for Org VDC '$($Configs.OrgVdc.Name)' Requested!"
}
$Trash = New-PecOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $ProVdcNetworkPool.Name `
-StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -Org $Configs.Org.Name -Enabled:$Enabled
}
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc OK" -ForegroundColor Green
Get-OrgVdc -Org $Configs.Org.Name -Name $Configs.OrgVdc.Name | Select-Object Name, Enabled, CpuAllocationGhz, MemoryLimitGB, StorageLimitGB, AllocationModel, ThinProvisioned, UseFastProvisioning, `

View File

@@ -1,6 +1,4 @@
#Requires -Version 4
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
Function New-MyEdgeGateway {
Function New-MyEdgeGateway {
<#
.SYNOPSIS
Creates a new Edge Gateway with Default Parameters
@@ -9,7 +7,6 @@ Function New-MyEdgeGateway {
Creates a new Edge Gateway with Default Parameters
Default Parameters are:
* Size
* HA State
* DNS Relay
@@ -17,14 +14,14 @@ Function New-MyEdgeGateway {
.NOTES
File Name : New-MyEdgeGateway.ps1
Author : Markus Kraus
Version : 1.0
Version : 1.1
State : Ready
.LINK
https://mycloudrevolution.com/
.EXAMPLE
New-MyEdgeGateway -Name "TestEdge" -OrgVDCName "TestVDC" -OrgName "TestOrg" -ExternalNetwork "ExternalNetwork" -IPAddress "192.168.100.1" -SubnetMask "255.255.255.0" -Gateway "192.168.100.254" -IPRangeStart ""192.168.100.2" -IPRangeEnd ""192.168.100.3" -Verbose
New-MyEdgeGateway -Name "TestEdge" -OrgVDCName "TestVDC" -OrgName "TestOrg" -Size compact -ExternalNetwork "ExternalNetwork" -IPAddress "192.168.100.1" -SubnetMask "255.255.255.0" -Gateway "192.168.100.254" -IPRangeStart ""192.168.100.2" -IPRangeEnd ""192.168.100.3" -Verbose
.PARAMETER Name
Name of the New Edge Gateway as String
@@ -35,6 +32,9 @@ Function New-MyEdgeGateway {
.PARAMETER OrgName
Org where the new Edge Gateway should be created as string
.PARAMETER Size
Size of the new Edge Gateway as string
.PARAMETER ExternalNetwork
External Network of the new Edge Gateway as String
@@ -69,6 +69,10 @@ Function New-MyEdgeGateway {
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Org where the new Edge Gateway should be created as string")]
[ValidateNotNullorEmpty()]
[String] $OrgName,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Size of the new Edge Gateway as string")]
[ValidateNotNullorEmpty()]
[ValidateSet("compact","full")]
[String] $Size,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="External Network of the New Edge Gateway as String")]
[ValidateNotNullorEmpty()]
[String] $ExternalNetwork,
@@ -113,7 +117,7 @@ Function New-MyEdgeGateway {
$EdgeGateway.Name = $Name
$EdgeGateway.Configuration = New-Object VMware.VimAutomation.Cloud.Views.GatewayConfiguration
#$EdgeGateway.Configuration.BackwardCompatibilityMode = $false
$EdgeGateway.Configuration.GatewayBackingConfig = "compact"
$EdgeGateway.Configuration.GatewayBackingConfig = $Size
$EdgeGateway.Configuration.UseDefaultRouteForDnsRelay = $false
$EdgeGateway.Configuration.HaEnabled = $false

View File

@@ -1,6 +1,4 @@
#Requires -Version 4
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
Function New-MyOrg {
Function New-MyOrg {
<#
.SYNOPSIS
Creates a new vCD Org with Default Parameters

View File

@@ -1,6 +1,4 @@
#Requires -Version 4
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
Function New-MyOrgAdmin {
Function New-MyOrgAdmin {
<#
.SYNOPSIS
Creates a new vCD Org Admin with Default Parameters

View File

@@ -0,0 +1,166 @@
Function New-MyOrgNetwork {
<#
.SYNOPSIS
Creates a new Org Network with Default Parameters
.DESCRIPTION
.NOTES
File Name : New-MyOrgNetwork.ps1
Author : Markus Kraus
Version : 1.1
State : Ready
.LINK
https://mycloudrevolution.com
.EXAMPLE
New-MyOrgNetwork -Name Test -OrgVdcName "Test-OrgVDC" -OrgName "Test-Org" -EdgeName "Test-OrgEdge" -SubnetMask 255.255.255.0 -Gateway 192.168.66.1 -IPRangeStart 192.168.66.100 -IPRangeEnd 192.168.66.200
.EXAMPLE
New-MyOrgNetwork -Name Test -OrgVdcName "Test-OrgVDC" -OrgName "Test-Org" -EdgeName "Test-OrgEdge" -SubnetMask 255.255.255.0 -Gateway 192.168.66.1 -IPRangeStart 192.168.66.100 -IPRangeEnd 192.168.66.200 -Shared:$False
.EXAMPLE
$params = @{ 'Name' = 'Test';
'OrgVdcName'= 'Test-OrgVDC';
'OrgName'='Test-Org';
'EdgeName'='Test-OrgEdge';
'SubnetMask' = '255.255.255.0';
'Gateway' = '192.168.66.1';
'IPRangeStart' = '192.168.66.100';
'IPRangeEnd' = '192.168.66.200'
}
New-MyOrgNetwork @params -Verbose
.PARAMETER Name
Name of the New Org Network as String
.PARAMETER OrgVDCName
OrgVDC where the new Org Network should be created as string
.PARAMETER OrgName
Org where the newOrg Networkshould be created as string
.PARAMETER EdgeName
Edge Gateway Name for the new Org Network as String
.PARAMETER SubnetMask
Subnet Mask of the New Org Network as IP Address
.PARAMETER Gateway
Gateway of the New Org Network as IP Address
.PARAMETER IPRangeStart
IP Range Start of the New Org Network as IP Address
.PARAMETER IPRangeEnd
IP Range End of the New Org Network as IP Address
.PARAMETER Shared
Switch for Shared OrgVDC Network
Default: $True
.PARAMETER Timeout
Timeout for the Org Network to become Ready
Default: 120s
#>
Param (
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the New Org Network as String")]
[ValidateNotNullorEmpty()]
[String] $Name,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="OrgVDC where the new Org Network should be created as string")]
[ValidateNotNullorEmpty()]
[String] $OrgVdcName,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Org where the new Org Network should be created as string")]
[ValidateNotNullorEmpty()]
[String] $OrgName,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Edge Gateway Name for the new Org Network as String")]
[ValidateNotNullorEmpty()]
[String] $EdgeName,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Subnet Mask of the New Org Network as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $SubnetMask,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Gateway of the New Org Network as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $Gateway,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="IP Range Start the New Org Network as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $IPRangeStart,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="IP Range End the New Org Network as IP Address")]
[ValidateNotNullorEmpty()]
[IPAddress] $IPRangeEnd,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Switch for Shared OrgVDC Network")]
[ValidateNotNullorEmpty()]
[Bool] $Shared = $True,
[Parameter(Mandatory=$False, ValueFromPipeline=$False,HelpMessage="Timeout for the Org Network to become Ready")]
[ValidateNotNullorEmpty()]
[int] $Timeout = 120
)
Process {
## Get Org vDC
Write-Verbose "Get Org vDC"
[Array] $orgVdc = Get-Org -Name $OrgName | Get-OrgVdc -Name $OrgVdcName
if ( $orgVdc.Count -gt 1) {
throw "Multiple OrgVdcs found!"
}
elseif ( $orgVdc.Count -lt 1) {
throw "No OrgVdc found!"
}
$orgVdcView = $orgVdc| Get-CIView
## Get EdgeGateway
Write-Verbose "Get EdgeGateway"
[Array] $edgeGateway = Search-Cloud -QueryType EdgeGateway -Name $EdgeName | Get-CIView
if ( $edgeGateway.Count -gt 1) {
throw "Multiple EdgeGateways found!"
}
elseif ( $edgeGateway.Count -lt 1) {
throw "No EdgeGateway found!"
}
## Define Org Network
Write-Verbose "Define Org Network"
$OrgNetwork = new-object vmware.vimautomation.cloud.views.orgvdcnetwork
$OrgNetwork.name = $Name
$OrgNetwork.edgegateway = $edgeGateway.id
$OrgNetwork.isshared = $Shared
$OrgNetwork.configuration = new-object vmware.vimautomation.cloud.views.networkconfiguration
$OrgNetwork.configuration.fencemode = "natRouted"
$OrgNetwork.configuration.ipscopes = new-object vmware.vimautomation.cloud.views.ipscopes
$Scope = new-object vmware.vimautomation.cloud.views.ipScope
$Scope.gateway = $Gateway
$Scope.netmask = $SubnetMask
$Scope.ipranges = new-object vmware.vimautomation.cloud.views.ipranges
$Scope.ipranges.iprange = new-object vmware.vimautomation.cloud.views.iprange
$Scope.ipranges.iprange[0].startaddress = $IPRangeStart
$Scope.ipranges.iprange[0].endaddress = $IPRangeEnd
$OrgNetwork.configuration.ipscopes.ipscope += $Scope
## Create Org Network
Write-Verbose "Create Org Network"
$CreateOrgNetwork = $orgVdcView.CreateNetwork($OrgNetwork)
## Wait for Org Network to become Ready
Write-Verbose "Wait for Org Network to become Ready"
while(!(Get-OrgVdcNetwork -Id $CreateOrgNetwork.Id -ErrorAction SilentlyContinue)){
$i++
Start-Sleep 5
if($i -gt $Timeout) { Write-Error "Creating Org Network."; break}
Write-Progress -Activity "Creating Org Network" -Status "Wait for Network to become Ready..."
}
Write-Progress -Activity "Creating Org Network" -Completed
Start-Sleep 1
Get-OrgVdcNetwork -Id $CreateOrgNetwork.Id | Select-Object Name, OrgVdc, NetworkType, DefaultGateway, Netmask, StaticIPPool, @{ N='isShared'; E = {$_.ExtensionData.isShared} } | Format-Table -AutoSize
}
}

View File

@@ -1,6 +1,4 @@
#Requires -Version 4
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
Function New-MyOrgVdc {
Function New-MyOrgVdc {
<#
.SYNOPSIS
Creates a new vCD Org VDC with Default Parameters
@@ -9,7 +7,6 @@ Function New-MyOrgVdc {
Creates a new vCD Org VDC with Default Parameters
Default Parameters are:
* Allocation Model
* Network Quota
* VM Quota
* 'vCpu In Mhz'
@@ -20,27 +17,38 @@ Function New-MyOrgVdc {
.NOTES
File Name : New-MyOrgVdc.ps1
Author : Markus Kraus
Version : 1.2
Version : 1.3
State : Ready
.LINK
https://mycloudrevolution.com/
.EXAMPLE
New-MyOrgVdc -Name "TestVdc" -CPULimit 1000 -MEMLimit 1000 -StorageLimit 1000 -StorageProfile "Standard-DC01" -NetworkPool "NetworkPool-DC01" -ProviderVDC "Provider-VDC-DC01" -Org "TestOrg" -ExternalNetwork "External_OrgVdcNet"
New-MyOrgVdc -Name "TestVdc" -AllocationModel AllocationPool -CPULimit 1000 -MEMLimit 1000 -StorageLimit 1000 -StorageProfile "Standard-DC01" -NetworkPool "NetworkPool-DC01" -ProviderVDC "Provider-VDC-DC01" -Org "TestOrg" -ExternalNetwork "External_OrgVdcNet"
.EXAMPLE
New-MyOrgVdc -Name "TestVdc" -CPULimit 1000 -MEMLimit 1000 -StorageLimit 1000 -StorageProfile "Standard-DC01" -NetworkPool "NetworkPool-DC01" -ProviderVDC "Provider-VDC-DC01" -Org "TestOrg"
New-MyOrgVdc -Name "TestVdc" -AllocationModel AllocationVApp -StorageLimit 1000 -StorageProfile "Standard-DC01" -NetworkPool "NetworkPool-DC01" -ProviderVDC "Provider-VDC-DC01" -Org "TestOrg"
.PARAMETER Name
Name of the New Org VDC as String
.PARAMETER AllocationModel
Allocation Model of the New Org VDC as String
.PARAMETER CPULimit
CPU Limit (MHz) of the New Org VDC as String
Default: 0 (Unlimited)
Note: If AllocationModel is not AllocationVApp (Pay as you go), a limit needs to be set
.PARAMETER MEMLimit
Memory Limit (MB) of the New Org VDC as String
Default: 0 (Unlimited)
Note: If AllocationModel is not AllocationVApp (Pay as you go), a limit needs to be set
.PARAMETER StorageLimit
Storage Limit (MB) of the New Org VDC as String
@@ -76,12 +84,16 @@ Function New-MyOrgVdc {
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the New Org VDC as String")]
[ValidateNotNullorEmpty()]
[String] $Name,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="CPU Limit (MHz) of the New Org VDC as String")]
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Allocation Model of the New Org VDC as String")]
[ValidateNotNullorEmpty()]
[int] $CPULimit,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Memory Limit (MB) of the New Org VDC as String")]
[ValidateSet("AllocationPool","AllocationVApp")]
[String] $AllocationModel,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="CPU Limit (MHz) of the New Org VDC as String")]
[ValidateNotNullorEmpty()]
[int] $MEMLimit,
[int] $CPULimit = 0,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Memory Limit (MB) of the New Org VDC as String")]
[ValidateNotNullorEmpty()]
[int] $MEMLimit = 0,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Storage Limit (MB) of the New Org VDC as String")]
[ValidateNotNullorEmpty()]
[int] $StorageLimit,
@@ -117,7 +129,7 @@ Function New-MyOrgVdc {
$providerVdcRef = New-Object VMware.VimAutomation.Cloud.Views.Reference
$providerVdcRef.Href = $OrgVdcproviderVdc.Href
$adminVdc.ProviderVdcReference = $providerVdcRef
$adminVdc.AllocationModel = "AllocationPool"
$adminVdc.AllocationModel = $AllocationModel
$adminVdc.ComputeCapacity = New-Object VMware.VimAutomation.Cloud.Views.ComputeCapacity
$adminVdc.ComputeCapacity.Cpu = New-Object VMware.VimAutomation.Cloud.Views.CapacityWithUsage
$adminVdc.ComputeCapacity.Cpu.Units = "MHz"
@@ -132,8 +144,8 @@ Function New-MyOrgVdc {
$adminVdc.StorageCapacity.Limit = $StorageLimit
$adminVdc.NetworkQuota = 10
$adminVdc.VmQuota = 0
$adminVdc.VCpuInMhz = 1000
$adminVdc.VCpuInMhz2 = 1000
$adminVdc.VCpuInMhz = 2000
$adminVdc.VCpuInMhz2 = 2000
$adminVdc.UsesFastProvisioning = $false
$adminVdc.IsThinProvision = $true
@@ -143,20 +155,21 @@ Function New-MyOrgVdc {
$orgVdc = $orgED.CreateVdc($adminVdc)
## Wait for getting Ready
Write-Verbose "Wait for getting Ready"
Write-Verbose "Wait for OrgVdc getting Ready after creation"
$i = 0
while(($orgVdc = Get-OrgVdc -Name $Name -Verbose:$false).Status -eq "NotReady"){
$i++
Start-Sleep 2
if($i -gt $Timeout) { Write-Error "Creating Org Failed."; break}
Write-Progress -Activity "Creating Org" -Status "Wait for Org to become Ready..."
if($i -gt $Timeout) { Write-Error "Creating OrgVdc Failed."; break}
Write-Progress -Activity "Creating OrgVdc" -Status "Wait for OrgVdc to become Ready..."
}
Write-Progress -Activity "Creating Org" -Completed
Write-Progress -Activity "Creating OrgVdc" -Completed
Start-Sleep 2
## Search given Storage Profile
Write-Verbose "Search given Storage Profile"
$ProVdcStorageProfile = search-cloud -QueryType ProviderVdcStorageProfile -Name $StorageProfile | Get-CIView
$Filter = "ProviderVdc==" + $OrgVdcproviderVdc.Id
$ProVdcStorageProfile = search-cloud -QueryType ProviderVdcStorageProfile -Name $StorageProfile -Filter $Filter | Get-CIView
## Create Storage Profile Object with Settings
Write-Verbose "Create Storage Profile Object with Settings"
@@ -174,14 +187,14 @@ Function New-MyOrgVdc {
$orgVdc.ExtensionData.CreateVdcStorageProfile($UpdateParams)
## Wait for getting Ready
Write-Verbose "Wait for getting Ready"
Write-Verbose "Wait for OrgVdc getting Ready after update"
while(($orgVdc = Get-OrgVdc -Name $name -Verbose:$false).Status -eq "NotReady"){
$i++
Start-Sleep 1
if($i -gt $Timeout) { Write-Error "Update Org Failed."; break}
Write-Progress -Activity "Updating Org" -Status "Wait for Org to become Ready..."
if($i -gt $Timeout) { Write-Error "Update OrgVdc Failed."; break}
Write-Progress -Activity "Updating OrgVdc" -Status "Wait for OrgVdc to become Ready..."
}
Write-Progress -Activity "Updating Org" -Completed
Write-Progress -Activity "Updating OrgVdc" -Completed
Start-Sleep 1
## Search Any-StorageProfile

View File

@@ -0,0 +1,97 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Get-CSPAccessToken {
<#
.NOTES
===========================================================================
Created by: William Lam
Date: 07/23/2018
Organization: VMware
Blog: https://www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
Converts a Refresh Token from the VMware Console Services Portal
to CSP Access Token to access CSP API
.PARAMETER RefreshToken
The Refresh Token from the VMware Console Services Portal
.EXAMPLE
Get-CSPAccessToken -RefreshToken $RefreshToken
#>
Param (
[Parameter(Mandatory=$true)][String]$RefreshToken
)
$results = Invoke-WebRequest -Uri "https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/authorize" -Method POST -Headers @{accept='application/json'} -Body "refresh_token=$RefreshToken"
if($results.StatusCode -ne 200) {
Write-Host -ForegroundColor Red "Failed to retrieve Access Token, please ensure your VMC Refresh Token is valid and try again"
break
}
$accessToken = ($results | ConvertFrom-Json).access_token
Write-Host "CSP Auth Token has been successfully retrieved and saved to `$env:cspAuthToken"
$env:cspAuthToken = $accessToken
}
Function Get-CSPServices {
<#
.NOTES
===========================================================================
Created by: William Lam
Date: 07/23/2018
Organization: VMware
Blog: https://www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
Returns the list of CSP Services avialable for given user
.EXAMPLE
Get-CSPServices
#>
If (-Not $env:cspAuthToken) { Write-error "CSP Auth Token not found, please run Get-CSPAccessToken" } Else {
$results = Invoke-WebRequest -Uri "https://console.cloud.vmware.com/csp/gateway/slc/api/definitions?expand=1" -Method GET -ContentType "application/json" -UseBasicParsing -Headers @{"csp-auth-token"="$env:cspAuthToken"}
((($results.Content) | ConvertFrom-Json).results | where {$_.visible -eq $true}).displayName
}
}
Function Get-CSPRefreshTokenExpiry {
<#
.NOTES
===========================================================================
Created by: William Lam
Date: 01/10/2019
Organization: VMware
Blog: https://www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
Retrieve the expiry for a given CSP Refresh Token
.PARAMETER RefreshToken
Retrieve the expiry for a given CSP Refresh Token
.EXAMPLE
Get-CSPRefreshTokenExpiry -RefreshToken $RefreshToken
#>
Param (
[Parameter(Mandatory=$true)][String]$RefreshToken
)
$body = @{"tokenValue"="$RefreshToken"}
$json = $body | ConvertTo-Json
$results = Invoke-WebRequest -Uri "https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/details" -Method POST -ContentType "application/json" -UseBasicParsing -Body $json
$tokenDetails = (($results.Content) | ConvertFrom-Json)
$createDate = (Get-Date -Date "01/01/1970").AddMilliseconds($tokenDetails.createdAt).ToLocalTime()
$usedDate = (Get-Date -Date "01/01/1970").AddMilliseconds($tokenDetails.lastUsedAt).ToLocalTime()
$expiryDate = (Get-Date -Date "01/01/1970").AddMilliseconds($tokenDetails.expiresAt).ToLocalTime()
$tmp = [pscustomobject] @{
LastUsedDate = $usedDate;
CreatedDate = $createDate;
ExpiryDate = $expiryDate;
}
$tmp | Format-List
}

View File

@@ -0,0 +1,128 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
#
# Module manifest for module 'VMware.Community.CISTag'
#
# Generated by: Kyle Ruddy
#
# Generated on: 12/14/18
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'VMware.Community.CISTag.psm1'
# Version number of this module.
ModuleVersion = '1.0.0'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = 'a0803efd-6017-4049-bfc9-5983a5a0c348'
# Author of this module
Author = 'Kyle Ruddy'
# Company or vendor of this module
CompanyName = 'VMware'
# Copyright statement for this module
Copyright = '(c) VMware. All rights reserved.'
# Description of the functionality provided by this module
Description = 'Community sourced PowerShell Module for managing vSphere Tags via the CIS Endpoint'
# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '4.0'
# Name of the PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Get-CISTag', 'Get-CISTagCategory', 'Get-CISTagAssignment', 'New-CISTag', 'New-CISTagCategory', 'New-CISTagAssignment', 'Remove-CISTag', 'Remove-CISTagCategory', 'Remove-CISTagAssignment'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
# CmdletsToExport = '*'
# Variables to export from this module
# VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
# AliasesToExport = '*'
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

View File

@@ -0,0 +1,774 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
function Get-CISTag {
<#
.SYNOPSIS
Gathers tag information from the CIS REST API endpoint
.DESCRIPTION
Will provide a list of tags
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Name
Tag name which should be retreived
.PARAMETER Category
Tag category name which should be retreived
.PARAMETER Id
Tag ID which should be retreived
.EXAMPLE
Get-CISTag
Retreives all tag information
.EXAMPLE
Get-CISTag -Name tagName
Retreives the tag information based on the specified name
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')]
param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
[String]$Name,
[Parameter(Mandatory=$false,Position=1,ValueFromPipelineByPropertyName=$true)]
[String]$Category,
[Parameter(Mandatory=$false,Position=2,ValueFromPipelineByPropertyName=$true)]
[String]$Id
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag
if ($PSBoundParameters.ContainsKey("Id")) {
$tagOutput = $tagSvc.get($Id)
} else {
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
[Boolean]$vCenterConn = $true
$vCTagList = Get-Tag
} else {
$tagArray = @()
$tagIdList = $tagSvc.list() | Select-Object -ExpandProperty Value
[int]$counter = 1
foreach ($t in $tagIdList) {
$tagArray += $tagSvc.get($t)
$counter++
if ($counter -gt 200) {Start-Sleep -Milliseconds 1; $counter = 1}
}
}
if ($PSBoundParameters.ContainsKey("Name")) {
if ($vCenterConn){
$tagOutput = $vCTagList | Where-Object {$_.Name -eq $Name}
} else {$tagOutput = $tagArray | Where-Object {$_.Name -eq $Name}}
} elseif ($PSBoundParameters.ContainsKey("Category")) {
if ($vCenterConn){
$tagOutput = $vCTagList | Where-Object {$_.Category -eq $Category}
} else {
$tagCatid = Get-CISTagCategory -Name $Category | Select-Object -ExpandProperty Id
$tagIdList = $tagSvc.list_tags_for_category($tagCatid)
$tagArray2 = @()
foreach ($t in $tagIdList) {
$tagArray2 += $tagSvc.get($t)
}
$tagOutput = $tagArray2
}
} else {
if ($vCenterConn){$tagOutput = $vCTagList}
else {$tagOutput = $tagArray}
}
}
$tagOutput | Select-Object Id, Name, Description
}
}
function New-CISTag {
<#
.SYNOPSIS
Creates a new tag from the CIS REST API endpoint
.DESCRIPTION
Will create a new tag
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Name
Tag name which should be created
.PARAMETER Category
Category name where the new tag should be associated
.PARAMETER Description
Description for the new tag
.PARAMETER CategoryID
Category ID where the new tag should be associated
.EXAMPLE
New-CISTag -Name tagName -Category categoryName -Description "Tag Descrition"
Creates a new tag based on the specified name
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')]
param(
[Parameter(Mandatory=$true,Position=0)]
[String]$Name,
[Parameter(Mandatory=$false,Position=1)]
[String]$Category,
[Parameter(Mandatory=$false,Position=2)]
[String]$Description,
[Parameter(Mandatory=$false,Position=3)]
[String]$CategoryID
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag
$tagCreateHelper = $tagSvc.Help.create.create_spec.Create()
$tagCreateHelper.name = $Name
if ($PSBoundParameters.ContainsKey("Category")) {
$tagCreateHelper.category_id = Get-CISTagCategory -Name $Category | Select-Object -ExpandProperty Id
} elseif ($PSBoundParameters.ContainsKey("CategoryId")) {
$tagCreateHelper.category_id = $CategoryID
} else {Write-Warning "No Category input found. Add a Category name or ID."; break}
if ($PSBoundParameters.ContainsKey("Description")) {
$tagCreateHelper.description = $Description
} else {
$tagCreateHelper.description = ""
}
$tagNewId = $tagSvc.create($tagCreateHelper)
Get-CISTag -Id $tagNewId
}
}
function Remove-CISTag {
<#
.SYNOPSIS
Removes a tag from the CIS REST API endpoint
.DESCRIPTION
Will delete a new tag
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Name
Tag name which should be removed
.PARAMETER ID
Tag ID which should be removed
.EXAMPLE
Remove-CISTag -Name tagName
Removes a new tag based on the specified name
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
[String]$Name,
[Parameter(Mandatory=$false,Position=1,ValueFromPipelineByPropertyName=$true)]
[String]$ID
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag
if ($ID) {
$tagSvc.delete($ID)
} else {
$tagId = Get-CISTag -Name $Name | select -ExpandProperty Id
if ($tagId) {$tagSvc.delete($tagId)}
else {Write-Warning "No valid tag found."}
}
}
}
function Get-CISTagCategory {
<#
.SYNOPSIS
Gathers tag category information from the CIS REST API endpoint
.DESCRIPTION
Will provide a list of tag categories
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Name
Tag category name which should be retreived
.PARAMETER Id
Tag category ID which should be retreived
.EXAMPLE
Get-CISTagCategory
Retreives all tag category information
.EXAMPLE
Get-CISTagCategory -Name tagCategoryName
Retreives the tag category information based on the specified name
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')]
param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
[String]$Name,
[Parameter(Mandatory=$false,Position=2,ValueFromPipelineByPropertyName=$true)]
[String]$Id
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagCatSvc = Get-CisService -Name com.vmware.cis.tagging.category
if ($PSBoundParameters.ContainsKey("Id")) {
$tagCatOutput = $tagCatSvc.get($Id)
} else {
$tagCatArray = @()
$tagCatIdList = $tagCatSvc.list() | Select-Object -ExpandProperty Value
foreach ($tc in $tagCatIdList) {
$tagCatArray += $tagCatSvc.get($tc)
}
if ($PSBoundParameters.ContainsKey("Name")) {
$tagCatOutput = $tagCatArray | Where-Object {$_.Name -eq $Name}
} else {
$tagCatOutput = $tagCatArray
}
}
$tagCatOutput | Select-Object Id, Name, Description, Cardinality
}
}
function New-CISTagCategory {
<#
.SYNOPSIS
Creates a new tag category from the CIS REST API endpoint
.DESCRIPTION
Will create a new tag category
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Name
Tag category name which should be created
.PARAMETER Description
Tag category ID which should be retreived
.PARAMETER Cardinality
Tag category ID which should be retreived
.PARAMETER AssociableTypes
Tag category ID which should be retreived
.EXAMPLE
New-CISTagCategory -Name NewTagCategoryName -Description "New Tag Category Description" -Cardinality "Single" -AssociableTypes
Creates a new tag category with the specified information
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')]
param(
[Parameter(Mandatory=$true,Position=0)]
[String]$Name,
[Parameter(Mandatory=$false,Position=1)]
[String]$Description,
[Parameter(Mandatory=$false,Position=2)]
[ValidateSet("SINGLE","MULTIPLE")]
[String]$Cardinality = "SINGLE",
[Parameter(Mandatory=$false,Position=3)]
[ValidateSet("All", "Cluster", "Datacenter", "Datastore", "DatastoreCluster", "DistributedPortGroup", "DistributedSwitch", "Folder", "ResourcePool", "VApp", "VirtualPortGroup", "VirtualMachine", "VMHost")]
[String]$AssociableTypes = "All"
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagCatSvc = Get-CisService -Name com.vmware.cis.tagging.category
$tagCatCreateHelper = $tagCatSvc.Help.create.create_spec.Create()
$tagCatCreateHelper.name = $Name
if ($PSBoundParameters.ContainsKey("Description")) {
$tagCatCreateHelper.description = $Description
} else {$tagCatCreateHelper.description = ""}
$tagCatCreateHelper.cardinality = $Cardinality
$tagCatCreateAssocTypeHelper = $tagCatSvc.help.create.create_spec.associable_types.create()
$tagCatCreateAssocTypeHelper.Add($AssociableTypes)
$tagCatCreateHelper.associable_types = $tagCatCreateAssocTypeHelper
$tagCatNewId = $tagCatSvc.create($tagCatCreateHelper)
Get-CISTagCategory -Id $tagCatNewId
}
}
function Remove-CISTagCategory {
<#
.SYNOPSIS
Removes tag category information from the CIS REST API endpoint
.DESCRIPTION
Will remove a tag category
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Name
Tag category name which should be removed
.PARAMETER Id
Tag category ID which should be removed
.EXAMPLE
Remove-CISTagCategory -Name tagCategoryName
Removes the tag category information based on the specified name
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
[String]$Name,
[Parameter(Mandatory=$false,Position=2,ValueFromPipelineByPropertyName=$true)]
[String]$Id
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagCatSvc = Get-CisService -Name com.vmware.cis.tagging.category
if ($PSBoundParameters.ContainsKey("Id")) {
$tagCatSvc.delete($Id)
} elseif ($PSBoundParameters.ContainsKey("Name")) {
$tagCatId = Get-CISTagCategory -Name $Name | Select-Object -ExpandProperty Id
$tagCatSvc.delete($tagCatId)
} else {Write-Warning "No tag category found."}
}
}
function Get-CISTagAssignment {
<#
.SYNOPSIS
Displays a list of the tag assignments from the CIS REST API endpoint
.DESCRIPTION
Will provide a list of the tag assignments
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Category
Tag category name which should be referenced
.PARAMETER Entity
Object name which should be retreived
.PARAMETER ObjectId
Object ID which should be retreived
.EXAMPLE
Get-CISTagAssignment
Retreives all tag assignment information
.EXAMPLE
Get-CISTagAssignment -Entity VMName
Retreives all tag assignments for the VM name
.EXAMPLE
Get-CISTagAssignment -ObjectId 'vm-11'
Retreives all tag assignments for the VM object
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Low')]
param(
[Parameter(Mandatory=$false,Position=0)]
[String]$Category,
[Parameter(Mandatory=$false,Position=1)]
[String]$Entity,
[Parameter(Mandatory=$false,Position=2,ValueFromPipelineByPropertyName=$true)]
[String]$ObjectId
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagOutput = @()
[Boolean]$vCenterConn = $false
$tagAssocSvc = Get-CisService -Name com.vmware.cis.tagging.tag_association
if ($PSBoundParameters.ContainsKey("ObjectId")) {
if ($ObjectId.split('-')[0] -eq 'vm') {
$objType = "VirtualMachine"
} elseif ($ObjectId.Split('-')[0] -eq 'datastore') {
$objType = 'Datastore'
} else {Write-Warning 'Only VirtualMachine and Datastore types currently supported.'; break}
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $ObjectId
$objObject.type = $objType
$tagIdOutput = $tagAssocSvc.list_attached_tags($objObject)
} elseif ($PSBoundParameters.ContainsKey("Entity")) {
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
[Boolean]$vCenterConn = $true
$viObject = (Get-Inventory -Name $Entity).ExtensionData.MoRef
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $viObject.Value
$objObject.type = $viObject.type
} else {
$vmSvc = Get-CisService -Name com.vmware.vcenter.vm
$filterVmNameObj = $vmsvc.help.list.filter.create()
$filterVmNameObj.names.add($Entity) | Out-Null
$objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm
if ($objId) {$objType = "VirtualMachine"}
else {
$dsSvc = Get-CisService com.vmware.vcenter.datastore
$filterDsNameObj = $dsSvc.Help.list.filter.Create()
$filterDsNameObj.names.add($Entity) | Out-Null
$objId = $dsSvc.list($filterDsNameObj) | Select-Object -ExpandProperty datastore
if ($objId) {$objType = "Datastore"}
else {Write-Warning "No entities found."; break}
}
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $objId
$objObject.type = $objType
}
$tagIdOutput = $tagAssocSvc.list_attached_tags($objObject)
} else {
$tagSvc = Get-CisService -Name com.vmware.cis.tagging.tag
$tagIdOutput = @()
$tagCategories = Get-CISTagCategory | Sort-Object -Property Name
if ($Category) {
$tagCatId = $tagCategories | Where-Object {$_.Name -eq $Category} | Select-Object -ExpandProperty Id
$tagIdOutput += $tagSvc.list_tags_for_category($tagCatId)
} else {
foreach ($tagCat in $tagCategories) {
$tagIdOutput += $tagSvc.list_tags_for_category($tagCat.id)
}
}
}
$tagReference = Get-CISTag
if ($Entity -or $ObjectId) {
foreach ($tagId in $tagIdOutput) {
$tagAttObj = @()
if ($Entity) {
$tagAttObj += $tagAssocSvc.list_attached_objects($tagId) | Where-Object {$_.type -eq $viObject.type -and $_.id -eq $viObject.Value}
} else {
$tagAttObj += $tagAssocSvc.list_attached_objects($tagId) | Where-Object {$_.id -eq $ObjectId}
}
foreach ($obj in $tagAttObj) {
if ($obj.type -eq "VirtualMachine") {
if (-Not $vmSvc) {$vmSvc = Get-CisService -Name com.vmware.vcenter.vm}
$filterVmObj = $vmsvc.help.list.filter.create()
$filterVmObj.vms.add($obj.Id) | Out-Null
$objName = $vmSvc.list($filterVmObj) | Select-Object -ExpandProperty Name
} elseif ($obj.type -eq "Datastore") {
if (-Not $dsSvc) {$dsSvc = Get-CisService -Name com.vmware.vcenter.datastore}
$filterDsObj = $dsSvc.help.list.filter.create()
$filterDsObj.datastores.add($obj.Id) | Out-Null
$objName = $dsSvc.list($filterDsObj) | Select-Object -ExpandProperty Name
} else {$objName = 'Object Not Found'}
$tempObject = "" | Select-Object Tag, Entity
$tempObject.Tag = $tagReference | Where-Object {$_.id -eq $tagId} | Select-Object -ExpandProperty Name
$tempObject.Entity = $objName
$tagOutput += $tempObject
}
}
} else {
foreach ($tagId in $tagIdOutput) {
$tagAttObj = @()
$tagAttObj += $tagAssocSvc.list_attached_objects($tagId)
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
[Boolean]$vCenterConn = $true
} elseif ($tagAttObj.Type -contains "VirtualMachine") {
if (-Not $vmSvc) {$vmSvc = Get-CisService -Name com.vmware.vcenter.vm}
} elseif ($tagAttObj.Type -contains "Datastore") {
if (-Not $dsSvc) {$dsSvc = Get-CisService -Name com.vmware.vcenter.datastore}
}
foreach ($obj in $tagAttObj) {
if ($vCenterConn) {
$newViObj = New-Object -TypeName VMware.Vim.ManagedObjectReference
$newViObj.Type = $obj.type
$newViObj.Value = $obj.id
$objName = Get-View -Id $newViObj -Property Name | Select-Object -ExpandProperty Name
} elseif ($obj.type -eq "VirtualMachine") {
$filterVmObj = $vmsvc.help.list.filter.create()
$filterVmObj.vms.add($obj.Id) | Out-Null
$objName = $vmSvc.list($filterVmObj) | Select-Object -ExpandProperty Name
} elseif ($obj.type -eq "Datastore") {
$filterDsObj = $dsSvc.help.list.filter.create()
$filterDsObj.datastores.add($obj.Id) | Out-Null
$objName = $dsSvc.list($filterDsObj) | Select-Object -ExpandProperty Name
} else {$objName = 'Object Not Found'}
$tempObject = "" | Select-Object Tag, Entity
$tempObject.Tag = $tagReference | Where-Object {$_.id -eq $tagId} | Select-Object -ExpandProperty Name
$tempObject.Entity = $objName
$tagOutput += $tempObject
}
}
}
return $tagOutput
}
}
function New-CISTagAssignment {
<#
.SYNOPSIS
Creates new tag assignments from the CIS REST API endpoint
.DESCRIPTION
Will create new tag assignments
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Tag
Tag name which should be referenced
.PARAMETER Entity
Object name which should be retreived
.PARAMETER TagId
Tag ID/s which should be referenced
.PARAMETER ObjectId
Object ID which/s should be retreived
.EXAMPLE
New-CISTagAssignment -Tag TagName -Entity VMName
Creates a tag assignment between the Tag name and the VM name
.EXAMPLE
New-CISTagAssignment -TagId $tagId -ObjectId 'vm-11'
Creates a tag assignment between the Tag ID and the Object ID
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')]
param(
[Parameter(Mandatory=$false,Position=0)]
$Tag,
[Parameter(Mandatory=$false,Position=1)]
$Entity,
[Parameter(Mandatory=$false,Position=2)]
$TagId,
[Parameter(Mandatory=$false,Position=3)]
$ObjectId
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagAssocSvc = Get-CisService -Name com.vmware.cis.tagging.tag_association
if ($PSBoundParameters.ContainsKey("Tag") -and $PSBoundParameters.ContainsKey("Entity")) {
if ($Tag -is [array] -and $Entity -isnot [array]) {
$tagIdList = $tagAssocSvc.help.attach_multiple_tags_to_object.tag_ids.create()
foreach ($t in $Tag) {
$tempId = Get-CISTag -Name $t | Select-Object -ExpandProperty Id
$tagIdList.add($tempId) | Out-Null
}
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
$viObject = (Get-Inventory -Name $Entity).ExtensionData.MoRef
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $viObject.Value
$objObject.type = $viObject.type
} else {
if (-Not $vmSvc) {$vmSvc = Get-CisService -Name com.vmware.vcenter.vm}
$filterVmNameObj = $vmsvc.help.list.filter.create()
$filterVmNameObj.names.add($Entity) | Out-Null
$objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm
if ($objId) {$objType = "VirtualMachine"}
else {
if (-Not $dsSvc) {$dsSvc = Get-CisService -Name com.vmware.vcenter.datastore}
$filterDsNameObj = $dsSvc.Help.list.filter.Create()
$filterDsNameObj.names.add($Entity) | Out-Null
$objId = $dsSvc.list($filterDsNameObj) | Select-Object -ExpandProperty datastore
if ($objId) {$objType = "Datastore"}
else {Write-Warning "No entities found."; break}
}
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $objId
$objObject.type = $objType
}
$tagAssocSvc.attach_multiple_tags_to_object($objObject,$tagIdList) | Out-Null
} elseif ($Tag -isnot [array] -and $Entity -is [array]) {
$tagId = Get-CISTag -Name $Tag | Select-Object -ExpandProperty Id
$objList = $tagAssocSvc.help.attach_tag_to_multiple_objects.object_ids.create()
foreach ($e in $Entity) {
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
$viObject = (Get-Inventory -Name $e).ExtensionData.MoRef
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $viObject.Value
$objObject.type = $viObject.type
} else {
if (-Not $vmSvc) {$vmSvc = Get-CisService -Name com.vmware.vcenter.vm}
$filterVmNameObj = $vmsvc.help.list.filter.create()
$filterVmNameObj.names.add($Entity) | Out-Null
$objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm
if ($objId) {$objType = "VirtualMachine"}
else {
if (-Not $dsSvc) {$dsSvc = Get-CisService -Name com.vmware.vcenter.datastore}
$filterDsObj = $dsSvc.help.list.filter.create()
$filterDsObj.datastores.add($obj.Id) | Out-Null
$objId = $dsSvc.list($filterDsObj) | Select-Object -ExpandProperty Datastore
if ($objId) {$objType = "Datastore"}
else {Write-Warning "No entities found."; break}
}
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $objId
$objObject.type = $objType
}
$objList.add($objObject) | Out-Null
}
$tagAssocSvc.attach_tag_to_multiple_objects($TagId,$objList) | Out-Null
} elseif ($Tag -isnot [array] -and $Entity -isnot [array]) {
$tagId = Get-CISTag -Name $Tag | Select-Object -ExpandProperty Id
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
$viObject = (Get-Inventory -Name $Entity).ExtensionData.MoRef
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $viObject.Value
$objObject.type = $viObject.type
} else {
if (-Not $vmSvc) {$vmSvc = Get-CisService -Name com.vmware.vcenter.vm}
$filterVmNameObj = $vmsvc.help.list.filter.create()
$filterVmNameObj.names.add($Entity) | Out-Null
$objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm
if ($objId) {$objType = "VirtualMachine"}
else {
if (-Not $dsSvc) {$dsSvc = Get-CisService -Name com.vmware.vcenter.datastore}
$filterDsNameObj = $dsSvc.Help.list.filter.Create()
$filterDsNameObj.names.add($Entity) | Out-Null
$objId = $dsSvc.list($filterDsNameObj) | Select-Object -ExpandProperty datastore
if ($objId) {$objType = "Datastore"}
else {Write-Warning "No entities found."; break}
}
$objObject = $tagAssocSvc.help.list_attached_tags.object_id.create()
$objObject.id = $objId
$objObject.type = $objType
}
$tagAssocSvc.attach($TagId,$objObject) | Out-Null
}
} elseif ($PSBoundParameters.ContainsKey("TagId") -and $PSBoundParameters.ContainsKey("ObjectId")) {
if ($ObjectId.split('-')[0] -eq 'vm') {
$objType = "VirtualMachine"
} elseif ($ObjectId.Split('-')[0] -eq 'datastore') {
$objType = 'Datastore'
} else {Write-Warning 'Only VirtualMachine and Datastore types currently supported.'; break}
if ($TagId -is [array] -and $ObjectId -isnot [array]) {
$objObject = $tagAssocSvc.help.attach_multiple_tags_to_object.object_id.create()
$objObject.id = $ObjectId
$objObject.type = $objType
$tagIdList = $tagAssocSvc.help.attach_multiple_tags_to_object.tag_ids.create()
foreach ($tId in $TagId) {
$tagIdList.add($tId) | Out-Null
}
$tagAssocSvc.attach_multiple_tags_to_object($objObject,$tagIdList) | Out-Null
} elseif ($TagId -isnot [array] -and $ObjectId -is [array]) {
$objList = $tagAssocSvc.help.attach_tag_to_multiple_objects.object_ids.create()
foreach ($obj in $ObjectId) {
$objObject = $tagAssocSvc.help.attach_tag_to_multiple_objects.object_ids.element.create()
$objObject.id = $obj
$objObject.type = $objType
$objList.add($objObject) | Out-Null
}
$tagAssocSvc.attach_tag_to_multiple_objects($TagId,$objList) | Out-Null
} elseif ($TagId -isnot [array] -and $ObjectId -isnot [array]) {
$objObject = $tagAssocSvc.help.attach.object_id.create()
$objObject.id = $ObjectId
$objObject.type = $objType
$tagAssocSvc.attach($TagId,$objObject) | Out-Null
}
} else {Write-Output "Multiple tags with multiple objects are not a supported call."}
}
}
function Remove-CISTagAssignment {
<#
.SYNOPSIS
Removes a tag assignment from the CIS REST API endpoint
.DESCRIPTION
Will remove provided tag assignments
.NOTES
Author: Kyle Ruddy, @kmruddy
.PARAMETER Tag
Tag name which should be removed
.PARAMETER Entity
Object name which should be removed
.PARAMETER TagId
Tag ID/s which should be removed
.PARAMETER ObjectId
Object ID which/s should be removed
.EXAMPLE
Remove-CISTagAssignment -TagId $tagId -ObjectId 'vm-11'
Removes the tag assignment between the Tag ID and the Object ID
.EXAMPLE
Remove-CISTagAssignment -Tag TagName -Entity VMName
Removes the tag assignment between the Tag name and the Entity name
#>
[CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)]
$Tag,
[Parameter(Mandatory=$false,Position=1,ValueFromPipelineByPropertyName=$true)]
$Entity,
[Parameter(Mandatory=$false,Position=2)]
$TagId,
[Parameter(Mandatory=$false,Position=3)]
$ObjectId
)
If (-Not $global:DefaultCisServers) { Write-error "No CIS Connection found, please use the Connect-CisServer to connect" } Else {
$tagAssocSvc = Get-CisService -Name com.vmware.cis.tagging.tag_association
if ($PSBoundParameters.ContainsKey("Tag") -and $PSBoundParameters.ContainsKey("Entity")) {
if ($Tag -is [array] -and $Entity -isnot [array]) {
$tagIdList = $tagAssocSvc.help.detach_multiple_tags_from_object.tag_ids.create()
foreach ($t in $Tag) {
$tempId = Get-CISTag -Name $t | Select-Object -ExpandProperty Id
$tagIdList.add($tempId) | Out-Null
}
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
$viObject = (Get-Inventory -Name $Entity).ExtensionData.MoRef
$objObject = $tagAssocSvc.help.detach_multiple_tags_from_object.object_id.create()
$objObject.id = $viObject.Value
$objObject.type = $viObject.type
} else {
$vmSvc = Get-CisService -Name com.vmware.vcenter.vm
$filterVmNameObj = $vmsvc.help.list.filter.create()
$filterVmNameObj.names.add($Entity) | Out-Null
$objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm
if ($objId) {$objType = "VirtualMachine"}
else {
if (-Not $dsSvc) {$dsSvc = Get-CisService -Name com.vmware.vcenter.datastore}
$filterDsNameObj = $dsSvc.Help.list.filter.Create()
$filterDsNameObj.names.add($Entity) | Out-Null
$objId = $dsSvc.list($filterDsNameObj) | Select-Object -ExpandProperty datastore
if ($objId) {$objType = "Datastore"}
else {Write-Warning "No entities found."; break}
}
$objObject = $tagAssocSvc.help.detach_multiple_tags_from_object.object_id.create()
$objObject.id = $objId
$objObject.type = $objType
}
$tagAssocSvc.detach_multiple_tags_from_object($objObject,$tagIdList) | Out-Null
} elseif ($Tag -isnot [array] -and $Entity -is [array]) {
$tagId = Get-CISTag -Name $Tag | Select-Object -ExpandProperty Id
$objList = $tagAssocSvc.help.detach_tag_from_multiple_objects.object_ids.create()
foreach ($e in $Entity) {
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
$viObject = (Get-Inventory -Name $e).ExtensionData.MoRef
$objObject = $tagAssocSvc.help.detach_tag_from_multiple_objects.object_ids.element.create()
$objObject.id = $viObject.Value
$objObject.type = $viObject.type
} else {
$vmSvc = Get-CisService -Name com.vmware.vcenter.vm
$filterVmNameObj = $vmsvc.help.list.filter.create()
$filterVmNameObj.names.add($Entity) | Out-Null
$objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm
if ($objId) {$objType = "VirtualMachine"}
else {
if (-Not $dsSvc) {$dsSvc = Get-CisService -Name com.vmware.vcenter.datastore}
$filterDsNameObj = $dsSvc.Help.list.filter.Create()
$filterDsNameObj.names.add($Entity) | Out-Null
$objId = $dsSvc.list($filterDsNameObj) | Select-Object -ExpandProperty datastore
if ($objId) {$objType = "Datastore"}
else {Write-Warning "No entities found."; break}
}
$objObject = $tagAssocSvc.help.detach_tag_from_multiple_objects.object_ids.element.create()
$objObject.id = $objId
$objObject.type = $objType
}
$objList.add($objObject) | Out-Null
}
$tagAssocSvc.detach_tag_from_multiple_objects($TagId,$objList) | Out-Null
} elseif ($Tag -isnot [array] -and $Entity -isnot [array]) {
$tagId = Get-CISTag -Name $Tag | Select-Object -ExpandProperty Id
if ($global:DefaultVIServer -and $global:DefaultVIServer.Name -eq $global:DefaultCisServers.Name) {
$viObject = (Get-Inventory -Name $Entity).ExtensionData.MoRef
$objObject = $tagAssocSvc.help.detach.object_id.create()
$objObject.id = $viObject.Value
$objObject.type = $viObject.type
} else {
$vmSvc = Get-CisService -Name com.vmware.vcenter.vm
$filterVmNameObj = $vmsvc.help.list.filter.create()
$filterVmNameObj.names.add($Entity) | Out-Null
$objId = $vmSvc.list($filterVmNameObj) | Select-Object -ExpandProperty vm
if ($objId) {$objType = "VirtualMachine"}
else {
if (-Not $dsSvc) {$dsSvc = Get-CisService -Name com.vmware.vcenter.datastore}
$filterDsNameObj = $dsSvc.Help.list.filter.Create()
$filterDsNameObj.names.add($Entity) | Out-Null
$objId = $dsSvc.list($filterDsNameObj) | Select-Object -ExpandProperty datastore
if ($objId) {$objType = "Datastore"}
else {Write-Warning "No entities found."; break}
}
$objObject = $tagAssocSvc.help.detach.object_id.create()
$objObject.id = $objId
$objObject.type = $objType
}
$tagAssocSvc.detach($TagId,$objObject) | Out-Null
}
} elseif ($PSBoundParameters.ContainsKey("TagId") -and $PSBoundParameters.ContainsKey("ObjectId")) {
if ($ObjectId.split('-')[0] -eq 'vm') {
$objType = "VirtualMachine"
} elseif ($ObjectId.Split('-')[0] -eq 'datastore') {
$objType = 'Datastore'
}else {Write-Warning 'Only VirtualMachine types currently supported.'; break}
if ($TagId -is [array] -and $ObjectId -isnot [array]) {
$objObject = $tagAssocSvc.help.detach_multiple_tags_from_object.object_id.create()
$objObject.id = $ObjectId
$objObject.type = $objType
$tagIdList = $tagAssocSvc.help.detach_multiple_tags_from_object.tag_ids.create()
foreach ($tId in $TagId) {
$tagIdList.add($tId) | Out-Null
}
$tagAssocSvc.detach_multiple_tags_from_object($objObject,$tagIdList) | Out-Null
} elseif ($TagId -isnot [array] -and $ObjectId -is [array]) {
$objList = $tagAssocSvc.help.detach_tag_from_multiple_objects.object_ids.create()
foreach ($obj in $ObjectId) {
$objObject = $tagAssocSvc.help.detach_tag_from_multiple_objects.object_ids.element.create()
$objObject.id = $obj
$objObject.type = $objType
$objList.add($objObject) | Out-Null
}
$tagAssocSvc.detach_tag_from_multiple_objects($TagId,$objList) | Out-Null
} elseif ($TagId -isnot [array] -and $ObjectId -isnot [array]) {
$objObject = $tagAssocSvc.help.detach.object_id.create()
$objObject.id = $ObjectId
$objObject.type = $objType
$tagAssocSvc.detach($TagId,$objObject) | Out-Null
}
} else {Write-Output "Multiple tags with multiple objects are not a supported call."}
}
}

Binary file not shown.

View File

@@ -0,0 +1,260 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
Function Connect-DRaas {
<#
.NOTES
===========================================================================
Created by: William Lam
Date: 05/23/2019
Organization: VMware
Blog: http://www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.SYNOPSIS
This cmdlet creates $global:draasConnection object containing the DRaaS URL along with CSP Token Header
.DESCRIPTION
This cmdlet creates $global:draasConnection object containing the DRaaS URL along with CSP Token Header
.EXAMPLE
Connect-DRaaS -RefreshToken $RefreshToken -OrgName $OrgName -SDDCName $SDDCName
.NOTES
You must be logged into VMC using Connect-VmcServer cmdlet
#>
Param (
[Parameter(Mandatory=$true)][String]$RefreshToken,
[Parameter(Mandatory=$true)][String]$OrgName,
[Parameter(Mandatory=$true)][String]$SDDCName
)
If (-Not $global:DefaultVMCServers.IsConnected) { Write-error "No valid VMC Connection found, please use the Connect-VMC to connect"; break } Else {
$sddcService = Get-VmcService "com.vmware.vmc.orgs.sddcs"
$orgId = (Get-VMCOrg -Name $OrgName).Id
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
$sddc = $sddcService.get($orgId,$sddcId)
}
$results = Invoke-WebRequest -Uri "https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/authorize" -Method POST -Headers @{accept='application/json'} -Body "refresh_token=$RefreshToken"
if($results.StatusCode -ne 200) {
Write-Host -ForegroundColor Red "Failed to retrieve Access Token, please ensure your VMC Refresh Token is valid and try again"
break
}
$accessToken = ($results | ConvertFrom-Json).access_token
$headers = @{
"csp-auth-token"="$accessToken"
"Content-Type"="application/json"
"Accept"="application/json"
}
$global:draasConnection = new-object PSObject -Property @{
'Server' = "https://vmc.vmware.com/vmc/draas/api/orgs/$orgId/sddcs/$sddcId/site-recovery"
'headers' = $headers
}
$global:draasConnection
}
Function Get-DRaas {
<#
.NOTES
===========================================================================
Created by: William Lam
Date: 05/23/2019
Organization: VMware
Blog: http://www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.SYNOPSIS
Returns information about DRaaS configuration for a given SDDC
.DESCRIPTION
This cmdlet returns information about DRaaS configuration for a given SDDC. Can be used to monitor both activate and deactivate operations.
.EXAMPLE
Get-DRaas
#>
Param (
[Switch]$Troubleshoot
)
If (-Not $global:draasConnection) { Write-error "No DRaaS Connection found, please use Connect-DRaaS" } Else {
$method = "GET"
$draasUrl = $global:draasConnection.Server
$draasVersionUrl = $global:draasConnection.Server + "/versions"
if($Troubleshoot) {
Write-Host -ForegroundColor cyan "`n[DEBUG] - $METHOD`n$draasUrl`n"
}
try {
if($PSVersionTable.PSEdition -eq "Core") {
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers -SkipCertificateCheck
} else {
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers
}
} catch {
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
Write-Host -ForegroundColor Red "`nThe CSP session is no longer valid, please re-run the Connect-DRaaS cmdlet to retrieve a new token`n"
break
} else {
Write-Error "Error in retrieving DRaaS Information"
Write-Error "`n($_.Exception.Message)`n"
break
}
}
if($requests.StatusCode -eq 200) {
$json = ($requests.Content | ConvertFrom-Json)
$draasId = $json.id;
$draasState = $json.site_recovery_state;
$srmNode = $json.srm_node.ip_address;
$srmNodeState = $json.site_recovery_state;
$vrNode = $json.vr_node.ip_address;
$vrNodeState = $json.vr_node.state;
$draasUrl = $json.draas_h5_url;
if($srmNodeState -eq "ACTIVATED") {
if($Troubleshoot) {
Write-Host -ForegroundColor cyan "`n[DEBUG] - $METHOD`n$draasVersionUrl`n"
}
try {
if($PSVersionTable.PSEdition -eq "Core") {
$requests = Invoke-WebRequest -Uri $draasVersionUrl -Method $method -Headers $global:draasConnection.headers -SkipCertificateCheck
} else {
$requests = Invoke-WebRequest -Uri $draasVersionUrl -Method $method -Headers $global:draasConnection.headers
}
} catch {
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
Write-Host -ForegroundColor Red "`nThe CSP session is no longer valid, please re-run the Connect-DRaaS cmdlet to retrieve a new token`n"
break
} else {
Write-Error "Error in retrieving DRaaS Information"
Write-Error "`n($_.Exception.Message)`n"
break
}
}
if($requests.StatusCode -eq 200) {
$json = ($requests.Content | ConvertFrom-Json).node_versions
$srmVersion,$srmDescription = ($json | where {$_.node_ip -eq $srmNode}).full_version.split("`n")
$vrVersion,$vrDescription = ($json | where {$_.node_ip -eq $vrNode}).full_version.split("`n")
$results = [pscustomobject] @{
ID = $draasId;
DRaaSState = $draasState;
SRMNode = $srmNode;
SRMVersion = $srmVersion;
SRMNodeState = $srmNodeState;
VRNode = $vrNode;
VRVersion = $vrVersion;
VRNodeState = $vrNodeState;
DRaaSURL = $draasUrl;
}
$results
}
} elseif ($srmNodeState -eq "ACTIVATING" -or $srmNodeState -eq "DEACTIVATING") {
$results = [pscustomobject] @{
ID = $draasId;
DRaaSState = $draasState;
SRMNode = $srmNode;
SRMNodeState = $srmNodeState;
VRNode = $vrNode;
VRNodeState = $vrNodeState;
DRaaSURL = $draasUrl;
}
$results
} else {
Write-Host "`nDRaaS is currently deactivated, please run Set-DRaas -Activate`n"
}
} else {
Write-Host "`nDRaaS has not been activated before, please run Set-DRaas -Activate`n"
}
}
}
Function Set-DRaas {
<#
.NOTES
===========================================================================
Created by: William Lam
Date: 05/23/2019
Organization: VMware
Blog: http://www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.SYNOPSIS
Activate or deactivate DRaaS for a given SDDC
.DESCRIPTION
This cmdlet activates or deactivates DRaaS for a given SDDC
.EXAMPLE
Get-DRaas
#>
Param (
[Switch]$Activate,
[Switch]$Deactivate,
[Switch]$Troubleshoot
)
If (-Not $global:draasConnection) { Write-error "No DRaaS Connection found, please use Connect-DRaaS" } Else {
$draasUrl = $global:draasConnection.server
if($Activate) {
$method = "POST"
if($Troubleshoot) {
Write-Host -ForegroundColor cyan "`n[DEBUG] - $METHOD`n$draasUrl`n"
}
try {
if($PSVersionTable.PSEdition -eq "Core") {
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers -SkipCertificateCheck
} else {
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers
}
} catch {
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
Write-Host -ForegroundColor Red "`nThe CSP session is no longer valid, please re-run the Connect-DRaaS cmdlet to retrieve a new token`n"
break
} else {
Write-Error "Error in activating DRaaS"
Write-Error "`n($_.Exception.Message)`n"
break
}
}
Write-Host "`nActivating DRaaS, this will take some time and you can monitor the progress using Get-DRaaS or using the VMC Console UI`n"
} elseif ($Deactivate) {
$method = "DELETE"
if($Troubleshoot) {
Write-Host -ForegroundColor cyan "`n[DEBUG] - $METHOD`n$draasUrl`n"
}
try {
if($PSVersionTable.PSEdition -eq "Core") {
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers -SkipCertificateCheck
} else {
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers
}
} catch {
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
Write-Host -ForegroundColor Red "`nThe CSP session is no longer valid, please re-run the Connect-DRaaS cmdlet to retrieve a new token`n"
break
} else {
Write-Error "Error in deactivating DRaaS"
Write-Error "`n($_.Exception.Message)`n"
break
}
}
Write-Host "`nDeactivating DRaaS, this will take some time and you can monitor the progress using Get-DRaaS or the VMC Console UI`n"
} else {
Write-Error "Invalid Operation"
}
}
}

View File

@@ -0,0 +1,98 @@
<#
Copyright 2021 VMware, Inc.
SPDX-License-Identifier: BSD-2-Clause
#>
#
# Module manifest for module 'VMware.HCX'
#
# Generated by: wlam@vmware.com
#
# Generated on: 09/11/18
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'VMware.HCX.psm1'
# Version number of this module.
ModuleVersion = '1.0.2'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = '88898ed6-26e8-4dfa-a9de-10d3a12571de'
# Author of this module
Author = 'William Lam'
# Company or vendor of this module
CompanyName = 'VMware'
# Copyright statement for this module
Copyright = '(c) 2018 VMware. All rights reserved.'
# Description of the functionality provided by this module
Description = 'PowerShell Module for Managing Hybrid Cloud Extension (HCX) on VMware Cloud on AWS'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '6.0'
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Connect-HcxServer', 'Get-HcxCloudConfig', 'Get-HcxEndpoint', 'New-HcxMigration', 'Get-HcxMigration', 'Connect-HcxVAMI',
'Get-HcxVCConfig', 'Set-HcxLicense', 'Set-HcxVCConfig', 'Get-HcxNSXConfig', 'Set-HcxNSXConfig', 'Get-HcxCity', 'Get-HcxLocation', 'Set-HcxLocation',
'Get-HcxRoleMapping', 'Set-HcxRoleMapping', 'Get-HcxProxy', 'Set-HcxProxy', 'Remove-HcxProxy', 'Connect-HcxCloudServer', 'Get-HCXCloudActivationKey',
'Get-HCXCloudSubscription', 'New-HCXCloudActivationKey', 'Get-HCXCloud', 'Set-HCXCloud'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,97 @@
{
"Type": "AUTOMATED",
"Data": {
"Name": "LCFarmJson",
"DisplayName": "FarmJsonTest",
"AccessGroup": "Root",
"Description": "created LC Farm from PS via JSON with NVIDIA GRID VGPU",
"Enabled": null,
"Deleting": false,
"Settings": {
"DisconnectedSessionTimeoutPolicy": "NEVER",
"DisconnectedSessionTimeoutMinutes": 1,
"EmptySessionTimeoutPolicy": "AFTER",
"EmptySessionTimeoutMinutes": 1,
"LogoffAfterTimeout": false
},
"Desktop": null,
"DisplayProtocolSettings": {
"DefaultDisplayProtocol": "PCOIP",
"AllowDisplayProtocolOverride": false,
"EnableHTMLAccess": false,
"EnableCollaboration": false,
"EnableGRIDvGPUs": true,
"VGPUGridProfile": "grid_m10-8a"
},
"ServerErrorThreshold": null,
"MirageConfigurationOverrides": {
"OverrideGlobalSetting": false,
"Enabled": false,
"Url": null
}
},
"AutomatedFarmSpec": {
"ProvisioningType": "VIEW_COMPOSER",
"VirtualCenter": null,
"RdsServerNamingSpec": {
"NamingMethod": "PATTERN",
"PatternNamingSettings": {
"NamingPattern": "LCFarmVMPS",
"MaxNumberOfRDSServers": 1
}
},
"VirtualCenterProvisioningSettings": {
"EnableProvisioning": true,
"StopProvisioningOnError": true,
"MinReadyVMsOnVComposerMaintenance": 0,
"VirtualCenterProvisioningData": {
"ParentVm": "RDSServer",
"Snapshot": "RDS_SNAP1",
"Datacenter": null,
"VmFolder": "Praveen",
"HostOrCluster": "CS-1",
"ResourcePool": "CS-1"
},
"VirtualCenterStorageSettings": {
"Datastores": [
{
"Datastore": "Datastore1",
"StorageOvercommit": "UNBOUNDED"
}
],
"UseVSan": false,
"ViewComposerStorageSettings": {
"UseSeparateDatastoresReplicaAndOSDisks": false,
"ReplicaDiskDatastore": null,
"UseNativeSnapshots": false,
"SpaceReclamationSettings": {
"ReclaimVmDiskSpace": false,
"ReclamationThresholdGB": null,
"BlackoutTimes": null
}
}
},
"VirtualCenterNetworkingSettings": {
"Nics": null
}
},
"VirtualCenterManagedCommonSettings": {
"TransparentPageSharingScope": "VM"
},
"CustomizationSettings": {
"CustomizationType": "SYS_PREP",
"DomainAdministrator": null,
"AdContainer": "CN=Computers",
"ReusePreExistingAccounts": false,
"SysprepCustomizationSettings": {
"CustomizationSpec": "PraveenCust"
}
},
"RdsServerMaxSessionsData": {
"MaxSessionsType": "UNLIMITED",
"MaxSessions": null
}
},
"ManualFarmSpec": null,
"NetBiosName": "adviewdev"
}

View File

@@ -1,4 +1,4 @@
Prerequisites/Steps to use this module:
# Prerequisites/Steps to use this module
1. This module only works for Horizon product E.g. Horizon 7.0.2 and later.
2. Install the latest version of Powershell, PowerCLI(6.5) or (later version via psgallery).
@@ -6,15 +6,24 @@ Prerequisites/Steps to use this module:
4. Import "VMware.Hv.Helper" module by running: Import-Module -Name "location of this module" or Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module.
5. Get-Command -Module "This module Name" to list all available functions or Get-Command -Module 'VMware.Hv.Helper'.
# Example script to connect view API service of Connection Server:
# Example script to connect ViewAPI service
```
Import-Module VMware.VimAutomation.HorizonView
# Connection to view API service
$hvServer = Connect-HVServer -server <connection server IP/FQDN>
$hvServices = $hvserver.ExtensionData
# List Connection Servers
$csList = $hvServices.ConnectionServer.ConnectionServer_List()
```
# Load this module
```
Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module
Get-Command -Module 'VMware.Hv.Helper'
```
# Use advanced functions of this module
```
New-HVPool -spec 'path to InstantClone.json file'
```

View File

@@ -12,7 +12,7 @@
# RootModule = ''
# Version number of this module.
ModuleVersion = '1.1'
ModuleVersion = '1.3.1'
# ID used to uniquely identify this module
GUID = '6d3f7fb5-4e52-43d8-91e1-f65f72532a1d'

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,188 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Add-HVDesktop
## SYNOPSIS
Adds virtual machine to existing pool
## SYNTAX
```
Add-HVDesktop [-PoolName] <String> [-Machines] <String[]> [[-Users] <String[]>] [[-Vcenter] <String>]
[[-HvServer] <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
The Add-HVDesktop adds virtual machines to already exiting pools by using view API service object(hvServer) of Connect-HVServer cmdlet.
VMs can be added to any of unmanaged manual, managed manual or Specified name.
This advanced function do basic checks for pool and view API service connection existance, hvServer object is bound to specific connection server.
## EXAMPLES
### EXAMPLE 1
```
Add-HVDesktop -PoolName 'ManualPool' -Machines 'manualPool1', 'manualPool2' -Confirm:$false
```
Add managed manual VMs to existing manual pool
### EXAMPLE 2
```
Add-HVDesktop -PoolName 'SpecificNamed' -Machines 'vm-01', 'vm-02' -Users 'user1', 'user2'
```
Add virtual machines to automated specific named dedicated pool
### EXAMPLE 3
```
Add-HVDesktop -PoolName 'SpecificNamed' -Machines 'vm-03', 'vm-04'
```
Add machines to automated specific named Floating pool
### EXAMPLE 4
```
Add-HVDesktop -PoolName 'Unmanaged' -Machines 'desktop-1.eng.vmware.com'
```
Add machines to unmanged manual pool
## PARAMETERS
### -PoolName
Pool name to which new VMs are to be added.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Machines
List of virtual machine names which need to be added to the given pool.
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Users
List of virtual machine users for given machines.
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Vcenter
Virtual Center server-address (IP or FQDN) of the given pool.
This should be same as provided to the Connection Server while adding the vCenter server.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
View API service object of Connect-HVServer cmdlet.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
| Dependencies | Make sure pool already exists before adding VMs to it. |
### Tested Against Environment
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,138 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Add-HVRDSServer
## SYNOPSIS
Add RDS Servers to an existing farm.
## SYNTAX
```
Add-HVRDSServer [-FarmName] <Object> [-RdsServers] <String[]> [[-HvServer] <Object>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```
## DESCRIPTION
The Add-HVRDSServer adds RDS Servers to already exiting farms by using view API service object(hvServer) of Connect-HVServer cmdlet.
We can add RDSServers to manual farm type only.
This advanced function do basic checks for farm and view API service connection existance.
This hvServer is bound to specific connection server.
## EXAMPLES
### EXAMPLE 1
```
Add-HVRDSServer -Farm "manualFarmTest" -RdsServers "vm-for-rds","vm-for-rds-2" -Confirm:$false
```
Add RDSServers to manual farm
## PARAMETERS
### -FarmName
farm name to which new RDSServers are to be added.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -RdsServers
RDS servers names which need to be added to the given farm.
Provide a comma separated list for multiple names.
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
View API service object of Connect-HVServer cmdlet.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### None
## NOTES
| | |
|-|-|
| Author | praveen mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
| Dependencies | Make sure farm already exists before adding RDSServers to it. |
### Tested Against Environment
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,100 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Clear-HVEventDatabase
## SYNOPSIS
Clears configurationof the configured Event Database
## SYNTAX
```
Clear-HVEventDatabase [[-HvServer] <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Clears configurationof the configured Event Database
## EXAMPLES
### EXAMPLE 1
```
Clear-HVEventDatabase
```
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.4 |
| PowerCLI Version | PowerCLI 10 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,127 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Connect-HVEvent
## SYNOPSIS
This function is used to connect to the event database configured on Connection Server.
## SYNTAX
```
Connect-HVEvent [[-DbPassword] <SecureString>] [[-HvServer] <Object>] [[-DbUserName] <String>]
[<CommonParameters>]
```
## DESCRIPTION
This function queries the specified Connection Server for event database configuration and returns the connection object to it.
If event database is not configured on specified connection server, it will return null.
Currently, Horizon 7 is supporting SQL server and Oracle 12c as event database servers.
To configure event database, goto 'Event Database Configuration' tab in Horizon admin UI.
## EXAMPLES
### EXAMPLE 1
```
Connect-HVEvent -HvServer $hvServer
```
Connecting to the database with default username configured on Connection Server $hvServer.
### EXAMPLE 2
```
$hvDbServer = Connect-HVEvent -HvServer $hvServer -DbUserName 'system'
```
Connecting to the database configured on Connection Server $hvServer with customised user name 'system'.
### EXAMPLE 3
```
$hvDbServer = Connect-HVEvent -HvServer $hvServer -DbUserName 'system' -DbPassword 'censored'
```
Connecting to the database with customised user name and password.
### EXAMPLE 4
```
$password = Read-Host 'Database Password' -AsSecureString
```
$hvDbServer = Connect-HVEvent -HvServer $hvServer -DbUserName 'system' -DbPassword $password
Connecting to the database with customised user name and password, with password being a SecureString.
## PARAMETERS
### -DbPassword
Password corresponds to 'dbUserName' user.
```yaml
Type: SecureString
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
View API service object of Connect-HVServer cmdlet.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -DbUserName
User name to be used in database connection.
If not passed, default database user name on the Connection Server will be used.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns a custom object that has database connection as 'dbConnection' property.
## NOTES
| | |
|-|-|
| Author | Paramesh Oddepally. |
| Author email | poddepally@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,71 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Disconnect-HVEvent
## SYNOPSIS
This function is used to disconnect the database connection.
## SYNTAX
```
Disconnect-HVEvent [-HvDbServer] <PSObject> [<CommonParameters>]
```
## DESCRIPTION
This function will disconnect the database connection made earlier during Connect-HVEvent function.
## EXAMPLES
### EXAMPLE 1
```
Disconnect-HVEvent -HvDbServer $hvDbServer
```
Disconnecting the database connection on $hvDbServer.
## PARAMETERS
### -HvDbServer
Connection object returned by Connect-HVEvent advanced function.
This is a mandatory input.
```yaml
Type: PSObject
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### None
## NOTES
| | |
|-|-|
| Author | Paramesh Oddepally. |
| Author email | poddepally@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,110 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVApplication
## SYNOPSIS
Gets the application information.
## SYNTAX
```
Get-HVApplication [[-ApplicationName] <String>] [[-HvServer] <Object>] [[-FormatList] <String>]
[<CommonParameters>]
```
## DESCRIPTION
Gets the application information.
This will be useful to find out whether the specified application exists or not.
If the application name is not specified, this will lists all the applications in the Pod.
## EXAMPLES
### EXAMPLE 1
```
Get-HVApplication -ApplicationName 'App1' -HvServer $HvServer
```
Queries and returns 'App1' information.
### EXAMPLE 2
```
Get-HVApplication -HvServer $HvServer -FormatList:$True
```
Lists all the applications in the Pod.
## PARAMETERS
### -ApplicationName
Name of the application.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -HvServer
View API service object of Connect-HVServer cmdlet.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -FormatList
Displays the list of the available applications in Table Format if this parameter is set to True.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns the information of the specified application if it specified, else displays all the available applications.
## NOTES
| | |
|-|-|
| Author | Samiullasha S |
| Author email | ssami@vmware.com |
| Version | 1.2 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.8.0 |
| PowerCLI Version | PowerCLI 11.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,143 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVBaseImageVM
## SYNOPSIS
Gets a list of compatible base image virtual machines.
## SYNTAX
### Type (Default)
```
Get-HVBaseImageVM [-HvServer <Object>] [-VirtualCenter <Object>] [-Type <Object>] [<CommonParameters>]
```
### Name
```
Get-HVBaseImageVM [-HvServer <Object>] [-VirtualCenter <Object>] [-Name <String>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns BaseImageVmInfo for the specified vCenter Server.
## EXAMPLES
### EXAMPLE 1
```
Get-HVBaseImageVM -VirtualCenter 'vCenter1' -Type VDI
```
### EXAMPLE 2
```
Get-HVBaseImageVM -VirtualCenter $vCenter1 -Type ALL
```
### EXAMPLE 3
```
Get-HVBaseImageVM -Name '*WIN10*'
```
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in place of hvServer.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VirtualCenter
A parameter to specify which vCenter Server to check base image VMs for.
It can be specified as a String,
containing the name of the vCenter, or as a vCenter object as returned by Get-HVvCenterServer.
If the value is
not passed or null then first element returned from Get-HVvCenterServer would be considered in place of VirtualCenter.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Type
A parameter to define the type of compatability to check the base image VM list against.
Valid options are 'VDI', 'RDS', or 'ALL'
'VDI' will return all desktop compatible Base Image VMs.
'RDS' will return all RDSH compatible Base Image VMs.
'ALL' will return all Base Image VMs, regardless of compatibility.
The default value is 'ALL'.
```yaml
Type: Object
Parameter Sets: Type
Aliases:
Required: False
Position: Named
Default value: VDI
Accept pipeline input: False
Accept wildcard characters: False
```
### -Name
The name of a virtual machine (if known), to filter Base Image VMs on.
Wildcards are accepted.
If Name is specified, then Type
is not considered for filtering.
```yaml
Type: String
Parameter Sets: Name
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns array of object type VMware.Hv.BaseImageVmInfo
## NOTES
| | |
|-|-|
| Author | Matt Frey. |
| Author email | mfrey@vmware.com |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.7 |
| PowerCLI Version | PowerCLI 11.2.0 |
| PowerShell Version | 5.1 |
## RELATED LINKS

View File

@@ -0,0 +1,154 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVEntitlement
## SYNOPSIS
Gets association data between a user/group and a resource
## SYNTAX
```
Get-HVEntitlement [[-User] <String>] [[-Type] <String>] [[-ResourceName] <String>] [[-ResourceType] <String>]
[[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Provides entitlement Info between a single user/group and a resource that they can be assigned.
## EXAMPLES
### EXAMPLE 1
```
Get-HVEntitlement -ResourceType Application
```
Gets all the entitlements related to application pool
### EXAMPLE 2
```
Get-HVEntitlement -User 'adviewdev.eng.vmware.com\administrator' -ResourceName 'calculator' -ResourceType Application
```
Gets entitlements specific to user or group name and application resource
### EXAMPLE 3
```
Get-HVEntitlement -User 'adviewdev.eng.vmware.com\administrator' -ResourceName 'UrlSetting1' -ResourceType URLRedirection
```
Gets entitlements specific to user or group and URLRedirection resource
### EXAMPLE 4
```
Get-HVEntitlement -User 'administrator@adviewdev.eng.vmware.com' -ResourceName 'GE1' -ResourceType GlobalEntitlement
```
Gets entitlements specific to user or group and GlobalEntitlement resource
## PARAMETERS
### -User
User principal name of user or group
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Type
Whether or not this is a group or a user.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: User
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceName
The resource(Application, Desktop etc.) name.
Supports only wildcard character '*' when resource type is desktop.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceType
Type of Resource(Application, Desktop etc.)
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: Desktop
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,201 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVEvent
## SYNOPSIS
Queries the events from event database configured on Connection Server.
## SYNTAX
```
Get-HVEvent [-HvDbServer] <PSObject> [[-TimePeriod] <String>] [[-FilterType] <String>] [[-UserFilter] <String>]
[[-SeverityFilter] <String>] [[-TimeFilter] <String>] [[-ModuleFilter] <String>] [[-MessageFilter] <String>]
[<CommonParameters>]
```
## DESCRIPTION
This function is used to query the events information from event database.
It returns the object that has events in five columns as UserName, Severity, EventTime, Module and Message.
EventTime will show the exact time when the event got registered in the database and it follows timezone on database server.
User can apply different filters on the event columns using the filter parameters userFilter, severityFilter, timeFilter, moduleFilter, messageFilter.
Mention that when multiple filters are provided then rows which satisify all the filters will be returned.
## EXAMPLES
### EXAMPLE 1
```
$e = Get-HVEvent -hvDbServer $hvDbServer
```
$e.Events
Querying all the database events on database $hvDbServer.
### EXAMPLE 2
```
$e = Get-HVEvent -HvDbServer $hvDbServer -TimePeriod 'all' -FilterType 'startsWith' -UserFilter 'aduser' -SeverityFilter 'err' -TimeFilter 'HH:MM:SS.fff' -ModuleFilter 'broker' -MessageFilter 'aduser'
```
$e.Events | Export-Csv -Path 'myEvents.csv' -NoTypeInformation
Querying all the database events where user name startswith 'aduser', severity is of 'err' type, having module name as 'broker', message starting with 'aduser' and time starting with 'HH:MM:SS.fff'.
The resulting events will be exported to a csv file 'myEvents.csv'.
## PARAMETERS
### -HvDbServer
Connection object returned by Connect-HVEvent advanced function.
```yaml
Type: PSObject
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -TimePeriod
Timeperiod of the events that user is interested in.
It can take following four values:
'day' - Lists last one day events from database
'week' - Lists last 7 days events from database
'month' - Lists last 30 days events from database
'all' - Lists all the events stored in database
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: All
Accept pipeline input: False
Accept wildcard characters: False
```
### -FilterType
Type of filter action to be applied.
The parameters userfilter, severityfilter, timefilter, modulefilter, messagefilter can be used along with this.
It can take following values:
'contains' - Retrieves the events that contains the string specified in filter parameters
'startsWith' - Retrieves the events that starts with the string specified in filter parameters
'isExactly' - Retrieves the events that exactly match with the string specified in filter parameters
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: Contains
Accept pipeline input: False
Accept wildcard characters: False
```
### -UserFilter
String that can applied in filtering on 'UserName' column.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SeverityFilter
String that can applied in filtering on 'Severity' column.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -TimeFilter
String that can applied in filtering on 'EventTime' column.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ModuleFilter
String that can applied in filtering on 'Module' column.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -MessageFilter
String that can applied in filtering on 'Message' column.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns a custom object that has events information in 'Events' property. Events property will have events information with five columns: UserName, Severity, EventTime, Module and Message.
## NOTES
| | |
|-|-|
| Author | Paramesh Oddepally. |
| Author email | poddepally@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,69 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVEventDatabase
## SYNOPSIS
Retreives information about the configured Event Database
## SYNTAX
```
Get-HVEventDatabase [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Collects information about the configured event database for aHorizon View pod
## EXAMPLES
### EXAMPLE 1
```
Get-HVEventDatabase
```
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.4 |
| PowerCLI Version | PowerCLI 10 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,179 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVFarm
## SYNOPSIS
This function is used to find farms based on the search criteria provided by the user.
## SYNTAX
```
Get-HVFarm [[-FarmName] <String>] [[-FarmDisplayName] <String>] [[-FarmType] <String>] [[-Enabled] <Boolean>]
[[-SuppressInfo] <Boolean>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
This function queries the specified Connection Server for farms which are configured on the server.
If no farm is configured on the specified connection server or no farm matches the given search criteria, it will return null.
## EXAMPLES
### EXAMPLE 1
```
Get-HVFarm -FarmName 'Farm-01'
```
Queries and returns farmInfo based on given parameter farmName
### EXAMPLE 2
```
Get-HVFarm -FarmName 'Farm-01' -FarmDisplayName 'Sales RDS Farm'
```
Queries and returns farmInfo based on given parameters farmName, farmDisplayName
### EXAMPLE 3
```
Get-HVFarm -FarmName 'Farm-01' -FarmType 'MANUAL'
```
Queries and returns farmInfo based on given parameters farmName, farmType
### EXAMPLE 4
```
Get-HVFarm -FarmName 'Farm-01' -FarmType 'MANUAL' -Enabled $true
```
Queries and returns farmInfo based on given parameters farmName, FarmType etc
### EXAMPLE 5
```
Get-HVFarm -FarmName 'Farm-0*'
```
Queries and returns farmInfo based on parameter farmName with wild character *
## PARAMETERS
### -FarmName
farmName to be searched
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FarmDisplayName
farmDisplayName to be searched
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FarmType
farmType to be searched.
It can take following values:
"AUTOMATED" - search for automated farms only
'MANUAL' - search for manual farms only
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Enabled
search for farms which are enabled
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -SuppressInfo
Suppress text info, when no farm found with given search parameters
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the data from.
If the value is not passed or null then first element from global:DefaultHVServers would be considered in-place of hvServer.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns the list of FarmInfo object matching the query criteria.
## NOTES
| | |
|-|-|
| Author | praveen mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,179 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVFarmSummary
## SYNOPSIS
This function is used to find farms based on the search criteria provided by the user.
## SYNTAX
```
Get-HVFarmSummary [[-FarmName] <String>] [[-FarmDisplayName] <String>] [[-FarmType] <String>]
[[-Enabled] <Boolean>] [[-SuppressInfo] <Boolean>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
This function queries the specified Connection Server for farms which are configured on the server.
If no farm is configured on the specified connection server or no farm matches the given search criteria, it will return null.
## EXAMPLES
### EXAMPLE 1
```
Get-HVFarmSummary -FarmName 'Farm-01'
```
Queries and returns farmSummary objects based on given parameter farmName
### EXAMPLE 2
```
Get-HVFarmSummary -FarmName 'Farm-01' -FarmDisplayName 'Sales RDS Farm'
```
Queries and returns farmSummary objects based on given parameters farmName, farmDisplayName
### EXAMPLE 3
```
Get-HVFarmSummary -FarmName 'Farm-01' -FarmType 'MANUAL'
```
Queries and returns farmSummary objects based on given parameters farmName, farmType
### EXAMPLE 4
```
Get-HVFarmSummary -FarmName 'Farm-01' -FarmType 'MANUAL' -Enabled $true
```
Queries and returns farmSummary objects based on given parameters farmName, FarmType etc
### EXAMPLE 5
```
Get-HVFarmSummary -FarmName 'Farm-0*'
```
Queries and returns farmSummary objects based on given parameter farmName with wild character *
## PARAMETERS
### -FarmName
FarmName to be searched
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FarmDisplayName
FarmDisplayName to be searched
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -FarmType
FarmType to be searched.
It can take following values:
"AUTOMATED" - search for automated farms only
'MANUAL' - search for manual farms only
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Enabled
Search for farms which are enabled
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -SuppressInfo
Suppress text info, when no farm found with given search parameters
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the data from.
If the value is not passed or null then first element from global:DefaultHVServers would be considered in-place of hvServer.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns the list of FarmSummary object matching the query criteria.
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,118 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVGlobalEntitlement
## SYNOPSIS
Gets Global Entitlement(s) with given search parameters.
## SYNTAX
```
Get-HVGlobalEntitlement [[-DisplayName] <String>] [[-Description] <String>] [[-SuppressInfo] <Boolean>]
[[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns global entitlement(s) and global application entitlement(s).
Global entitlements are used to route users to their resources across multiple pods.
## EXAMPLES
### EXAMPLE 1
```
Get-HVGlobalEntitlement -DisplayName 'GEAPP'
```
Retrieves global application/desktop entitlement(s) with displayName 'GEAPP'
## PARAMETERS
### -DisplayName
Display Name of Global Entitlement.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Description
Description of Global Entitlement.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SuppressInfo
Suppress text info, when no global entitlement(s) found with given search parameters
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,69 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVGlobalSession
## SYNOPSIS
Provides a list with all Global sessions in a Cloud Pod Architecture
## SYNTAX
```
Get-HVGlobalSession [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
The get-hvglobalsession gets all local session by using view API service object(hvServer) of Connect-HVServer cmdlet.
## EXAMPLES
### EXAMPLE 1
```
Get-hvglobalsession
```
Gets all global sessions
## PARAMETERS
### -HvServer
View API service object of Connect-HVServer cmdlet.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten. |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0, 7.3.2 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,70 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVGlobalSettings
## SYNOPSIS
Gets a list of Global Settings
## SYNTAX
```
Get-HVGlobalSettings [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns the Global Settings for the pod of the specified HVServer.
## EXAMPLES
### EXAMPLE 1
```
Get-HVGlobalSettings
```
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered inplace of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns list of object type VMware.Hv.GlobalSettingsInfo
## NOTES
| | |
|-|-|
| Author | Matt Frey. |
| Author email | mfrey@vmware.com |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.1 |
| PowerCLI Version | PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,95 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVHealth
## SYNOPSIS
Pulls health information from Horizon View
## SYNTAX
```
Get-HVHealth [[-Servicename] <String>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns health information from the local Horizon Pod
## EXAMPLES
### EXAMPLE 1
```
Get-HVHealth -service connectionserver
```
Returns health for the connectionserver(s)
### EXAMPLE 2
```
Get-HVHealth -service ViewComposer
```
Returns health for the View composer server(s)
## PARAMETERS
### -Servicename
The name of the service to query the health for.
This will default to Connection server health.
Available services are ADDomain,CertificateSSOConnector,ConnectionServer,EventDatabase,SAMLAuthenticator,SecurityServer,ViewComposer,VirtualCenter,Pod
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: ConnectionServer
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.3.2,7.4 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,89 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVHomeSite
## SYNOPSIS
Gets the configured Horizon View Homesites
## SYNTAX
```
Get-HVHomeSite [[-Group] <String>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Gets the configured Horizon View Homesites
## EXAMPLES
### EXAMPLE 1
```
Get-HVHomeSite
```
### EXAMPLE 2
```
Get-HVHomeSite -group group@domain
```
## PARAMETERS
### -Group
User principal name of a group
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.4 |
| PowerCLI Version | PowerCLI 10 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,120 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVInternalName
## SYNOPSIS
Gets human readable name
## SYNTAX
```
Get-HVInternalName [-EntityId] <EntityId> [[-VcId] <VirtualCenterId>] [[-BaseImageVmId] <BaseImageVmId>]
[[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Converts Horizon API Ids to human readable names.
Horizon API Ids are base64 encoded, this function
will decode and returns internal/human readable names.
## EXAMPLES
### EXAMPLE 1
```
Get-HVInternalName -EntityId $entityId
```
Decodes Horizon API Id and returns human readable name
## PARAMETERS
### -EntityId
Representation of a manageable entity id.
```yaml
Type: EntityId
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VcId
{{ Fill VcId Description }}
```yaml
Type: VirtualCenterId
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -BaseImageVmId
{{ Fill BaseImageVmId Description }}
```yaml
Type: BaseImageVmId
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns human readable name
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,69 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVLocalSession
## SYNOPSIS
Provides a list with all sessions on the local pod (works in CPA and non-CPA)
## SYNTAX
```
Get-HVLocalSession [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
The Get-HVLocalSession gets all local session by using view API service object(hvServer) of Connect-HVServer cmdlet.
## EXAMPLES
### EXAMPLE 1
```
Get-HVLocalSession
```
Get all local sessions
## PARAMETERS
### -HvServer
View API service object of Connect-HVServer cmdlet.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
Author : Wouter Kursten.
Author email : wouter@retouw.nl
Version : 1.0
===Tested Against Environment====
| | |
|-|-|
Horizon View Server Version : 7.0.2, 7.1.0, 7.3.2
PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1
PowerShell Version : 5.0
## RELATED LINKS

View File

@@ -0,0 +1,180 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVMachine
## SYNOPSIS
Gets virtual Machine(s) information with given search parameters.
## SYNTAX
```
Get-HVMachine [[-PoolName] <String>] [[-MachineName] <String>] [[-DnsName] <String>] [[-State] <String>]
[[-JsonFilePath] <String>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns virtual machines information, the machines list would be determined
based on queryable fields poolName, dnsName, machineName, state.
When more than one
fields are used for query the virtual machines which satisfy all fields criteria would be returned.
## EXAMPLES
### EXAMPLE 1
```
Get-HVMachine -PoolName 'ManualPool'
```
Queries VM(s) with given parameter poolName
### EXAMPLE 2
```
Get-HVMachine -MachineName 'PowerCLIVM'
```
Queries VM(s) with given parameter machineName
### EXAMPLE 3
```
Get-HVMachine -State CUSTOMIZING
```
Queries VM(s) with given parameter vm state
### EXAMPLE 4
```
Get-HVMachine -DnsName 'powercli-*'
```
Queries VM(s) with given parameter dnsName with wildcard character *
## PARAMETERS
### -PoolName
Pool name to query for.
If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -MachineName
The name of the Machine to query for.
If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has display name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -DnsName
DNS name for the Machine to filter with.
If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has display name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -State
The basic state of the Machine to filter with.
If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has display name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -JsonFilePath
{{ Fill JsonFilePath Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns list of objects of type MachineInfo
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,195 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVMachineSummary
## SYNOPSIS
Gets virtual Machine(s) summary with given search parameters.
## SYNTAX
```
Get-HVMachineSummary [[-PoolName] <String>] [[-MachineName] <String>] [[-DnsName] <String>] [[-State] <String>]
[[-JsonFilePath] <String>] [[-SuppressInfo] <Boolean>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns virtual machines information, the machines list would be determined
based on queryable fields poolName, dnsName, machineName, state.
When more than one
fields are used for query the virtual machines which satisfy all fields criteria would be returned.
## EXAMPLES
### EXAMPLE 1
```
Get-HVMachineSummary -PoolName 'ManualPool'
```
Queries VM(s) with given parameter poolName
### EXAMPLE 2
```
Get-HVMachineSummary -MachineName 'PowerCLIVM'
```
Queries VM(s) with given parameter machineName
### EXAMPLE 3
```
Get-HVMachineSummary -State CUSTOMIZING
```
Queries VM(s) with given parameter vm state
### EXAMPLE 4
```
Get-HVMachineSummary -DnsName 'powercli-*'
```
Queries VM(s) with given parameter dnsName with wildcard character *
## PARAMETERS
### -PoolName
Pool name to query for.
If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -MachineName
The name of the Machine to query for.
If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has display name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -DnsName
DNS name for the Machine to filter with.
If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has display name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -State
The basic state of the Machine to filter with.
If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has display name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -JsonFilePath
{{ Fill JsonFilePath Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SuppressInfo
Suppress text info, when no machine found with given search parameters
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns list of objects of type MachineNamesView
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,71 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVPodFederation
## SYNOPSIS
Returns information about a Horizon View Pod Federation (Cloud Pod Architecture)
## SYNTAX
```
Get-HVPodFederation [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Returns information about a Horizon View Pod Federation (Cloud Pod Architecture)
## EXAMPLES
### EXAMPLE 1
```
Get-HVPodFederation
```
Returns information about a Horizon View Pod Federation
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.3.2,7.4 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,218 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVPool
## SYNOPSIS
Gets pool(s) information with given search parameters.
## SYNTAX
```
Get-HVPool [[-PoolName] <String>] [[-PoolDisplayName] <String>] [[-PoolType] <String>]
[[-UserAssignment] <String>] [[-Enabled] <Boolean>] [[-ProvisioningEnabled] <Boolean>]
[[-SuppressInfo] <Boolean>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns pools information, the pools list would be determined based on
queryable fields poolName, poolDisplayName, poolType, userAssignment, enabled,
provisioningEnabled.
When more than one fields are used for query the pools which
satisfy all fields criteria would be returned.
## EXAMPLES
### EXAMPLE 1
```
Get-HVPool -PoolName 'mypool' -PoolType MANUAL -UserAssignment FLOATING -Enabled $true -ProvisioningEnabled $true
```
Queries and returns pool object(s) based on given parameters poolName, poolType etc.
### EXAMPLE 2
```
Get-HVPool -PoolType AUTOMATED -UserAssignment FLOATING
```
Queries and returns pool object(s) based on given parameters poolType and userAssignment
### EXAMPLE 3
```
Get-HVPool -PoolName 'myrds' -PoolType RDS -UserAssignment DEDICATED -Enabled $false
```
Queries and returns pool object(s) based on given parameters poolName, PoolType etc.
### EXAMPLE 4
```
Get-HVPool -PoolName 'myrds' -PoolType RDS -UserAssignment DEDICATED -Enabled $false -HvServer $mycs
```
Queries and returns pool object(s) based on given parameters poolName and HvServer etc.
## PARAMETERS
### -PoolName
Pool name to query for.
If the value is null or not provided then filter will not be applied,
otherwise the pools which has name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -PoolDisplayName
Pool display name to query for.
If the value is null or not provided then filter will not be applied,
otherwise the pools which has display name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -PoolType
Pool type to filter with.
If the value is null or not provided then filter will not be applied.
If the value is MANUAL then only manual pools would be returned.
If the value is AUTOMATED then only automated pools would be returned
If the value is RDS then only Remote Desktop Service Pool pools would be returned
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UserAssignment
User Assignment of pool to filter with.
If the value is null or not provided then filter will not be applied.
If the value is DEDICATED then only dedicated pools would be returned.
If the value is FLOATING then only floating pools would be returned
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Enabled
Pool enablement to filter with.
If the value is not provided then then filter will not be applied.
If the value is true then only pools which are enabled would be returned.
If the value is false then only pools which are disabled would be returned.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -ProvisioningEnabled
{{ Fill ProvisioningEnabled Description }}
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -SuppressInfo
Suppress text info, when no pool found with given search parameters
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the pools from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns list of objects of type DesktopInfo
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,142 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVPoolSpec
## SYNOPSIS
Gets desktop specification
## SYNTAX
```
Get-HVPoolSpec [-DesktopInfo] <DesktopInfo> [[-FilePath] <String>] [[-HvServer] <Object>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```
## DESCRIPTION
Converts DesktopInfo Object to DesktopSpec.
Also Converts view API Ids to human readable names
## EXAMPLES
### EXAMPLE 1
```
Get-HVPoolSpec -DesktopInfo $DesktopInfoObj
```
Converts DesktopInfo to DesktopSpec
### EXAMPLE 2
```
Get-HVPool -PoolName 'LnkClnJson' | Get-HVPoolSpec -FilePath "C:\temp\LnkClnJson.json"
```
Converts DesktopInfo to DesktopSpec and also dumps json object
## PARAMETERS
### -DesktopInfo
An object with detailed description of a desktop instance.
```yaml
Type: DesktopInfo
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -FilePath
{{ Fill FilePath Description }}
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns desktop specification
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,218 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVPoolSummary
## SYNOPSIS
Gets pool summary with given search parameters.
## SYNTAX
```
Get-HVPoolSummary [[-PoolName] <String>] [[-PoolDisplayName] <String>] [[-PoolType] <String>]
[[-UserAssignment] <String>] [[-Enabled] <Boolean>] [[-ProvisioningEnabled] <Boolean>]
[[-SuppressInfo] <Boolean>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns pools information, the pools list would be determined based on
queryable fields poolName, poolDisplayName, poolType, userAssignment, enabled,
provisioningEnabled.
When more than one fields are used for query the pools which
satisfy all fields criteria would be returned.
## EXAMPLES
### EXAMPLE 1
```
Get-HVPoolSummary -PoolName 'mypool' -PoolType MANUAL -UserAssignment FLOATING -Enabled $true -ProvisioningEnabled $true
```
Queries and returns desktopSummaryView based on given parameters poolName, poolType etc.
### EXAMPLE 2
```
Get-HVPoolSummary -PoolType AUTOMATED -UserAssignment FLOATING
```
Queries and returns desktopSummaryView based on given parameters poolType, userAssignment.
### EXAMPLE 3
```
Get-HVPoolSummary -PoolName 'myrds' -PoolType RDS -UserAssignment DEDICATED -Enabled $false
```
Queries and returns desktopSummaryView based on given parameters poolName, poolType, userAssignment etc.
### EXAMPLE 4
```
Get-HVPoolSummary -PoolName 'myrds' -PoolType RDS -UserAssignment DEDICATED -Enabled $false -HvServer $mycs
```
Queries and returns desktopSummaryView based on given parameters poolName, HvServer etc.
## PARAMETERS
### -PoolName
Pool name to query for.
If the value is null or not provided then filter will not be applied,
otherwise the pools which has name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -PoolDisplayName
Pool display name to query for.
If the value is null or not provided then filter will not be applied,
otherwise the pools which has display name same as value will be returned.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -PoolType
Pool type to filter with.
If the value is null or not provided then filter will not be applied.
If the value is MANUAL then only manual pools would be returned.
If the value is AUTOMATED then only automated pools would be returned
If the value is RDS then only Remote Desktop Service Pool pools would be returned
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UserAssignment
User Assignment of pool to filter with.
If the value is null or not provided then filter will not be applied.
If the value is DEDICATED then only dedicated pools would be returned.
If the value is FLOATING then only floating pools would be returned
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Enabled
Pool enablement to filter with.
If the value is not provided then then filter will not be applied.
If the value is true then only pools which are enabled would be returned.
If the value is false then only pools which are disabled would be returned.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -ProvisioningEnabled
{{ Fill ProvisioningEnabled Description }}
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -SuppressInfo
Suppress text info, when no pool found with given search parameters
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the pools from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns list of DesktopSummaryView
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,85 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVPreInstalledApplication
## SYNOPSIS
Gets the list of Pre-installed Applications from the RDS Server(s).
## SYNTAX
```
Get-HVPreInstalledApplication [-FarmName] <String> [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Gets the list of Pre-installed Applications from the RDS Server(s).
## EXAMPLES
### EXAMPLE 1
```
Get-HVPreInstalledApplication -FarmName 'Farm1' -HvServer $HvServer
```
Gets the list of Applications present in 'Farm1', if exists.
## PARAMETERS
### -FarmName
Name of the Farm on which to discover installed applications.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -HvServer
View API service object of Connect-HVServer cmdlet.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Gets the list of Applications from the specified Farm if exists.
## NOTES
| | |
|-|-|
| Author | Samiullasha S |
| Author email | ssami@vmware.com |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.8.0 |
| PowerCLI Version | PowerCLI 11.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,308 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVQueryFilter
## SYNOPSIS
Creates a VMware.Hv.QueryFilter based on input provided.
## SYNTAX
### ne
```
Get-HVQueryFilter [-MemberName] <String> [-Ne] [-MemberValue] <Object> [<CommonParameters>]
```
### startswith
```
Get-HVQueryFilter [-MemberName] <String> [-Startswith] [-MemberValue] <Object> [<CommonParameters>]
```
### contains
```
Get-HVQueryFilter [-MemberName] <String> [-Contains] [-MemberValue] <Object> [<CommonParameters>]
```
### eq
```
Get-HVQueryFilter [-MemberName] <String> [-Eq] [-MemberValue] <Object> [<CommonParameters>]
```
### not
```
Get-HVQueryFilter [-Not] [-Filter] <QueryFilter> [<CommonParameters>]
```
### and
```
Get-HVQueryFilter [-And] [-Filters] <QueryFilter[]> [<CommonParameters>]
```
### or
```
Get-HVQueryFilter [-Or] [-Filters] <QueryFilter[]> [<CommonParameters>]
```
## DESCRIPTION
This is a factory method to create a VMware.Hv.QueryFilter.
The type of the QueryFilter would be determined based on switch used.
## EXAMPLES
### EXAMPLE 1
```
Get-HVQueryFilter data.name -Eq vmware
```
Creates queryFilterEquals with given parameters memberName(position 0) and memberValue(position 2)
### EXAMPLE 2
```
Get-HVQueryFilter -MemberName data.name -Eq -MemberValue vmware
```
Creates queryFilterEquals with given parameters memberName and memberValue
### EXAMPLE 3
```
Get-HVQueryFilter data.name -Ne vmware
```
Creates queryFilterNotEquals filter with given parameters memberName and memberValue
### EXAMPLE 4
```
Get-HVQueryFilter data.name -Contains vmware
```
Creates queryFilterContains with given parameters memberName and memberValue
### EXAMPLE 5
```
Get-HVQueryFilter data.name -Startswith vmware
```
Creates queryFilterStartsWith with given parameters memberName and memberValue
### EXAMPLE 6
```
$filter = Get-HVQueryFilter data.name -Startswith vmware
```
Get-HVQueryFilter -Not $filter
Creates queryFilterNot with given parameter filter
### EXAMPLE 7
```
$filter1 = Get-HVQueryFilter data.name -Startswith vmware
```
$filter2 = Get-HVQueryFilter data.name -Contains pool
Get-HVQueryFilter -And @($filter1, $filter2)
Creates queryFilterAnd with given parameter filters array
### EXAMPLE 8
```
$filter1 = Get-HVQueryFilter data.name -Startswith vmware
```
$filter2 = Get-HVQueryFilter data.name -Contains pool
Get-HVQueryFilter -Or @($filter1, $filter2)
Creates queryFilterOr with given parameter filters array
## PARAMETERS
### -MemberName
Property path separated by .
(dot) from the root of queryable data object which is being queried for
```yaml
Type: String
Parameter Sets: ne, startswith, contains, eq
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Eq
Switch to create QueryFilterEquals filter
```yaml
Type: SwitchParameter
Parameter Sets: eq
Aliases:
Required: True
Position: 2
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Contains
Switch to create QueryFilterContains filter
```yaml
Type: SwitchParameter
Parameter Sets: contains
Aliases:
Required: True
Position: 2
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Startswith
Switch to create QueryFilterStartsWith filter
```yaml
Type: SwitchParameter
Parameter Sets: startswith
Aliases:
Required: True
Position: 2
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Ne
Switch to create QueryFilterNotEquals filter
```yaml
Type: SwitchParameter
Parameter Sets: ne
Aliases:
Required: True
Position: 2
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -MemberValue
Value of property (memberName) which is used for filtering
```yaml
Type: Object
Parameter Sets: ne, startswith, contains, eq
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Not
Switch to create QueryFilterNot filter, used for negating existing filter
```yaml
Type: SwitchParameter
Parameter Sets: not
Aliases:
Required: True
Position: 1
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Filter
Filter to used in QueryFilterNot to negate the result
```yaml
Type: QueryFilter
Parameter Sets: not
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -And
Switch to create QueryFilterAnd filter, used for joing two or more filters
```yaml
Type: SwitchParameter
Parameter Sets: and
Aliases:
Required: True
Position: 1
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Or
Switch to create QueryFilterOr filter, used for joing two or more filters
```yaml
Type: SwitchParameter
Parameter Sets: or
Aliases:
Required: True
Position: 1
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Filters
List of filters to join using QueryFilterAnd or QueryFilterOr
```yaml
Type: QueryFilter[]
Parameter Sets: and, or
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns the QueryFilter object
## NOTES
| | |
|-|-|
| Author | Kummara Ramamohan. |
| Author email | kramamohan@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,181 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVQueryResult
## SYNOPSIS
Returns the query results from ViewApi Query Service
## SYNTAX
```
Get-HVQueryResult [-EntityType] <String> [[-Filter] <QueryFilter>] [[-SortBy] <String>]
[[-SortDescending] <Boolean>] [[-Limit] <Int16>] [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Get-HVQueryResult is a API to query the results using ViewApi.
The filtering of the returned
list would be done based on input parameters filter, sortDescending, sortyBy, limit
## EXAMPLES
### EXAMPLE 1
```
Get-HVQueryResult DesktopSummaryView
```
Returns query results of entityType DesktopSummaryView(position 0)
### EXAMPLE 2
```
Get-HVQueryResult DesktopSummaryView (Get-HVQueryFilter data.name -Eq vmware)
```
Returns query results of entityType DesktopSummaryView(position 0) with given filter(position 1)
### EXAMPLE 3
```
Get-HVQueryResult -EntityType DesktopSummaryView -Filter (Get-HVQueryFilter desktopSummaryData.name -Eq vmware)
```
Returns query results of entityType DesktopSummaryView with given filter
### EXAMPLE 4
```
$myFilter = Get-HVQueryFilter data.name -Contains vmware
```
Get-HVQueryResult -EntityType DesktopSummaryView -Filter $myFilter -SortBy desktopSummaryData.displayName -SortDescending $false
Returns query results of entityType DesktopSummaryView with given filter and also sorted based on dispalyName
### EXAMPLE 5
```
Get-HVQueryResult DesktopSummaryView -Limit 10
```
Returns query results of entityType DesktopSummaryView, maximum count equal to limit
## PARAMETERS
### -EntityType
ViewApi Queryable entity type which is being queried for.The return list would be containing objects of entityType
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Filter
Filter to used for filtering the results, See Get-HVQueryFilter for more information
```yaml
Type: QueryFilter
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SortBy
Data field path used for sorting the results
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SortDescending
If the value is set to true (default) then the results will be sorted in descending order
If the value is set to false then the results will be sorted in ascending order
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
```
### -Limit
Max number of objects to retrieve.
Default would be 0 which means retieve all the results
```yaml
Type: Int16
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the data from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns the list of objects of entityType
## NOTES
| | |
|-|-|
| Author | Kummara Ramamohan. |
| Author email | kramamohan@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0,7.4 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1, PowerCLI 10.1.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,70 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVResourceStructure
## SYNOPSIS
Output the structure of the resource pools available to a HV.
Primarily this is for debugging
PS\> Get-HVResourceStructure
vCenter vc.domain.local
Container DC path /DC/host
HostOrCluster Servers path /DC/host/Servers
HostOrCluster VDI path /DC/host/VDI
ResourcePool Servers path /DC/host/Servers/Resources
ResourcePool VDI path /DC/host/VDI/Resources
ResourcePool RP1 path /DC/host/VDI/Resources/RP1
ResourcePool RP2 path /DC/host/VDI/Resources/RP1/RP2
| Author | Mark Elvers \<mark.elvers@tunbury.org\> |
## SYNTAX
```
Get-HVResourceStructure [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
{{ Fill in the Description }}
## EXAMPLES
### Example 1
```powershell
PS C:\> {{ Add example code here }}
```
{{ Add example description here }}
## PARAMETERS
### -HvServer
{{ Fill HvServer Description }}
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS

View File

@@ -0,0 +1,71 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVSite
## SYNOPSIS
Returns information about the sites within a Horizon View Pod Federation (Cloud Pod Architecture)
## SYNTAX
```
Get-HVSite [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Returns information about the sites within a Horizon View Pod Federation (Cloud Pod Architecture)
## EXAMPLES
### EXAMPLE 1
```
get-hvsite
```
Returns information about the sites within a Horizon View Pod Federation.
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.3.2,7.4 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,69 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVlicense
## SYNOPSIS
Gets the license for Horizon View
## SYNTAX
```
Get-HVlicense [[-HvServer] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Gets the license for Horizon View
## EXAMPLES
### EXAMPLE 1
```
get-hvlicense
```
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.4,7.5 |
| PowerCLI Version | PowerCLI 10 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,90 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVvCenterServer
## SYNOPSIS
Gets a list of all configured vCenter Servers
## SYNTAX
```
Get-HVvCenterServer [[-HvServer] <Object>] [[-Name] <String>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns the vCenter Servers configured for the pod of the specified HVServer.
## EXAMPLES
### EXAMPLE 1
```
Get-HVvCenterServer
```
### EXAMPLE 2
```
Get-HVvCenterServer -Name 'vCenter1'
```
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered inplace of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Name
A string value to query a vCenter Server by Name, if it is known.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns array of object type VMware.Hv.VirtualCenterInfo
## NOTES
| | |
|-|-|
| Author | Matt Frey. |
| Author email | mfrey@vmware.com |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.7 |
| PowerCLI Version | PowerCLI 11.2.0 |
| PowerShell Version | 5.1 |
## RELATED LINKS

View File

@@ -0,0 +1,97 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# Get-HVvCenterServerHealth
## SYNOPSIS
Gets a the health info for a given vCenter Server.
## SYNTAX
```
Get-HVvCenterServerHealth [[-HvServer] <Object>] [[-VirtualCenter] <Object>] [<CommonParameters>]
```
## DESCRIPTION
Queries and returns the VirtualCenterHealthInfo specified HVServer.
## EXAMPLES
### EXAMPLE 1
```
Get-HVvCenterServerHealth -VirtualCenter 'vCenter1'
```
### EXAMPLE 2
```
Get-HVvCenterServerHealth -VirtualCenter $vCenter1
```
### EXAMPLE 3
```
Get-HVvCenterServerHealth
```
## PARAMETERS
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered inplace of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VirtualCenter
A parameter to specify which vCenter Server to check health for.
If not specified, this function will return the
health info for all vCenter Servers.
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### Returns array of object type VMware.Hv.VirtualCenterInfo
## NOTES
| | |
|-|-|
| Author | Matt Frey. |
| Author email | mfrey@vmware.com |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.7 |
| PowerCLI Version | PowerCLI 11.2.0 |
| PowerShell Version | 5.1 |
## RELATED LINKS

View File

@@ -0,0 +1,221 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# New-HVEntitlement
## SYNOPSIS
Associates a user/group with a resource
## SYNTAX
### Default
```
New-HVEntitlement -User <String> -ResourceName <String> [-ResourceType <String>] [-Type <String>]
[-HvServer <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]
```
### PipeLine
```
New-HVEntitlement -User <String> -Resource <Object> [-ResourceType <String>] [-Type <String>]
[-HvServer <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
This represents a simple association between a single user/group and a resource that they can be assigned.
## EXAMPLES
### EXAMPLE 1
```
New-HVEntitlement -User 'administrator@adviewdev.eng.vmware.com' -ResourceName 'InsClnPol' -Confirm:$false
```
Associate a user/group with a pool
### EXAMPLE 2
```
New-HVEntitlement -User 'adviewdev\administrator' -ResourceName 'Calculator' -ResourceType Application
```
Associate a user/group with a application
### EXAMPLE 3
```
New-HVEntitlement -User 'adviewdev.eng.vmware.com\administrator' -ResourceName 'UrlSetting1' -ResourceType URLRedirection
```
Associate a user/group with a URLRedirection settings
### EXAMPLE 4
```
New-HVEntitlement -User 'adviewdev.eng.vmware.com\administrator' -ResourceName 'GE1' -ResourceType GlobalEntitlement
```
Associate a user/group with a desktop entitlement
### EXAMPLE 5
```
New-HVEntitlement -User 'adviewdev\administrator' -ResourceName 'GEAPP1' -ResourceType GlobalApplicationEntitlement
```
Associate a user/group with a application entitlement
### EXAMPLE 6
```
$pools = Get-HVPool; $pools | New-HVEntitlement -User 'adviewdev\administrator' -Confirm:$false
```
Associate a user/group with list of pools
## PARAMETERS
### -User
User principal name of user or group
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ResourceName
The resource(Application, Desktop etc.) name.
Supports only wildcard character '*' when resource type is desktop.
```yaml
Type: String
Parameter Sets: Default
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Resource
Object(s) of the resource(Application, Desktop etc.) to entitle
```yaml
Type: Object
Parameter Sets: PipeLine
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -ResourceType
Type of Resource(Application, Desktop etc)
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Desktop
Accept pipeline input: False
Accept wildcard characters: False
```
### -Type
Whether or not this is a group or a user.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: User
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,329 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# New-HVGlobalEntitlement
## SYNOPSIS
Creates a Global Entitlement.
## SYNTAX
```
New-HVGlobalEntitlement [-DisplayName] <String> [-Type] <String> [[-Description] <String>] [[-Scope] <String>]
[[-Dedicated] <Boolean>] [[-FromHome] <Boolean>] [[-RequireHomeSite] <Boolean>]
[[-MultipleSessionAutoClean] <Boolean>] [[-Enabled] <Boolean>] [[-SupportedDisplayProtocols] <String[]>]
[[-DefaultDisplayProtocol] <String>] [[-AllowUsersToChooseProtocol] <Boolean>]
[[-AllowUsersToResetMachines] <Boolean>] [[-EnableHTMLAccess] <Boolean>] [[-HvServer] <Object>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Global entitlements are used to route users to their resources across multiple pods.
These are persisted in a global ldap instance that is replicated across all pods in a linked mode view set.
## EXAMPLES
### EXAMPLE 1
```
New-HVGlobalEntitlement -DisplayName 'GE_APP' -Type APPLICATION_ENTITLEMENT
```
Creates new global application entitlement
### EXAMPLE 2
```
New-HVGlobalEntitlement -DisplayName 'GE_DESKTOP' -Type DESKTOP_ENTITLEMENT
```
Creates new global desktop entitlement
## PARAMETERS
### -DisplayName
Display Name of Global Entitlement.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Type
Specify whether to create desktop/app global entitlement
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Description
Description of Global Entitlement.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Scope
Scope for this global entitlement.
Visibility and Placement policies are defined by this value.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: ANY
Accept pipeline input: False
Accept wildcard characters: False
```
### -Dedicated
Specifies whether dedicated/floating resources associated with this global entitlement.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -FromHome
This value defines the starting location for resource placement and search.
When true, a pod in the user's home site is used to start the search.
When false, the current site is used.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -RequireHomeSite
This value determines whether we fail if a home site isn't defined for this global entitlement.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -MultipleSessionAutoClean
This value is used to determine if automatic session clean up is enabled.
This cannot be enabled when this Global Entitlement is associated with a Desktop that has dedicated user assignment.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -Enabled
If this Global Entitlement is enabled.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 9
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -SupportedDisplayProtocols
The set of supported display protocols for the global entitlement.
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 10
Default value: @("PCOIP","BLAST")
Accept pipeline input: False
Accept wildcard characters: False
```
### -DefaultDisplayProtocol
The default display protocol for the global entitlement.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 11
Default value: PCOIP
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowUsersToChooseProtocol
Whether the users can choose the protocol used.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 12
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
```
### -AllowUsersToResetMachines
Whether users are allowed to reset/restart their machines.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 13
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -EnableHTMLAccess
If set to true, the desktops that are associated with this GlobalEntitlement must also have HTML Access enabled.
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 14
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 15
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Praveen Mathamsetty. |
| Author email | pmathamsetty@vmware.com |
| Version | 1.1 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.0.2, 7.1.0 |
| PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

View File

@@ -0,0 +1,178 @@
---
external help file: VMware.HV.Helper-help.xml
Module Name: VMware.HV.Helper
online version:
schema: 2.0.0
---
# New-HVHomeSite
## SYNOPSIS
Defines a homesite within a Horizon View Cloud Pod architecture
## SYNTAX
### Default (Default)
```
New-HVHomeSite -Group <String> -Site <String> [-HvServer <Object>] [<CommonParameters>]
```
### globalApplicationEntitlement
```
New-HVHomeSite [-Group <String>] [-Site <String>] [-globalApplicationEntitlement <String>] [-HvServer <Object>]
[<CommonParameters>]
```
### globalEntitlement
```
New-HVHomeSite [-Group <String>] [-Site <String>] [-globalEntitlement <String>] [-HvServer <Object>]
[<CommonParameters>]
```
## DESCRIPTION
Creates a new homesite within a Cloud Pod Archtitecture.
By default it will be applied to everything
but the choice can be made to only apply for a single global entitlement or singel global application entitlement
## EXAMPLES
### EXAMPLE 1
```
New-HVHomeSite -group group@domain -site SITE
```
### EXAMPLE 2
```
New-HVHomeSite -group group@domain -site SITE -globalapplicationentitlement ge-ap01
```
### EXAMPLE 3
```
New-HVHomeSite -group group@domain -site SITE -globalentitlement GE_Production
```
## PARAMETERS
### -Group
User principal name of a group
```yaml
Type: String
Parameter Sets: Default
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
```yaml
Type: String
Parameter Sets: globalApplicationEntitlement, globalEntitlement
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Site
Name of the Horizon View Site
```yaml
Type: String
Parameter Sets: Default
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
```yaml
Type: String
Parameter Sets: globalApplicationEntitlement, globalEntitlement
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -globalEntitlement
Name of the global entitlement
```yaml
Type: String
Parameter Sets: globalEntitlement
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -globalApplicationEntitlement
Name of the global application entitlement
```yaml
Type: String
Parameter Sets: globalApplicationEntitlement
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HvServer
Reference to Horizon View Server to query the virtual machines from.
If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer
```yaml
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
| | |
|-|-|
| Author | Wouter Kursten |
| Author email | wouter@retouw.nl |
| Version | 1.0 |
===Tested Against Environment====
| | |
|-|-|
| Horizon View Server Version | 7.4 |
| PowerCLI Version | PowerCLI 10.1.1 |
| PowerShell Version | 5.0 |
## RELATED LINKS

Some files were not shown because too many files have changed in this diff Show More