├── .gitattributes ├── .gitignore ├── DSC └── README.md ├── LICENSE.txt ├── Modules ├── Backup-VCSA │ └── Backup-VCSA.psm1 ├── ContentLibrary │ └── ContentLibrary.psm1 ├── CrossvCentervmotion │ └── XVM.psm1 ├── DatastoreFunctions │ └── DatastoreFunctions.psm1 ├── Get-NICDetails │ └── Get-NICDetails.psm1 ├── Get-NewAndRemovedVMs │ └── Get-NewAndRemovedVMs.psm1 ├── Get-VMmaxIOPS │ └── Get-VMmaxIOPS.psm1 ├── InstantClone │ └── InstantClone.psm1 ├── Konfig-ESXi │ └── Konfig-ESXi.psm1 ├── NSXT │ ├── NSXT.psd1 │ └── NSXT.psm1 ├── PSvLIMessage │ └── PSvLIMessage.psm1 ├── PerVMEVC │ └── PerVMEVC.psm1 ├── ProactiveHA │ └── ProactiveHA.psm1 ├── README.md ├── Recommend-Sizing │ └── Recommend-Sizing.psm1 ├── SRM │ ├── .gitattributes │ ├── .gitignore │ ├── Examples │ │ ├── ReportConfiguration.ps1 │ │ └── SrmTagging.ps1 │ ├── LICENSE.txt │ ├── Meadowcroft.Srm.Protection.ps1 │ ├── Meadowcroft.Srm.Recovery.ps1 │ ├── Meadowcroft.Srm.Storage.ps1 │ ├── Meadowcroft.Srm.psd1 │ ├── Meadowcroft.Srm.psm1 │ ├── NOTICE.txt │ └── README.md ├── SaltStackConfig │ ├── SaltStackConfig.Format.ps1xml │ ├── SaltStackConfig.psd1 │ └── SaltStackConfig.psm1 ├── Set-CBT │ └── Set-CBT.psm1 ├── Start-UNMAP │ └── Start-UNMAP.psm1 ├── VAMI │ └── VAMI.psm1 ├── VCHA │ └── VCHA.psm1 ├── VCSA │ └── VCSA.psm1 ├── VISecret │ ├── README.md │ ├── VMware.VISecret.psd1 │ └── VMware.VISecret.psm1 ├── VMCPFunctions │ └── VMCPFunctions.psm1 ├── VMFSIncrease │ ├── LICENSE.txt.URL │ ├── VMFSIncrease.psd1 │ ├── VMFSIncrease.psm1 │ └── en-US │ │ ├── VMFSIncrease.psm1-Help.xml │ │ └── about_VMFSIncrease.help.txt ├── VMToolsManagement │ └── VMToolsManagement.psm1 ├── VMware-vCD-Module │ ├── LICENSE │ ├── README.md │ ├── VMware-vCD-Module.psd1 │ ├── examples │ │ └── OnBoarding.json │ ├── functions │ │ ├── Invoke-MyOnBoarding.psm1 │ │ ├── New-MyEdgeGateway.psm1 │ │ ├── New-MyOrg.psm1 │ │ ├── New-MyOrgAdmin.psm1 │ │ ├── New-MyOrgNetwork.psm1 │ │ └── New-MyOrgVdc.psm1 │ ├── media │ │ ├── Invoke-MyOnBoarding.png │ │ └── VSCode-Pester-Tests.png │ └── tests │ │ └── VMware-vCD-Module.Tests.ps1 ├── VMware-vCD-TenantReport │ ├── README.md │ ├── VMware-vCD-TenantReport.psd1 │ ├── functions │ │ └── Get-VcdTenantReport.psm1 │ ├── media │ │ └── Get-VcdTenantReport.png │ ├── modules │ │ └── PowerStartHTML │ │ │ ├── PowerStartHTML.psd1 │ │ │ └── PowerStartHTML.psm1 │ └── tests │ │ └── VMware-vCD-TenantReport.Tests.ps1 ├── VMware.CSP │ └── VMware.CSP.psm1 ├── VMware.Community.CISTag │ ├── VMware.Community.CISTag.psd1 │ └── VMware.Community.CISTag.psm1 ├── VMware.DRaaS │ ├── VMware.DRaaS.psd1 │ └── VMware.DRaaS.psm1 ├── VMware.HCX │ ├── VMware.HCX.psd1 │ └── VMware.HCX.psm1 ├── VMware.Hosted │ ├── VMware.Hosted.psd1 │ └── VMware.Hosted.psm1 ├── VMware.Hv.Helper │ ├── Json │ │ ├── Farm │ │ │ ├── AutomatedInstantCloneFarm.json │ │ │ ├── AutomatedLinkedCloneFarm.json │ │ │ ├── AutomatedLinkedCloneFarmVGPU.json │ │ │ └── ManualFarm.json │ │ └── Pool │ │ │ ├── FullClone.json │ │ │ ├── InstantClone.json │ │ │ ├── LinkedClone.json │ │ │ ├── ManualSpec.json │ │ │ └── RdsSpec.json │ ├── README.md │ ├── Set-HVFarm │ │ ├── AutomatedEditFarm.json │ │ └── ManualEditFarm.json │ ├── Set-HVGlobalSettings │ │ └── Set-HVGlobalSettings.json │ ├── Set-HVPool │ │ ├── AutomatedEditPool.Json │ │ ├── ManualEditPool.json │ │ └── RdsEditPool.json │ ├── VMware.HV.Helper.format.ps1xml │ ├── VMware.HV.Helper.psd1 │ ├── VMware.HV.Helper.psm1 │ └── docs │ │ ├── Add-HVDesktop.md │ │ ├── Add-HVRDSServer.md │ │ ├── Clear-HVEventDatabase.md │ │ ├── Connect-HVEvent.md │ │ ├── Disconnect-HVEvent.md │ │ ├── Get-HVApplication.md │ │ ├── Get-HVBaseImageVM.md │ │ ├── Get-HVEntitlement.md │ │ ├── Get-HVEvent.md │ │ ├── Get-HVEventDatabase.md │ │ ├── Get-HVFarm.md │ │ ├── Get-HVFarmSummary.md │ │ ├── Get-HVGlobalEntitlement.md │ │ ├── Get-HVGlobalSession.md │ │ ├── Get-HVGlobalSettings.md │ │ ├── Get-HVHealth.md │ │ ├── Get-HVHomeSite.md │ │ ├── Get-HVInternalName.md │ │ ├── Get-HVLocalSession.md │ │ ├── Get-HVMachine.md │ │ ├── Get-HVMachineSummary.md │ │ ├── Get-HVPodFederation.md │ │ ├── Get-HVPool.md │ │ ├── Get-HVPoolSpec.md │ │ ├── Get-HVPoolSummary.md │ │ ├── Get-HVPreInstalledApplication.md │ │ ├── Get-HVQueryFilter.md │ │ ├── Get-HVQueryResult.md │ │ ├── Get-HVResourceStructure.md │ │ ├── Get-HVSite.md │ │ ├── Get-HVlicense.md │ │ ├── Get-HVvCenterServer.md │ │ ├── Get-HVvCenterServerHealth.md │ │ ├── New-HVEntitlement.md │ │ ├── New-HVFarm.md │ │ ├── New-HVGlobalEntitlement.md │ │ ├── New-HVHomeSite.md │ │ ├── New-HVManualApplication.md │ │ ├── New-HVPodFederation.md │ │ ├── New-HVPool.md │ │ ├── New-HVPreInstalledApplication.md │ │ ├── New-HVSite.md │ │ ├── Register-HVPod.md │ │ ├── Remove-HVApplication.md │ │ ├── Remove-HVApplicationIcon.md │ │ ├── Remove-HVEntitlement.md │ │ ├── Remove-HVFarm.md │ │ ├── Remove-HVGlobalEntitlement.md │ │ ├── Remove-HVMachine.md │ │ ├── Remove-HVPodFederation.md │ │ ├── Remove-HVPool.md │ │ ├── Remove-HVSite.md │ │ ├── Reset-HVMachine.md │ │ ├── Set-HVApplication.md │ │ ├── Set-HVApplicationIcon.md │ │ ├── Set-HVEventDatabase.md │ │ ├── Set-HVFarm.md │ │ ├── Set-HVGlobalEntitlement.md │ │ ├── Set-HVGlobalSettings.md │ │ ├── Set-HVInstantCloneMaintenance.md │ │ ├── Set-HVMachine.md │ │ ├── Set-HVPodFederation.md │ │ ├── Set-HVPool.md │ │ ├── Set-HVSite.md │ │ ├── Set-HVlicense.md │ │ ├── Start-HVFarm.md │ │ ├── Start-HVPool.md │ │ └── Unregister-HVPod.md ├── VMware.Skyline.InsightsApi │ ├── VMware.Skyline.InsightsApi.Format.ps1xml │ ├── VMware.Skyline.InsightsApi.psd1 │ └── VMware.Skyline.InsightsApi.psm1 ├── VMware.TrustedInfrastructure.Helper │ ├── README.md │ ├── VMware.TrustedInfrastructure.Helper.psd1 │ └── VMware.TrustedInfrastructure.Helper.psm1 ├── VMware.VCGChecker │ ├── Export-VCGReport.ps1 │ ├── Get-VCGHWInfo.ps1 │ ├── Get-VCGStatus.ps1 │ ├── README.md │ ├── Save-VCGJsonFile.ps1 │ ├── VMware.VCGChecker.psd1 │ └── logger.ps1 ├── VMware.VMC.NSXT │ ├── VMware.VMC.NSXT.psd1 │ └── VMware.VMC.NSXT.psm1 ├── VMware.VMC │ ├── VMware.VMC.psd1 │ └── VMware.VMC.psm1 ├── VMware.VMEncryption │ ├── README.md │ ├── VMware.VMEncryption.psd1 │ └── VMware.VMEncryption.psm1 ├── VMware.VsanEncryption │ ├── README.md │ ├── VMware.VsanEncryption.psd1 │ └── VMware.VsanEncryption.psm1 ├── VMware.WorkloadManagement │ ├── VMware.WorkloadManagement.psd1 │ └── VMware.WorkloadManagement.psm1 ├── VMware.WorkspaceOneAccess │ ├── VMware.WorkspaceOneAccess.psd1 │ └── VMware.WorkspaceOneAccess.psm1 ├── VMware.vSphere.SsoAdmin │ ├── AuthenticationPolicy.ps1 │ ├── Connect.ps1 │ ├── Group.ps1 │ ├── IdentitySource.ps1 │ ├── LockoutPolicy.ps1 │ ├── MobConnect.ps1 │ ├── PasswordPolicy.ps1 │ ├── PersonUser.ps1 │ ├── README.md │ ├── TokenLifetime.ps1 │ ├── VMware.vSphere.SsoAdmin.psd1 │ ├── VMware.vSphere.SsoAdmin.psm1 │ ├── net45 │ │ ├── VMware.vSphere.LsClient.dll │ │ ├── VMware.vSphere.SsoAdmin.Format.ps1xml │ │ ├── VMware.vSphere.SsoAdmin.Utils.dll │ │ ├── VMware.vSphere.SsoAdmin.psd1 │ │ └── VMware.vSphere.SsoAdminClient.dll │ ├── netcoreapp3.1 │ │ ├── VMware.vSphere.LsClient.dll │ │ ├── VMware.vSphere.SsoAdmin.Format.ps1xml │ │ ├── VMware.vSphere.SsoAdmin.Utils.dll │ │ ├── VMware.vSphere.SsoAdmin.psd1 │ │ └── VMware.vSphere.SsoAdminClient.dll │ └── src │ │ ├── .gitignore │ │ ├── VMware.vSphere.SsoAdmin.Client │ │ ├── Nuget.config │ │ ├── VMware.vSphere.LsClient │ │ │ ├── Connected Services │ │ │ │ └── LookupServiceReference │ │ │ │ │ ├── ConnectedService.json │ │ │ │ │ └── Reference.cs │ │ │ ├── LookupServiceClient.cs │ │ │ └── VMware.vSphere.LsClient.csproj │ │ ├── VMware.vSphere.SsoAdmin.Client.sln │ │ ├── VMware.vSphere.SsoAdmin.Utils │ │ │ ├── AcceptAllX509CertificateValidator.cs │ │ │ ├── StringToSecureStringArgumentTransformationAttribute.cs │ │ │ ├── StringToSsoAdminServerArgumentTransformationAttribute.cs │ │ │ └── VMware.vSphere.SsoAdmin.Utils.csproj │ │ ├── VMware.vSphere.SsoAdminClient.Tests │ │ │ ├── IntegrationTests.cs │ │ │ └── VMware.vSphere.SsoAdminClient.Tests.csproj │ │ ├── VMware.vSphere.SsoAdminClient │ │ │ ├── DataTypes │ │ │ │ ├── ActiveDirectoryIdentitySource.cs │ │ │ │ ├── AuthenticationPolicy.cs │ │ │ │ ├── Group.cs │ │ │ │ ├── IdentitySource.cs │ │ │ │ ├── LocalOSIdentitySource.cs │ │ │ │ ├── LockoutPolicy.cs │ │ │ │ ├── PasswordPolicy.cs │ │ │ │ ├── PersonUser.cs │ │ │ │ ├── SsoAdminServer.cs │ │ │ │ ├── SystemIdentitySource.cs │ │ │ │ └── TokenLifetime.cs │ │ │ ├── SsoAdminClient.cs │ │ │ ├── SsoAdminServiceReference │ │ │ │ └── Reference.cs │ │ │ ├── UserPassSecurityContext.cs │ │ │ └── VMware.vSphere.SsoAdminClient.csproj │ │ └── packages │ │ │ ├── VMware.Binding.Sts.12.0.0.15939652.nupkg │ │ │ ├── VMware.Binding.Sts.12.0.0.15939652.symbols.nupkg │ │ │ ├── VMware.Binding.WsTrust.12.0.0.15939652.nupkg │ │ │ ├── VMware.Binding.WsTrust.12.0.0.15939652.symbols.nupkg │ │ │ ├── VMware.Http.Handlers.12.0.0.15939652.nupkg │ │ │ ├── VMware.Http.Handlers.12.0.0.15939652.symbols.nupkg │ │ │ ├── VMware.System.Private.ServiceModel.4.4.4.nupkg │ │ │ ├── VMware.Util.Sspi.12.0.0.15939652.nupkg │ │ │ └── VMware.Util.Sspi.12.0.0.15939652.symbols.nupkg │ │ ├── build.ps1 │ │ ├── resources │ │ └── powercli.png │ │ └── test │ │ ├── AuthenticationPolicy.Tests.ps1 │ │ ├── ConnectDisconnect.Tests.ps1 │ │ ├── Group.Tests.ps1 │ │ ├── IdentitySource.Tests.ps1 │ │ ├── LockoutPolicy.Tests.ps1 │ │ ├── LsClient.Tests.ps1 │ │ ├── PasswordPolicy.Tests.ps1 │ │ ├── PersonUser.Tests.ps1 │ │ ├── RunTests.ps1 │ │ └── TokenLifetime.Tests.ps1 ├── VMwareCloudPartnerNavigator │ └── navigator.psm1 ├── Validate-ESXiPackages │ └── Validate-ESXiPackages.psm1 ├── Vi-Module │ ├── README.md │ ├── Vi-Module.psd1 │ └── Vi-Module.psm1 ├── VyOS │ ├── VyOS.psm1 │ └── vyos.template ├── apply-hardening │ └── apply-hardening.psm1 ├── rCisTag │ ├── Examples │ │ ├── 01-Get.ps1 │ │ ├── 02-New.ps1 │ │ ├── 03-Set.ps1 │ │ ├── 04-Remove.ps1 │ │ ├── 05-Tag-Datastore.ps1 │ │ └── CisConfig.ps1 │ ├── MITLicense.txt │ ├── README.md │ ├── en-US │ │ ├── about_rCISTag.Help.txt │ │ └── rCISTag-help.xml │ ├── rCISTag.psd1 │ └── rCISTag.psm1 ├── vCenter.Alarms │ ├── New-vCenterAlarms.ps1 │ └── vCenter.Alarms.psm1 ├── vCenterCEIP │ └── vCenterCEIP.psm1 ├── vCenterManualMigration │ └── vCenterManualMigration.psm1 └── vSphere_Hardening_Assess_VM_v1a │ └── vSphere_Hardening_Assess_VM_v1a.psm1 ├── NOTICE.txt ├── Pester ├── 00 Test Connect-CISServer Connection to VC.Tests.ps1 ├── 00 Test Connect-VIServer Connection to VC.Tests.ps1 ├── Functions │ ├── Connect-VMCVIServer.tests.ps1 │ ├── Get-VMCCommand.tests.ps1 │ ├── Get-VMCFirewallRule.tests.ps1 │ ├── Get-VMCHost.tests.ps1 │ ├── Get-VMCOrg.tests.ps1 │ ├── Get-VMCSDDCDefaultCredential.tests.ps1 │ ├── Get-VMCSDDCPublicIP.tests.ps1 │ ├── Get-VMCSDDCVersion.tests.ps1 │ ├── Get-VmcSddc.tests.ps1 │ ├── Get-VmcTask.tests.ps1 │ └── Shared.ps1 ├── Get-DatastoreProvisioned.Tests.ps1 ├── Test Get-CISService.Tests.ps1 ├── VMCCode-Coverage.ps1 ├── ZZ Test Disconnect-CISServer to VC.Tests.ps1 └── ZZ Test Disconnect-VIServer to VC.Tests.ps1 ├── PowerActions ├── Example - ClusterSnapshotsReport.ps1 ├── Example - RemoveOldClusterSnapshots.ps1 ├── Git Sync.ps1 ├── README.md ├── VM-CdDrive-Report.ps1 └── VM-Snapshot-Report.ps1 ├── README.md ├── Scripts ├── Apply-OMRightsizing.ps1 ├── At_Your_Fingertips │ ├── NewProfile.ps1 │ └── install-profile.ps1 ├── AutomaticVMFSUnmap.ps1 ├── Check-VMwareTools.ps1 ├── Copy-NsxIpsetsv2t.ps1 ├── CreateVLANonStandardSwitch ├── DatastoreSIOCStatistics.ps1 ├── Demo │ └── CallAPIsWithPowerCLI.ps1 ├── ESXInstallDate.ps1 ├── ESXInstalledVIBs.ps1 ├── ExportImportTags.ps1 ├── FindVSphereCommand │ ├── FindVSphereCommand.Format.ps1xml │ ├── FindVSphereCommand.psd1 │ ├── FindVSphereCommand.psm1 │ └── Readme.md ├── Get-BasicVMCapacityReport ├── Get-BiosBootStatus.ps1 ├── Get-CIVMData.ps1 ├── Get-DatastoreProvisioned.ps1 ├── Get-Migrations.ps1 ├── Get-TotalDiskUsage.ps1 ├── Get-TotalMemoryAllocation.ps1 ├── Get-TriggeredAlarm.ps1 ├── Get-VMHostUplinkDetails.ps1 ├── Get-VMHostWWPN.ps1 ├── Get-VMID.ps1 ├── Get-VMNetworkPortId.ps1 ├── Get-VMSnapshotReport.ps1 ├── Get-VMToolsParts.ps1 ├── Get-VsanHclDatabase.ps1 ├── Home Lab │ ├── Home Lab Delete settings.ps1 │ └── Home Lab Deployment.ps1 ├── Horizon View Example Desktop Script.ps1 ├── Horizon-GetUsageStats.ps1 ├── Host_Memory_Assessment_Tool.ps1 ├── Install-HostClient.ps1 ├── Invoke-BiosBoot.ps1 ├── Move-DatastoreCluster.ps1 ├── NVME Info.ps1 ├── New-ClusterHostGroup.ps1 ├── New-ClusterVmGroup.ps1 ├── New-ClusterVmHostRule.ps1 ├── PAIF-N │ ├── 01-deploy-vcf-workload-domain.ps1 │ ├── 02-install-nvidia-driver-vlcm.ps1 │ ├── 03-deploy-edge-cluster.ps1 │ ├── 04-enable-wcp.ps1 │ ├── README.md │ └── utils │ │ ├── Wait-VcfTask.ps1 │ │ └── Wait-VcfValidation.ps1 ├── PowerCLI_FixNestedFolders.ps1 ├── README.md ├── ReadVMSnapshotConfig.ps1 ├── Remove-HostClient.ps1 ├── Remove-IPPool.ps1 ├── Report-LUNPath-ESXCLI.ps1 ├── Sample VMC firewall rules management.ps1 ├── Save-PowerCLI.ps1 ├── SecureBoot.ps1 ├── Set-ClusterDpm.ps1 ├── Set-CustomAttributesInGuestinfo.ps1 ├── Set-LockdownLevel.ps1 ├── Set-NetworkAdapterOpaqueNetwork.ps1 ├── Set-TagsInGuestinfo.ps1 ├── Set-VMHostSecureNTP.ps1 ├── SetClusterMultiPathToRoundRobin.ps1 ├── SetDatastoreTag.ps1 ├── SetLunReservation.ps1 ├── SetMultiPathToRoundRobin ├── Start-VMHostSsh.ps1 ├── Stop-VMHostSsh.ps1 ├── Sysprep_Automation_Script.ps1 ├── Update_PowerCLI_Scripts.ps1 ├── VMware_Cloud_on_AWS │ ├── AWS_Integrations_Examples │ │ ├── Serverless_VM_Deployment │ │ │ ├── index.html │ │ │ ├── readme.txt │ │ │ └── vm-request-form.zip │ │ └── Slack_Inventory │ │ │ ├── slackinventory.py │ │ │ └── vmc-inventory-to-slack.mp4 │ ├── Create100VMs.ps1 │ ├── L2VPN-vMotion-OnPrem-to-VMC.ps1 │ ├── VMC Example Script.ps1 │ ├── VMWonAWS_1nodeDeployment.ps1 │ ├── VMWonAWS_FirewallRuleAccelerator.ps1 │ ├── VMWonAWS_InviteUsers.ps1 │ └── XRef-VMC-Services.ps1 ├── VSANSmartsData.ps1 ├── VSANVersion.ps1 ├── backup-esxi-host-configuration.ps1 ├── esxi-image-comparator.ps1 ├── esxi-image-creator.ps1 ├── get-peakvms.ps1 ├── get-ping.ps1 ├── ha-vcenter-deploy-template.json ├── ha-vcenter-deploy.ps1 ├── modules.sh ├── vCenterSnapshot.ps1 ├── vRealize Operations Maintenance Mode.ps1 ├── vSphereLogins.ps1 ├── vTool_2016aug.ps1 ├── vlcm-sample-cmdlets │ └── vLCM-cmdlets.ps1 └── vmCreationNotes.ps1 └── resources ├── powercli-psgallery-icon.svg ├── vmw-ico-powercli-vmc-rgb_16px.svg ├── vmw-ico-powercli-vmc-rgb_400px.svg └── vmw-prod-icon-powercli_vert.svg /.gitattributes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/.gitattributes -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # PowerShell Studio Files 2 | *.temppoint.* 3 | *.psproj.psbuild 4 | *.psbuild 5 | 6 | #VS Code Files 7 | *.vscode 8 | /.vs 9 | 10 | # Windows image file caches 11 | Thumbs.db 12 | ehthumbs.db 13 | 14 | # Folder config file 15 | Desktop.ini 16 | 17 | # Recycle Bin used on file shares 18 | $RECYCLE.BIN/ 19 | 20 | # Windows Installer files 21 | *.cab 22 | *.msi 23 | *.msm 24 | *.msp 25 | 26 | # Windows shortcuts 27 | *.lnk 28 | 29 | # ========================= 30 | # Operating System Files 31 | # ========================= 32 | 33 | # OSX 34 | # ========================= 35 | 36 | .DS_Store 37 | .AppleDouble 38 | .LSOverride 39 | 40 | # Thumbnails 41 | ._* 42 | 43 | # Files that might appear on external disk 44 | .Spotlight-V100 45 | .Trashes 46 | 47 | # Directories potentially created on remote AFP share 48 | .AppleDB 49 | .AppleDesktop 50 | Network Trash Folder 51 | Temporary Items 52 | .apdisk 53 | /Modules/VMware.vSphere.SsoAdmin/ForPSGallery/VMware.vSphere.SsoAdmin 54 | -------------------------------------------------------------------------------- /DSC/README.md: -------------------------------------------------------------------------------- 1 | DSC Resources 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | PowerCLI-Example-Scripts 2 | Copyright 2021 VMware, Inc. 3 | 4 | BSD 2-Clause License 5 | 6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 9 | 10 | 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. 11 | 12 | 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. 13 | -------------------------------------------------------------------------------- /Modules/NSXT/NSXT.psd1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | @{ 6 | ModuleToProcess = 'NSXT.psm1' 7 | ModuleVersion = '1.0.0.0' 8 | GUID = 'c72f4e3d-5d1d-498f-ba86-6fa03e4ae6dd' 9 | Author = 'William Lam' 10 | CompanyName = 'primp-industries.com' 11 | Copyright = '(c) 2017. All rights reserved.' 12 | Description = 'Powershell Module for NSX-T REST API Functions' 13 | PowerShellVersion = '5.0' 14 | FunctionsToExport = 'Get-NSXTBGPNeighbors', 15 | 'Get-NSXTComputeManager', 16 | 'Get-NSXTController', 17 | 'Get-NSXTEdgeCluster', 18 | 'Get-NSXTFabricNode', 19 | 'Get-NSXTFabricVM', 20 | 'Get-NSXTFirewallRule', 21 | 'Get-NSXTForwardingTable', 22 | 'Get-NSXTIPPool', 23 | 'Get-NSXTLogicalRouter', 24 | 'Get-NSXTLogicalRouterPorts', 25 | 'Get-NSXTLogicalSwitch', 26 | 'Get-NSXTManager', 27 | 'Get-NSXTNetworkRoutes', 28 | 'Get-NSXTRoutingTable', 29 | 'Get-NSXTTraceFlow', 30 | 'Get-NSXTTraceFlowObservations', 31 | 'Get-NSXTTransportNode', 32 | 'Get-NSXTTransportZone', 33 | 'Get-NSXTClusterNode', 34 | 'Set-NSXTIPPool', 35 | 'Set-NSXTLogicalRouter', 36 | 'Set-NSXTLogicalSwitch', 37 | 'Set-NSXTTraceFlow', 38 | 'Get-NSXTIPAMIPBlock', 39 | 'Set-NSXTIPAMIPBlock', 40 | 'Remove-NSXTIPAMIPBlock' 41 | 42 | 43 | PrivateData = @{ 44 | PSData = @{ 45 | Tags = @('NSX-T','REST') 46 | LicenseUri = 'https://www.tldrlegal.com/l/mit' 47 | ProjectUri = 'https://github.com/lamw/PowerCLI-Example-Scripts/tree/master/Modules/NSXT' 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Modules/README.md: -------------------------------------------------------------------------------- 1 | Modules 2 | -------------------------------------------------------------------------------- /Modules/SRM/.gitattributes: -------------------------------------------------------------------------------- 1 | *.psd1 diff 2 | -------------------------------------------------------------------------------- /Modules/SRM/.gitignore: -------------------------------------------------------------------------------- 1 | *.zip -------------------------------------------------------------------------------- /Modules/SRM/Examples/SrmTagging.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2017-2021 VMware, Inc. 3 | SPDX-License-Identifier: Apache-2.0 4 | #> 5 | <# 6 | Copyright 2021 VMware, Inc. 7 | SPDX-License-Identifier: BSD-2-Clause 8 | #> 9 | 10 | # Depends on SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets 11 | # It is assumed that the connections to active VC and SRM Server have already been made 12 | 13 | Import-Module Meadowcroft.SRM -Prefix Srm 14 | 15 | $TagCategoryName = 'Meadowcroft.SRM.VM' 16 | $TagCategoryDescription = 'Tag category for tagging VMs with SRM state' 17 | 18 | # If the tag category doesn't exist, create it and the relevant tags 19 | $TagCategory = Get-TagCategory -Name $TagCategoryName -ErrorAction SilentlyContinue 20 | if (-Not $TagCategory) { 21 | Write-Output "Creating Tag Category $TagCategoryName" 22 | $TagCategory = New-TagCategory -Name $TagCategoryName -Description $TagCategoryDescription -EntityType 'VirtualMachine' 23 | 24 | Write-Output "Creating Tag SrmProtectedVm" 25 | New-Tag -Name 'SrmProtectedVm' -Category $TagCategory -Description "VM protected by VMware SRM" 26 | Write-Output "Creating Tag SrmTestVm" 27 | New-Tag -Name 'SrmTestVm' -Category $TagCategory -Description "Test VM instantiated by VMware SRM" 28 | Write-Output "Creating Tag SrmPlaceholderVm" 29 | New-Tag -Name 'SrmPlaceholderVm' -Category $TagCategory -Description "Placeholder VM used by VMware SRM" 30 | } 31 | 32 | $protectedVmTag = Get-Tag -Name 'SrmProtectedVm' -Category $TagCategory 33 | $testVmTag = Get-Tag -Name 'SrmTestVm' -Category $TagCategory 34 | $placeholderVmTag = Get-Tag -Name 'SrmPlaceholderVm' -Category $TagCategory 35 | 36 | # Assign protected tag to a VM, use ready state to get "local" protected VMs 37 | Get-SrmProtectedVM -State Ready | %{ New-TagAssignment -Tag $protectedVmTag -Entity $(Get-VIObjectByVIView $_.Vm) | Out-Null } 38 | 39 | # Assign test tag to a VM 40 | Get-SrmTestVM | %{ New-TagAssignment -Tag $testVmTag -Entity $_ | Out-Null } 41 | 42 | # Assign placeholder tag to a VM 43 | Get-SrmPlaceholderVM | %{ New-TagAssignment -Tag $placeholderVmTag -Entity $_ | Out-Null } 44 | -------------------------------------------------------------------------------- /Modules/SRM/Meadowcroft.Srm.Storage.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2017-2021 VMware, Inc. 3 | SPDX-License-Identifier: Apache-2.0 4 | #> 5 | <# 6 | Copyright 2021 VMware, Inc. 7 | SPDX-License-Identifier: BSD-2-Clause 8 | #> 9 | 10 | # SRM Helper Methods - https://github.com/benmeadowcroft/SRM-Cmdlets 11 | 12 | <# 13 | .SYNOPSIS 14 | Trigger Discover Devices for Site Recovery Manager 15 | 16 | .OUTPUTS 17 | Returns discover devices task 18 | #> 19 | Function Start-DiscoverDevice { 20 | [cmdletbinding(SupportsShouldProcess=$True, ConfirmImpact="Medium")] 21 | [OutputType([VMware.VimAutomation.Srm.Views.DiscoverDevicesTask])] 22 | Param( 23 | [VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer 24 | ) 25 | 26 | $api = Get-ServerApiEndpoint -SrmServer $SrmServer 27 | $name = $SrmServer.Name 28 | [VMware.VimAutomation.Srm.Views.DiscoverDevicesTask] $task = $null 29 | if ($pscmdlet.ShouldProcess($name, "Rescan Storage Devices")) { 30 | $task = $api.Storage.DiscoverDevices() 31 | } 32 | return $task 33 | } 34 | -------------------------------------------------------------------------------- /Modules/SRM/NOTICE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2017-2021 VMware, Inc. All Rights Reserved. 3 | 4 | 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. 5 | 6 | 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. 7 | 8 | Copyright (c) 2021 VMware, Inc. All Rights Reserved. 9 | 10 | This product is licensed to you under the BSD-2-Clause License. You may not use this product except in compliance with the License. 11 | -------------------------------------------------------------------------------- /Modules/SaltStackConfig/SaltStackConfig.Format.ps1xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SscConnection 6 | 7 | SscConnection 8 | 9 | 10 | 11 | 12 | 30 13 | 14 | 15 | 16 | 30 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Name 28 | 29 | 30 | User 31 | 32 | 33 | Authenticated 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Modules/VISecret/README.md: -------------------------------------------------------------------------------- 1 | # Example module for using SecretManagement and SecretStore to save PowerCLI credentials 2 | 3 | 4 | 5 | This module demonstrates how users can use the the Microsoft.PowerShell.SecretManagement and Microsoft.PowerShell.SecretStore modules to save their PowerCLI credentials. 6 | 7 | The module supports PowerShell 5.1 and PowerShell 7.0 and above. -------------------------------------------------------------------------------- /Modules/VMFSIncrease/LICENSE.txt.URL: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://github.com/lucdekens/LogInsight/blob/v1.0/LICENSE.txt 3 | IDList= 4 | HotKey=0 5 | IconFile=C:\Users\ldekens\AppData\Local\Mozilla\Firefox\Profiles\2ahnnh1i.default\shortcutCache\ec4nFcIEAQBPFmSiPtTJ2w==.ico 6 | IconIndex=0 7 | -------------------------------------------------------------------------------- /Modules/VMFSIncrease/VMFSIncrease.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleToProcess = 'VMFSIncrease.psm1' 3 | ModuleVersion = '1.0.0.0' 4 | GUID = '9f167385-c5c6-4a65-ac14-949c67519001' 5 | Author = 'Luc Dekens ' 6 | CompanyName = 'Community' 7 | Copyright = '(c) 2016. All rights reserved.' 8 | Description = 'Expand and Extend VMFS DatastoresModule description' 9 | PowerShellVersion = '3.0' 10 | FunctionsToExport = 'Get-VmfsDatastoreInfo','Get-VmfsDatastoreIncrease','New-VmfsDatastoreIncrease' 11 | PrivateData = @{ 12 | PSData = @{ 13 | Tags = @('VMFS','Expand','Extend','vSphere') 14 | LicenseUri = 'https://www.tldrlegal.com/l/mit' 15 | ProjectUri = 'https://github.com/lucdekens/VMFSIncrease' 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Modules/VMFSIncrease/en-US/about_VMFSIncrease.help.txt: -------------------------------------------------------------------------------- 1 | TOPIC 2 | VMFSIncrease 3 | 4 | SYNOPSIS 5 | The VMFSIncrease module offers the same functionality that is available 6 | through the Increase button in the vSphere Web Client. 7 | 8 | DESCRIPTION 9 | The VMFSIncrease offers functionality that allows to Expand or Extend 10 | VMFS Datastores. The module uses the vSphere API to implement this functionality. 11 | 12 | SEE ALSO 13 | http://www.lucd.info/2016/07/29/vmfs-datastores-expand-and-extend 14 | -------------------------------------------------------------------------------- /Modules/VMware-vCD-Module/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Markus Kraus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Modules/VMware-vCD-Module/README.md: -------------------------------------------------------------------------------- 1 | VMware-vCD-Module PowerShell Module 2 | =================================== 3 | 4 | ![Invoke-MyOnBoarding](/media/Invoke-MyOnBoarding.png) 5 | 6 | # About 7 | 8 | ## Project Owner: 9 | 10 | Markus Kraus [@vMarkus_K](https://twitter.com/vMarkus_K) 11 | 12 | MY CLOUD-(R)EVOLUTION [mycloudrevolution.com](http://mycloudrevolution.com/) 13 | 14 | 15 | ## Project WebSite: 16 | [PowerCLI vCloud Director Customer Provisioning](https://mycloudrevolution.com/2017/06/13/powercli-vcloud-director-customer-provisioning/) 17 | 18 | [PowerCLI – Create vCloud Director Edge Gateway](https://mycloudrevolution.com/2017/06/27/powercli-create-vcloud-director-edge-gateway/) 19 | 20 | 21 | ## Project Documentation: 22 | 23 | [Read the Docs - VMware-vCD-Module](http://vmware-vcd-module.readthedocs.io/) 24 | 25 | ## Project Description: 26 | 27 | The 'VMware-vCD-Module' PowerShell Module is focused on the initial creation of VMware vCloud Director Objects like Org, Org User, Org VDC with External Networks or Edge Gateway. 28 | 29 | All Functions in this Module can be used as standalone Cmdlet but also the ``Invoke-My OnBoarding`` Functions to process a JSON File and create all Objects at once. 30 | 31 | ### Fully tested Versions: 32 | 33 | Powershell: v4, v5 34 | 35 | PowerCLI: 6.5.1 36 | 37 | VMware vCloud Director: 8.10.1 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Modules/VMware-vCD-Module/examples/OnBoarding.json: -------------------------------------------------------------------------------- 1 | { 2 | "Org": { 3 | "Name":"TestOrg", 4 | "FullName": "Test Org", 5 | "Description":"Automation Test Org" 6 | }, 7 | "OrgAdmin": { 8 | "Name":"TestOrgAdmin", 9 | "Pasword": "myPassword1!", 10 | "FullName":"Test OrgAdmin", 11 | "EmailAddress":"test@admin.org" 12 | }, 13 | "OrgVdc": { 14 | "Name":"TestOrgVdc", 15 | "FixedSize": "M", 16 | "CPULimit": "1000", 17 | "MEMLimit":"1024", 18 | "StorageLimit":"1024", 19 | "StorageProfile":"Standard-DC01", 20 | "ProviderVDC":"Provider-VDC-DC01", 21 | "NetworkPool":"Provider-VDC-DC01-NetPool", 22 | "ExternalNetwork": "External-OrgVdcNet", 23 | "EdgeGateway": "Yes", 24 | "IPAddress":"192.168.100.1", 25 | "SubnetMask":"255.255.255.0", 26 | "Gateway":"192.168.100.254", 27 | "IPRangeStart":"192.168.100.2", 28 | "IPRangeEnd":"192.168.100.3" 29 | } 30 | } -------------------------------------------------------------------------------- /Modules/VMware-vCD-Module/media/Invoke-MyOnBoarding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware-vCD-Module/media/Invoke-MyOnBoarding.png -------------------------------------------------------------------------------- /Modules/VMware-vCD-Module/media/VSCode-Pester-Tests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware-vCD-Module/media/VSCode-Pester-Tests.png -------------------------------------------------------------------------------- /Modules/VMware-vCD-Module/tests/VMware-vCD-Module.Tests.ps1: -------------------------------------------------------------------------------- 1 | $moduleRoot = Resolve-Path "$PSScriptRoot\.." 2 | $moduleName = "VMware-vCD-Module" 3 | $ConfigFile = "$moduleRoot\examples\OnBoarding.json" 4 | 5 | Describe "General project validation: $moduleName" { 6 | 7 | $scripts = Get-ChildItem $moduleRoot -Include *.ps1, *.psm1, *.psd1 -Recurse 8 | 9 | # TestCases are splatted to the script so we need hashtables 10 | $testCase = $scripts | Foreach-Object {@{file = $_}} 11 | It "Script should be valid powershell" -TestCases $testCase { 12 | param($file) 13 | 14 | $file.fullname | Should Exist 15 | 16 | $contents = Get-Content -Path $file.fullname -ErrorAction Stop 17 | $errors = $null 18 | $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) 19 | $errors.Count | Should Be 0 20 | } 21 | 22 | It "Module '$moduleName' prerequirements are met" { 23 | {Import-Module VMware.VimAutomation.Cloud -Force} | Should Not Throw 24 | } 25 | 26 | It "Module '$moduleName' can import cleanly" { 27 | {Import-Module (Join-Path $moduleRoot "$moduleName.psd1") -force } | Should Not Throw 28 | } 29 | 30 | It "Module '$moduleName' JSON example is valid" { 31 | {Get-Content -Raw -Path $ConfigFile | ConvertFrom-Json} | Should Not Throw 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Modules/VMware-vCD-TenantReport/README.md: -------------------------------------------------------------------------------- 1 | VMware-vCD-TenantReport PowerShell Module 2 | ============= 3 | 4 | # About 5 | 6 | ## Project Owner: 7 | 8 | Markus Kraus [@vMarkus_K](https://twitter.com/vMarkus_K) 9 | 10 | MY CLOUD-(R)EVOLUTION [mycloudrevolution.com](http://mycloudrevolution.com/) 11 | 12 | ## Project WebSite: 13 | 14 | [mycloudrevolution.com](http://mycloudrevolution.com/) 15 | 16 | ## Project Documentation: 17 | 18 | [Read the Docs](http://readthedocs.io/) 19 | 20 | ## Project Description: 21 | 22 | The 'VMware-vCD-TenantReport' PowerShell Module creates with the Fuction 'Get-VcdTenantReport' a HTML Report of your vCloud Director Objects. 23 | 24 | ![Get-VcdTenantReport](/media/Get-VcdTenantReport.png) 25 | 26 | Big thanks to [Timothy Dewin](https://twitter.com/tdewin) for his great [PowerStartHTML](https://github.com/tdewin/randomsamples/tree/master/powerstarthtml) PowerShell Module which is used to generate the Report for this Module. 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Modules/VMware-vCD-TenantReport/media/Get-VcdTenantReport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware-vCD-TenantReport/media/Get-VcdTenantReport.png -------------------------------------------------------------------------------- /Modules/VMware-vCD-TenantReport/modules/PowerStartHTML/PowerStartHTML.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware-vCD-TenantReport/modules/PowerStartHTML/PowerStartHTML.psd1 -------------------------------------------------------------------------------- /Modules/VMware-vCD-TenantReport/tests/VMware-vCD-TenantReport.Tests.ps1: -------------------------------------------------------------------------------- 1 | $moduleRoot = Resolve-Path "$PSScriptRoot\.." 2 | $moduleName = "VMware-vCD-TenantReport" 3 | 4 | Describe "General project validation: $moduleName" { 5 | 6 | $scripts = Get-ChildItem $moduleRoot -Include *.ps1, *.psm1, *.psd1 -Recurse 7 | 8 | # TestCases are splatted to the script so we need hashtables 9 | $testCase = $scripts | Foreach-Object {@{file = $_}} 10 | It "Script should be valid powershell" -TestCases $testCase { 11 | param($file) 12 | 13 | $file.fullname | Should Exist 14 | 15 | $contents = Get-Content -Path $file.fullname -ErrorAction Stop 16 | $errors = $null 17 | $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) 18 | $errors.Count | Should Be 0 19 | } 20 | 21 | It "Module '$moduleName' can import cleanly" { 22 | {Import-Module (Join-Path $moduleRoot "$moduleName.psd1") -force } | Should Not Throw 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Modules/VMware.DRaaS/VMware.DRaaS.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.DRaaS/VMware.DRaaS.psd1 -------------------------------------------------------------------------------- /Modules/VMware.Hosted/VMware.Hosted.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleToProcess = 'VMware.Hosted.psm1' 3 | ModuleVersion = '1.0.0.0' 4 | GUID = '11393D09-D6B8-4E79-B9BC-247F1BE66683' 5 | Author = 'William Lam' 6 | CompanyName = 'primp-industries.com' 7 | Copyright = '(c) 2017. All rights reserved.' 8 | Description = 'Powershell Module for VMware Fusion 10 REST API' 9 | PowerShellVersion = '5.0' 10 | FunctionsToExport = 'Get-HostedCommand','Connect-HostedServer','Disconnect-HostedServer','Get-HostedVM','Start-HostedVM','Stop-HostedVM','Suspend-HostedVM','Resume-HostedVM','New-HostedVM','Remove-HostedVM','Get-HostedVMSharedFolder','New-HostedVMSharedFolder','Remove-HostedVMSharedFolder','Get-HostedVMNic','Get-HostedNetworks' 11 | PrivateData = @{ 12 | PSData = @{ 13 | Tags = @('Fusion','REST','vmrest') 14 | LicenseUri = 'https://www.tldrlegal.com/l/mit' 15 | ProjectUri = 'https://github.com/lamw/PowerCLI-Example-Scripts/tree/master/Modules/VMware.Hosted' 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/Json/Farm/ManualFarm.json: -------------------------------------------------------------------------------- 1 | { 2 | "Type": "MANUAL", 3 | "Data": { 4 | "Name": "manualFarmTest", 5 | "DisplayName": "manualFarmTest", 6 | "AccessGroup": "Root", 7 | "Description": "Manual PS Test", 8 | "Enabled": null, 9 | "Deleting": false, 10 | "Settings": { 11 | "DisconnectedSessionTimeoutPolicy" : "NEVER", 12 | "DisconnectedSessionTimeoutMinutes" : 1, 13 | "EmptySessionTimeoutPolicy" : "AFTER", 14 | "EmptySessionTimeoutMinutes" : 1, 15 | "LogoffAfterTimeout" : false 16 | }, 17 | "Desktop": null, 18 | "DisplayProtocolSettings": { 19 | "DefaultDisplayProtocol" : "PCOIP", 20 | "AllowDisplayProtocolOverride" : false, 21 | "EnableHTMLAccess" : false 22 | }, 23 | "ServerErrorThreshold": null, 24 | "MirageConfigurationOverrides": { 25 | "OverrideGlobalSetting" : false, 26 | "Enabled" : false, 27 | "Url" : null 28 | } 29 | }, 30 | "AutomatedFarmSpec": null, 31 | "ManualFarmSpec": { 32 | "RdsServers": [ 33 | { 34 | "rdsServer": "RDSServer.adviewdev.eng.vmware.com" 35 | } 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/Json/Pool/RdsSpec.json: -------------------------------------------------------------------------------- 1 | { 2 | "Base": { 3 | "Name" : "RdsJson", 4 | "DisplayName": "TestRDSPS", 5 | "AccessGroup": "Root", 6 | "Description": "Testing PS" 7 | }, 8 | "DesktopSettings": { 9 | "enabled": true, 10 | "deleting": false, 11 | "connectionServerRestrictions": null, 12 | "logoffSettings": null, 13 | "displayProtocolSettings": null, 14 | "flashSettings": { 15 | "quality": "NO_CONTROL", 16 | "throttling": "DISABLED" 17 | }, 18 | "mirageConfigurationOverrides": null 19 | }, 20 | "Type": "RDS", 21 | "AutomatedDesktopSpec": null, 22 | "ManualDesktopSpec": null, 23 | "RdsDesktopSpec": { 24 | "Farm": "test1" 25 | }, 26 | "GlobalEntitlementData": null 27 | } 28 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/README.md: -------------------------------------------------------------------------------- 1 | # Prerequisites/Steps to use this module 2 | 3 | 1. This module only works for Horizon product E.g. Horizon 7.0.2 and later. 4 | 2. Install the latest version of Powershell, PowerCLI(6.5) or (later version via psgallery). 5 | 3. Import HorizonView module by running: Import-Module VMware.VimAutomation.HorizonView. 6 | 4. Import "VMware.Hv.Helper" module by running: Import-Module -Name "location of this module" or Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module. 7 | 5. Get-Command -Module "This module Name" to list all available functions or Get-Command -Module 'VMware.Hv.Helper'. 8 | 9 | # Example script to connect ViewAPI service 10 | 11 | ``` 12 | Import-Module VMware.VimAutomation.HorizonView 13 | 14 | # Connection to view API service 15 | $hvServer = Connect-HVServer -server 16 | $hvServices = $hvserver.ExtensionData 17 | 18 | # List Connection Servers 19 | $csList = $hvServices.ConnectionServer.ConnectionServer_List() 20 | ``` 21 | # Load this module 22 | ``` 23 | Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module 24 | Get-Command -Module 'VMware.Hv.Helper' 25 | ``` 26 | # Use advanced functions of this module 27 | ``` 28 | New-HVPool -spec 'path to InstantClone.json file' 29 | ``` 30 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/Set-HVFarm/AutomatedEditFarm.json: -------------------------------------------------------------------------------- 1 | { 2 | "data.description" : "update through edit farm function", 3 | "data.displayName" : "LCFarmTestUpdated1", 4 | "data.displayProtocolSettings.defaultDisplayProtocol" : "PCOIP", 5 | "automatedFarmData.virtualCenterManagedCommonSettings.transparentPageSharingScope" : "FARM" 6 | } -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/Set-HVFarm/ManualEditFarm.json: -------------------------------------------------------------------------------- 1 | { 2 | "data.description" : "update through edit farm function", 3 | "data.displayName" : "ManualFarmTestUpdated1", 4 | "data.displayProtocolSettings.defaultDisplayProtocol" : "PCOIP" 5 | } -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/Set-HVGlobalSettings/Set-HVGlobalSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "generalData.clientMaxSessionTimePolicy": "TIMEOUT_AFTER", 3 | "generalData.clientMaxSessionTimeMinutes": 600, 4 | "generalData.clientIdleSessionTimeoutPolicy": "NEVER", 5 | "generalData.clientIdleSessionTimeoutMinutes": null, 6 | "generalData.clientSessionTimeoutMinutes": 1200, 7 | "generalData.desktopSSOTimeoutPolicy": "DISABLE_AFTER", 8 | "generalData.desktopSSOTimeoutMinutes": 15, 9 | "generalData.applicationSSOTimeoutPolicy": "ALWAYS_ENABLED", 10 | "generalData.applicationSSOTimeoutMinutes": null, 11 | "generalData.viewAPISessionTimeoutMinutes": 10, 12 | "generalData.preLoginMessage": null, 13 | "generalData.displayWarningBeforeForcedLogoff": true, 14 | "generalData.forcedLogoffTimeoutMinutes": 5, 15 | "generalData.forcedLogoffMessage": "Your desktop is scheduled for an important update and will shut down in 5 minutes. Please save any unsaved work now", 16 | "generalData.enableServerInSingleUserMode": false, 17 | "generalData.storeCALOnBroker": false, 18 | "generalData.storeCALOnClient": false, 19 | "securityData.reauthSecureTunnelAfterInterruption": true, 20 | "securityData.messageSecurityMode": "ENHANCED", 21 | "securityData.enableIPSecForSecurityServerPairing": true 22 | } -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/Set-HVPool/AutomatedEditPool.Json: -------------------------------------------------------------------------------- 1 | { 2 | "base.description" : "update through edit pool function", 3 | "base.displayName" : "Henry2DspNm", 4 | "desktopSettings.displayProtocolSettings.defaultDisplayProtocol" : "BLAST", 5 | "automatedDesktopData.virtualCenterProvisioningSettings.virtualCenterStorageSettings.viewStorageAcceleratorSettings.useViewStorageAccelerator" : true, 6 | "automatedDesktopData.virtualCenterProvisioningSettings.virtualCenterStorageSettings.viewStorageAcceleratorSettings.viewComposerDiskTypes" : "OS_DISKS", 7 | "automatedDesktopData.virtualCenterProvisioningSettings.virtualCenterStorageSettings.viewStorageAcceleratorSettings.regenerateViewStorageAcceleratorDays" : 8 8 | } -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/Set-HVPool/ManualEditPool.json: -------------------------------------------------------------------------------- 1 | { 2 | "base.description" : "update through edit pool", 3 | "base.displayName" : "pooldisp", 4 | "desktopSettings.displayProtocolSettings.defaultDisplayProtocol" : "BLAST", 5 | "manualDesktopData.viewStorageAcceleratorSettings.useViewStorageAccelerator" : true, 6 | "manualDesktopData.viewStorageAcceleratorSettings.viewComposerDiskTypes" : "OS_DISKS", 7 | "manualDesktopData.viewStorageAcceleratorSettings.regenerateViewStorageAcceleratorDays" : 8 8 | } -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/Set-HVPool/RdsEditPool.json: -------------------------------------------------------------------------------- 1 | { 2 | "base.description" : "update through edit pool function", 3 | "base.displayName" : "RDS2DspNm", 4 | "desktopSettings.flashSettings.quality" : "LOW", 5 | "desktopSettings.flashSettings.throttling" : "CONSERVATIVE" 6 | } -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Disconnect-HVEvent.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Disconnect-HVEvent 9 | 10 | ## SYNOPSIS 11 | This function is used to disconnect the database connection. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Disconnect-HVEvent [-HvDbServer] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | This function will disconnect the database connection made earlier during Connect-HVEvent function. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Disconnect-HVEvent -HvDbServer $hvDbServer 27 | ``` 28 | 29 | Disconnecting the database connection on $hvDbServer. 30 | 31 | ## PARAMETERS 32 | 33 | ### -HvDbServer 34 | Connection object returned by Connect-HVEvent advanced function. 35 | This is a mandatory input. 36 | 37 | ```yaml 38 | Type: PSObject 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: True 43 | Position: 1 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### CommonParameters 50 | 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). 51 | 52 | ## INPUTS 53 | 54 | ## OUTPUTS 55 | 56 | ### None 57 | ## NOTES 58 | | | | 59 | |-|-| 60 | | Author | Paramesh Oddepally. | 61 | | Author email | poddepally@vmware.com | 62 | | Version | 1.1 | 63 | 64 | ===Tested Against Environment==== 65 | | | | 66 | |-|-| 67 | | Horizon View Server Version | 7.0.2, 7.1.0 | 68 | | PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 | 69 | | PowerShell Version | 5.0 | 70 | 71 | ## RELATED LINKS 72 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVEventDatabase.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVEventDatabase 9 | 10 | ## SYNOPSIS 11 | Retreives information about the configured Event Database 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVEventDatabase [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Collects information about the configured event database for aHorizon View pod 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-HVEventDatabase 27 | ``` 28 | 29 | ## PARAMETERS 30 | 31 | ### -HvServer 32 | Reference to Horizon View Server to query the virtual machines from. 33 | If the value is not passed or null then 34 | first element from global:DefaultHVServers would be considered in-place of hvServer 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | 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). 50 | 51 | ## INPUTS 52 | 53 | ## OUTPUTS 54 | 55 | ## NOTES 56 | | | | 57 | |-|-| 58 | | Author | Wouter Kursten | 59 | | Author email | wouter@retouw.nl | 60 | | Version | 1.0 | 61 | 62 | ===Tested Against Environment==== 63 | | | | 64 | |-|-| 65 | | Horizon View Server Version | 7.4 | 66 | | PowerCLI Version | PowerCLI 10 | 67 | | PowerShell Version | 5.0 | 68 | 69 | ## RELATED LINKS 70 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVGlobalSession.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVGlobalSession 9 | 10 | ## SYNOPSIS 11 | Provides a list with all Global sessions in a Cloud Pod Architecture 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVGlobalSession [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | The get-hvglobalsession gets all local session by using view API service object(hvServer) of Connect-HVServer cmdlet. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-hvglobalsession 27 | ``` 28 | 29 | Gets all global sessions 30 | 31 | ## PARAMETERS 32 | 33 | ### -HvServer 34 | View API service object of Connect-HVServer cmdlet. 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | 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). 50 | 51 | ## INPUTS 52 | 53 | ## OUTPUTS 54 | 55 | ## NOTES 56 | | | | 57 | |-|-| 58 | | Author | Wouter Kursten. | 59 | | Author email | wouter@retouw.nl | 60 | | Version | 1.0 | 61 | 62 | ===Tested Against Environment==== 63 | | | | 64 | |-|-| 65 | | Horizon View Server Version | 7.0.2, 7.1.0, 7.3.2 | 66 | | PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 | 67 | | PowerShell Version | 5.0 | 68 | 69 | ## RELATED LINKS 70 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVGlobalSettings.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVGlobalSettings 9 | 10 | ## SYNOPSIS 11 | Gets a list of Global Settings 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVGlobalSettings [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Queries and returns the Global Settings for the pod of the specified HVServer. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-HVGlobalSettings 27 | ``` 28 | 29 | ## PARAMETERS 30 | 31 | ### -HvServer 32 | Reference to Horizon View Server to query the virtual machines from. 33 | If the value is not passed or null then 34 | first element from global:DefaultHVServers would be considered inplace of hvServer 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | 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). 50 | 51 | ## INPUTS 52 | 53 | ## OUTPUTS 54 | 55 | ### Returns list of object type VMware.Hv.GlobalSettingsInfo 56 | ## NOTES 57 | | | | 58 | |-|-| 59 | | Author | Matt Frey. | 60 | | Author email | mfrey@vmware.com | 61 | | Version | 1.0 | 62 | 63 | ===Tested Against Environment==== 64 | | | | 65 | |-|-| 66 | | Horizon View Server Version | 7.1 | 67 | | PowerCLI Version | PowerCLI 6.5.1 | 68 | | PowerShell Version | 5.0 | 69 | 70 | ## RELATED LINKS 71 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVHomeSite.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVHomeSite 9 | 10 | ## SYNOPSIS 11 | Gets the configured Horizon View Homesites 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVHomeSite [[-Group] ] [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Gets the configured Horizon View Homesites 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-HVHomeSite 27 | ``` 28 | 29 | ### EXAMPLE 2 30 | ``` 31 | Get-HVHomeSite -group group@domain 32 | ``` 33 | 34 | ## PARAMETERS 35 | 36 | ### -Group 37 | User principal name of a group 38 | 39 | ```yaml 40 | Type: String 41 | Parameter Sets: (All) 42 | Aliases: 43 | 44 | Required: False 45 | Position: 1 46 | Default value: None 47 | Accept pipeline input: False 48 | Accept wildcard characters: False 49 | ``` 50 | 51 | ### -HvServer 52 | Reference to Horizon View Server to query the virtual machines from. 53 | If the value is not passed or null then 54 | first element from global:DefaultHVServers would be considered in-place of hvServer 55 | 56 | ```yaml 57 | Type: Object 58 | Parameter Sets: (All) 59 | Aliases: 60 | 61 | Required: False 62 | Position: 2 63 | Default value: None 64 | Accept pipeline input: False 65 | Accept wildcard characters: False 66 | ``` 67 | 68 | ### CommonParameters 69 | 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). 70 | 71 | ## INPUTS 72 | 73 | ## OUTPUTS 74 | 75 | ## NOTES 76 | | | | 77 | |-|-| 78 | | Author | Wouter Kursten | 79 | | Author email | wouter@retouw.nl | 80 | | Version | 1.0 | 81 | 82 | ===Tested Against Environment==== 83 | | | | 84 | |-|-| 85 | | Horizon View Server Version | 7.4 | 86 | | PowerCLI Version | PowerCLI 10 | 87 | | PowerShell Version | 5.0 | 88 | 89 | ## RELATED LINKS 90 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVLocalSession.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVLocalSession 9 | 10 | ## SYNOPSIS 11 | Provides a list with all sessions on the local pod (works in CPA and non-CPA) 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVLocalSession [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | The Get-HVLocalSession gets all local session by using view API service object(hvServer) of Connect-HVServer cmdlet. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-HVLocalSession 27 | ``` 28 | 29 | Get all local sessions 30 | 31 | ## PARAMETERS 32 | 33 | ### -HvServer 34 | View API service object of Connect-HVServer cmdlet. 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | 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). 50 | 51 | ## INPUTS 52 | 53 | ## OUTPUTS 54 | 55 | ## NOTES 56 | | | | 57 | |-|-| 58 | Author : Wouter Kursten. 59 | Author email : wouter@retouw.nl 60 | Version : 1.0 61 | 62 | ===Tested Against Environment==== 63 | | | | 64 | |-|-| 65 | Horizon View Server Version : 7.0.2, 7.1.0, 7.3.2 66 | PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 67 | PowerShell Version : 5.0 68 | 69 | ## RELATED LINKS 70 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVPodFederation.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVPodFederation 9 | 10 | ## SYNOPSIS 11 | Returns information about a Horizon View Pod Federation (Cloud Pod Architecture) 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVPodFederation [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Returns information about a Horizon View Pod Federation (Cloud Pod Architecture) 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-HVPodFederation 27 | ``` 28 | 29 | Returns information about a Horizon View Pod Federation 30 | 31 | ## PARAMETERS 32 | 33 | ### -HvServer 34 | Reference to Horizon View Server to query the virtual machines from. 35 | If the value is not passed or null then 36 | first element from global:DefaultHVServers would be considered in-place of hvServer 37 | 38 | ```yaml 39 | Type: Object 40 | Parameter Sets: (All) 41 | Aliases: 42 | 43 | Required: False 44 | Position: 1 45 | Default value: None 46 | Accept pipeline input: False 47 | Accept wildcard characters: False 48 | ``` 49 | 50 | ### CommonParameters 51 | 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). 52 | 53 | ## INPUTS 54 | 55 | ## OUTPUTS 56 | 57 | ## NOTES 58 | | | | 59 | |-|-| 60 | | Author | Wouter Kursten | 61 | | Author email | wouter@retouw.nl | 62 | | Version | 1.0 | 63 | 64 | ===Tested Against Environment==== 65 | | | | 66 | |-|-| 67 | | Horizon View Server Version | 7.3.2,7.4 | 68 | | PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 | 69 | | PowerShell Version | 5.0 | 70 | 71 | ## RELATED LINKS 72 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVPreInstalledApplication.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVPreInstalledApplication 9 | 10 | ## SYNOPSIS 11 | Gets the list of Pre-installed Applications from the RDS Server(s). 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVPreInstalledApplication [-FarmName] [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Gets the list of Pre-installed Applications from the RDS Server(s). 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-HVPreInstalledApplication -FarmName 'Farm1' -HvServer $HvServer 27 | ``` 28 | 29 | Gets the list of Applications present in 'Farm1', if exists. 30 | 31 | ## PARAMETERS 32 | 33 | ### -FarmName 34 | Name of the Farm on which to discover installed applications. 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: True (ByValue) 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -HvServer 49 | View API service object of Connect-HVServer cmdlet. 50 | 51 | ```yaml 52 | Type: Object 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: 2 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | 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). 65 | 66 | ## INPUTS 67 | 68 | ## OUTPUTS 69 | 70 | ### Gets the list of Applications from the specified Farm if exists. 71 | ## NOTES 72 | | | | 73 | |-|-| 74 | | Author | Samiullasha S | 75 | | Author email | ssami@vmware.com | 76 | | Version | 1.0 | 77 | 78 | ===Tested Against Environment==== 79 | | | | 80 | |-|-| 81 | | Horizon View Server Version | 7.8.0 | 82 | | PowerCLI Version | PowerCLI 11.1 | 83 | | PowerShell Version | 5.0 | 84 | 85 | ## RELATED LINKS 86 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVResourceStructure.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVResourceStructure 9 | 10 | ## SYNOPSIS 11 | Output the structure of the resource pools available to a HV. 12 | Primarily this is for debugging 13 | 14 | PS\> Get-HVResourceStructure 15 | vCenter vc.domain.local 16 | Container DC path /DC/host 17 | HostOrCluster Servers path /DC/host/Servers 18 | HostOrCluster VDI path /DC/host/VDI 19 | ResourcePool Servers path /DC/host/Servers/Resources 20 | ResourcePool VDI path /DC/host/VDI/Resources 21 | ResourcePool RP1 path /DC/host/VDI/Resources/RP1 22 | ResourcePool RP2 path /DC/host/VDI/Resources/RP1/RP2 23 | 24 | | Author | Mark Elvers \ | 25 | 26 | ## SYNTAX 27 | 28 | ``` 29 | Get-HVResourceStructure [[-HvServer] ] [] 30 | ``` 31 | 32 | ## DESCRIPTION 33 | {{ Fill in the Description }} 34 | 35 | ## EXAMPLES 36 | 37 | ### Example 1 38 | ```powershell 39 | PS C:\> {{ Add example code here }} 40 | ``` 41 | 42 | {{ Add example description here }} 43 | 44 | ## PARAMETERS 45 | 46 | ### -HvServer 47 | {{ Fill HvServer Description }} 48 | 49 | ```yaml 50 | Type: Object 51 | Parameter Sets: (All) 52 | Aliases: 53 | 54 | Required: False 55 | Position: 1 56 | Default value: None 57 | Accept pipeline input: False 58 | Accept wildcard characters: False 59 | ``` 60 | 61 | ### CommonParameters 62 | 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). 63 | 64 | ## INPUTS 65 | 66 | ## OUTPUTS 67 | 68 | ## NOTES 69 | 70 | ## RELATED LINKS -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVSite.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVSite 9 | 10 | ## SYNOPSIS 11 | Returns information about the sites within a Horizon View Pod Federation (Cloud Pod Architecture) 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVSite [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Returns information about the sites within a Horizon View Pod Federation (Cloud Pod Architecture) 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | get-hvsite 27 | ``` 28 | 29 | Returns information about the sites within a Horizon View Pod Federation. 30 | 31 | ## PARAMETERS 32 | 33 | ### -HvServer 34 | Reference to Horizon View Server to query the virtual machines from. 35 | If the value is not passed or null then 36 | first element from global:DefaultHVServers would be considered in-place of hvServer 37 | 38 | ```yaml 39 | Type: Object 40 | Parameter Sets: (All) 41 | Aliases: 42 | 43 | Required: False 44 | Position: 1 45 | Default value: None 46 | Accept pipeline input: False 47 | Accept wildcard characters: False 48 | ``` 49 | 50 | ### CommonParameters 51 | 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). 52 | 53 | ## INPUTS 54 | 55 | ## OUTPUTS 56 | 57 | ## NOTES 58 | | | | 59 | |-|-| 60 | | Author | Wouter Kursten | 61 | | Author email | wouter@retouw.nl | 62 | | Version | 1.0 | 63 | 64 | ===Tested Against Environment==== 65 | | | | 66 | |-|-| 67 | | Horizon View Server Version | 7.3.2,7.4 | 68 | | PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 | 69 | | PowerShell Version | 5.0 | 70 | 71 | ## RELATED LINKS 72 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVlicense.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVlicense 9 | 10 | ## SYNOPSIS 11 | Gets the license for Horizon View 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVlicense [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Gets the license for Horizon View 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | get-hvlicense 27 | ``` 28 | 29 | ## PARAMETERS 30 | 31 | ### -HvServer 32 | Reference to Horizon View Server to query the virtual machines from. 33 | If the value is not passed or null then 34 | first element from global:DefaultHVServers would be considered in-place of hvServer 35 | 36 | ```yaml 37 | Type: Object 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | 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). 50 | 51 | ## INPUTS 52 | 53 | ## OUTPUTS 54 | 55 | ## NOTES 56 | | | | 57 | |-|-| 58 | | Author | Wouter Kursten | 59 | | Author email | wouter@retouw.nl | 60 | | Version | 1.0 | 61 | 62 | ===Tested Against Environment==== 63 | | | | 64 | |-|-| 65 | | Horizon View Server Version | 7.4,7.5 | 66 | | PowerCLI Version | PowerCLI 10 | 67 | | PowerShell Version | 5.0 | 68 | 69 | ## RELATED LINKS 70 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVvCenterServer.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVvCenterServer 9 | 10 | ## SYNOPSIS 11 | Gets a list of all configured vCenter Servers 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVvCenterServer [[-HvServer] ] [[-Name] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Queries and returns the vCenter Servers configured for the pod of the specified HVServer. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-HVvCenterServer 27 | ``` 28 | 29 | ### EXAMPLE 2 30 | ``` 31 | Get-HVvCenterServer -Name 'vCenter1' 32 | ``` 33 | 34 | ## PARAMETERS 35 | 36 | ### -HvServer 37 | Reference to Horizon View Server to query the virtual machines from. 38 | If the value is not passed or null then 39 | first element from global:DefaultHVServers would be considered inplace of hvServer 40 | 41 | ```yaml 42 | Type: Object 43 | Parameter Sets: (All) 44 | Aliases: 45 | 46 | Required: False 47 | Position: 1 48 | Default value: None 49 | Accept pipeline input: False 50 | Accept wildcard characters: False 51 | ``` 52 | 53 | ### -Name 54 | A string value to query a vCenter Server by Name, if it is known. 55 | 56 | ```yaml 57 | Type: String 58 | Parameter Sets: (All) 59 | Aliases: 60 | 61 | Required: False 62 | Position: 2 63 | Default value: None 64 | Accept pipeline input: False 65 | Accept wildcard characters: False 66 | ``` 67 | 68 | ### CommonParameters 69 | 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). 70 | 71 | ## INPUTS 72 | 73 | ## OUTPUTS 74 | 75 | ### Returns array of object type VMware.Hv.VirtualCenterInfo 76 | ## NOTES 77 | | | | 78 | |-|-| 79 | | Author | Matt Frey. | 80 | | Author email | mfrey@vmware.com | 81 | | Version | 1.0 | 82 | 83 | ===Tested Against Environment==== 84 | | | | 85 | |-|-| 86 | | Horizon View Server Version | 7.7 | 87 | | PowerCLI Version | PowerCLI 11.2.0 | 88 | | PowerShell Version | 5.1 | 89 | 90 | ## RELATED LINKS 91 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Get-HVvCenterServerHealth.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-HVvCenterServerHealth 9 | 10 | ## SYNOPSIS 11 | Gets a the health info for a given vCenter Server. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-HVvCenterServerHealth [[-HvServer] ] [[-VirtualCenter] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Queries and returns the VirtualCenterHealthInfo specified HVServer. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Get-HVvCenterServerHealth -VirtualCenter 'vCenter1' 27 | ``` 28 | 29 | ### EXAMPLE 2 30 | ``` 31 | Get-HVvCenterServerHealth -VirtualCenter $vCenter1 32 | ``` 33 | 34 | ### EXAMPLE 3 35 | ``` 36 | Get-HVvCenterServerHealth 37 | ``` 38 | 39 | ## PARAMETERS 40 | 41 | ### -HvServer 42 | Reference to Horizon View Server to query the virtual machines from. 43 | If the value is not passed or null then 44 | first element from global:DefaultHVServers would be considered inplace of hvServer 45 | 46 | ```yaml 47 | Type: Object 48 | Parameter Sets: (All) 49 | Aliases: 50 | 51 | Required: False 52 | Position: 1 53 | Default value: None 54 | Accept pipeline input: False 55 | Accept wildcard characters: False 56 | ``` 57 | 58 | ### -VirtualCenter 59 | A parameter to specify which vCenter Server to check health for. 60 | If not specified, this function will return the 61 | health info for all vCenter Servers. 62 | 63 | ```yaml 64 | Type: Object 65 | Parameter Sets: (All) 66 | Aliases: 67 | 68 | Required: False 69 | Position: 2 70 | Default value: None 71 | Accept pipeline input: False 72 | Accept wildcard characters: False 73 | ``` 74 | 75 | ### CommonParameters 76 | 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). 77 | 78 | ## INPUTS 79 | 80 | ## OUTPUTS 81 | 82 | ### Returns array of object type VMware.Hv.VirtualCenterInfo 83 | ## NOTES 84 | | | | 85 | |-|-| 86 | | Author | Matt Frey. | 87 | | Author email | mfrey@vmware.com | 88 | | Version | 1.0 | 89 | 90 | ===Tested Against Environment==== 91 | | | | 92 | |-|-| 93 | | Horizon View Server Version | 7.7 | 94 | | PowerCLI Version | PowerCLI 11.2.0 | 95 | | PowerShell Version | 5.1 | 96 | 97 | ## RELATED LINKS 98 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/New-HVPodFederation.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-HVPodFederation 9 | 10 | ## SYNOPSIS 11 | Initiates a Horizon View Pod Federation (Cloud Pod Architecture) 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | New-HVPodFederation [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Starts the initialisation of a Horizon View Pod Federation. 21 | Other pod's can be joined to this federation to form the Cloud Pod Architecture 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | new-hvpodfederation 28 | ``` 29 | 30 | Returns health for the connectionserver(s) 31 | 32 | ## PARAMETERS 33 | 34 | ### -HvServer 35 | Reference to Horizon View Server to query the virtual machines from. 36 | If the value is not passed or null then 37 | first element from global:DefaultHVServers would be considered in-place of hvServer 38 | 39 | ```yaml 40 | Type: Object 41 | Parameter Sets: (All) 42 | Aliases: 43 | 44 | Required: False 45 | Position: 1 46 | Default value: None 47 | Accept pipeline input: False 48 | Accept wildcard characters: False 49 | ``` 50 | 51 | ### CommonParameters 52 | 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). 53 | 54 | ## INPUTS 55 | 56 | ## OUTPUTS 57 | 58 | ## NOTES 59 | | | | 60 | |-|-| 61 | | Author | Wouter Kursten | 62 | | Author email | wouter@retouw.nl | 63 | | Version | 1.0 | 64 | 65 | ===Tested Against Environment==== 66 | | | | 67 | |-|-| 68 | | Horizon View Server Version | 7.3.2,7.4 | 69 | | PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 | 70 | | PowerShell Version | 5.0 | 71 | 72 | ## RELATED LINKS 73 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Remove-HVPodFederation.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-HVPodFederation 9 | 10 | ## SYNOPSIS 11 | Uninitiates a Horizon View Pod Federation (Cloud Pod Architecture) 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Remove-HVPodFederation [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Starts the uninitialisation of a Horizon View Pod Federation. 21 | It does NOT remove a pod from a federation. 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | Starts the Uninitiates a Horizon View Pod Federation. 28 | ``` 29 | 30 | Unintialises 31 | 32 | ## PARAMETERS 33 | 34 | ### -HvServer 35 | Reference to Horizon View Server to query the virtual machines from. 36 | If the value is not passed or null then 37 | first element from global:DefaultHVServers would be considered in-place of hvServer 38 | 39 | ```yaml 40 | Type: Object 41 | Parameter Sets: (All) 42 | Aliases: 43 | 44 | Required: False 45 | Position: 1 46 | Default value: None 47 | Accept pipeline input: False 48 | Accept wildcard characters: False 49 | ``` 50 | 51 | ### CommonParameters 52 | 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). 53 | 54 | ## INPUTS 55 | 56 | ## OUTPUTS 57 | 58 | ## NOTES 59 | | | | 60 | |-|-| 61 | | Author | Wouter Kursten | 62 | | Author email | wouter@retouw.nl | 63 | | Version | 1.0 | 64 | 65 | ===Tested Against Environment==== 66 | | | | 67 | |-|-| 68 | | Horizon View Server Version | 7.3.2,7.4 | 69 | | PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 | 70 | | PowerShell Version | 5.0 | 71 | 72 | ## RELATED LINKS 73 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Remove-HVSite.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-HVSite 9 | 10 | ## SYNOPSIS 11 | renames a new site within a Horizon View Pod Federation (Cloud Pod Architecture) 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Remove-HVSite [-name] [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | renames a new site within a Horizon View Pod Federation (Cloud Pod Architecture) 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | set-hvsite -site "CURRENTSITENAME" -name "NAME" -description "DESCRIPTION" 27 | ``` 28 | 29 | Returns information about the sites within a Horizon View Pod Federation. 30 | 31 | ## PARAMETERS 32 | 33 | ### -name 34 | Name of the site (required) 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -HvServer 49 | Reference to Horizon View Server to query the virtual machines from. 50 | If the value is not passed or null then 51 | first element from global:DefaultHVServers would be considered in-place of hvServer 52 | 53 | ```yaml 54 | Type: Object 55 | Parameter Sets: (All) 56 | Aliases: 57 | 58 | Required: False 59 | Position: 2 60 | Default value: None 61 | Accept pipeline input: False 62 | Accept wildcard characters: False 63 | ``` 64 | 65 | ### CommonParameters 66 | 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). 67 | 68 | ## INPUTS 69 | 70 | ## OUTPUTS 71 | 72 | ## NOTES 73 | | | | 74 | |-|-| 75 | | Author | Wouter Kursten | 76 | | Author email | wouter@retouw.nl | 77 | | Version | 1.0 | 78 | 79 | ===Tested Against Environment==== 80 | | | | 81 | |-|-| 82 | | Horizon View Server Version | 7.3.2,7.4 | 83 | | PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 | 84 | | PowerShell Version | 5.0 | 85 | 86 | ## RELATED LINKS 87 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Set-HVPodFederation.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-HVPodFederation 9 | 10 | ## SYNOPSIS 11 | Used to change the name of a Horizon View Pod Federation (Cloud Pod Architecture) 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-HVPodFederation [-name] [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Used to change the name of a Horizon View Pod Federation (Cloud Pod Architecture) 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | set-hvpodfederation -name "New Name" 27 | ``` 28 | 29 | Will update the name of the current podfederation. 30 | 31 | ## PARAMETERS 32 | 33 | ### -name 34 | The new name of the Pod Federation. 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -HvServer 49 | Reference to Horizon View Server to query the virtual machines from. 50 | If the value is not passed or null then 51 | first element from global:DefaultHVServers would be considered in-place of hvServer 52 | 53 | ```yaml 54 | Type: Object 55 | Parameter Sets: (All) 56 | Aliases: 57 | 58 | Required: False 59 | Position: 2 60 | Default value: None 61 | Accept pipeline input: False 62 | Accept wildcard characters: False 63 | ``` 64 | 65 | ### CommonParameters 66 | 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). 67 | 68 | ## INPUTS 69 | 70 | ## OUTPUTS 71 | 72 | ## NOTES 73 | | | | 74 | |-|-| 75 | | Author | Wouter Kursten | 76 | | Author email | wouter@retouw.nl | 77 | | Version | 1.0 | 78 | 79 | ===Tested Against Environment==== 80 | | | | 81 | |-|-| 82 | | Horizon View Server Version | 7.3.2,7.4 | 83 | | PowerCLI Version | PowerCLI 6.5, PowerCLI 6.5.1 | 84 | | PowerShell Version | 5.0 | 85 | 86 | ## RELATED LINKS 87 | -------------------------------------------------------------------------------- /Modules/VMware.Hv.Helper/docs/Set-HVlicense.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: VMware.HV.Helper-help.xml 3 | Module Name: VMware.HV.Helper 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-HVlicense 9 | 10 | ## SYNOPSIS 11 | Sets or changes the license for Horizon View 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Set-HVlicense [-license] [[-HvServer] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Sets or changes the license for Horizon View 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Set-HVlicense -license "LICENSE-KEY" 27 | ``` 28 | 29 | Returns information about the sites within a Horizon View Pod Federation. 30 | 31 | ## PARAMETERS 32 | 33 | ### -license 34 | License key (string) 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -HvServer 49 | Reference to Horizon View Server to query the virtual machines from. 50 | If the value is not passed or null then 51 | first element from global:DefaultHVServers would be considered in-place of hvServer 52 | 53 | ```yaml 54 | Type: Object 55 | Parameter Sets: (All) 56 | Aliases: 57 | 58 | Required: False 59 | Position: 2 60 | Default value: None 61 | Accept pipeline input: False 62 | Accept wildcard characters: False 63 | ``` 64 | 65 | ### CommonParameters 66 | 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). 67 | 68 | ## INPUTS 69 | 70 | ## OUTPUTS 71 | 72 | ## NOTES 73 | | | | 74 | |-|-| 75 | | Author | Wouter Kursten | 76 | | Author email | wouter@retouw.nl | 77 | | Version | 1.0 | 78 | 79 | ===Tested Against Environment==== 80 | | | | 81 | |-|-| 82 | | Horizon View Server Version | 7.4,7.5 | 83 | | PowerCLI Version | PowerCLI 10 | 84 | | PowerShell Version | 5.0 | 85 | 86 | ## RELATED LINKS 87 | -------------------------------------------------------------------------------- /Modules/VMware.Skyline.InsightsApi/VMware.Skyline.InsightsApi.Format.ps1xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SkylineConnection 6 | 7 | SkylineConnection 8 | 9 | 10 | 11 | 12 | 30 13 | 14 | 15 | 16 | 30 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Name 28 | 29 | 30 | APIKey 31 | 32 | 33 | CSPName 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Modules/VMware.TrustedInfrastructure.Helper/README.md: -------------------------------------------------------------------------------- 1 | Prerequisites/Steps to use this module: 2 | 1. You must be a Trust Authority Administrator, a part of the TrustedAdmins group and also have the "Host.Inventory.Add Host To Cluster" privilege on vCenter system. 3 | 2. The ESXi host must be wiped from existing Trusted Infrastructure configuration. If the ESXi host has been previously configured as part of vSphere Trust Authority (part of a vCenter configured for vSphere Trust Authority, a Trust Authority Cluster or Trusted Cluster), you must use the decommission script first. 4 | 3. TrustAuthorityCluster and TrustedCluster should be in a healthy state (check all vSphere Trust Authority APIs which return Health field). 5 | 4. The ESXi host must be removed from vCenter. 6 | 5. You must know the ESXi host root credentials (username and password). 7 | 6. You must have purchased sufficient license for vSphere Trust Authority. 8 | 7. You must have PowerCLI 12.1.0 and above. 9 | 8. Following PowerCLI module is required to be imported: VMware.VimAutomation.Security. 10 | 9. Run the command Get-Command -Module VMware.TrustedInfrastructure.Helper. This should inform the following functions are available: 11 | - Add-TrustAuthorityVMHost 12 | - Add-TrustedVMHost 13 | If you do not see these functions listed, the PowerCLI module is not loaded correctly. 14 | 10. Run Get-Help Add-TrustAuthorityVMHost -full and Get-Help Add-TrustedVMHost -full to see how to use these two functions. 15 | 11. Others, please refer vSphere documentation. 16 | -------------------------------------------------------------------------------- /Modules/VMware.VCGChecker/Save-VCGJsonFile.ps1: -------------------------------------------------------------------------------- 1 | Function Save-VCGJsonFile{ 2 | Param( 3 | [Parameter(Mandatory=$true)] $FileName, 4 | [Parameter(Mandatory=$true)] $Data, 5 | [Parameter(Mandatory=$true)] $Dir 6 | ) 7 | $json = @() 8 | $Data | ForEach-Object { $json += $_.to_jsonobj()} 9 | 10 | if (!(Test-Path $Dir)) { 11 | New-Item -Type directory -Confirm:$false -Path $Dir -Force |Out-Null 12 | } 13 | 14 | $Path= $Dir + '\' + $FileName + '.json' 15 | info ("Saving data to " + $Path) 16 | ConvertTo-Json -Depth 10 -Compress $json | Out-File -encoding 'UTF8' -FilePath $Path 17 | } -------------------------------------------------------------------------------- /Modules/VMware.VMC/VMware.VMC.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.VMC/VMware.VMC.psd1 -------------------------------------------------------------------------------- /Modules/VMware.VMEncryption/README.md: -------------------------------------------------------------------------------- 1 | Prerequisites/Steps to use this module: 2 | 3 | 1. This module only works for vSphere products that support VM Encryption. E.g. vSphere 6.5 and later. 4 | 2. All the functions in this module only work for KMIP Servers. 5 | 3. Install the latest version of Powershell and PowerCLI. 6 | 4. Import this module by running: Import-Module -Name "location of this module" 7 | 5. Get-Command -Module "This module Name" to list all available functions. 8 | 9 | Note: 10 | Deprecating the below functions related to KMServer and KMSCluster from VMware.VMEncryption and using instead the ones from VMware.VimAutomation.Storage, 11 | 12 | 1, VMware.VMEncryption\Get-DefaultKMSCluster, use instead 13 | VMware.VimAutomation.Storage\Get-KmsCluster|where {$_.UseAsDefaultKeyProvider}|foreach {$_.id} 14 | 15 | 2, VMware.VMEncryption\Get-KMSCluster, use instead 16 | VMware.VimAutomation.Storage\Get-KmsCluster|select id 17 | 18 | 3, VMware.VMEncryption\Get-KMSClusterInfo, use instead 19 | VMware.VimAutomation.Storage\Get-KmsCluster|foreach {$_.extensiondata} 20 | 21 | 4, VMware.VMEncryption\Get-KMServerInfo, use instead 22 | VMware.VimAutomation.Storage\Get-KeyManagementServer|foreach {$_.extensiondata} 23 | 24 | 5, VMware.VMEncryption\New-KMServer, use instead 25 | VMware.VimAutomation.Storage\Add-KeyManagementServer 26 | 27 | 6, VMware.VMEncryption\Remove-KMServer, use instead 28 | VMware.VimAutomation.Storage\Remove-KeyManagementServer 29 | 30 | 7, VMware.VMEncryption\Set-DefaultKMSCluster, use instead 31 | VMware.VimAutomation.Storage\Set-KmsCluster -UseAsDefaultKeyProvider 32 | 33 | -------------------------------------------------------------------------------- /Modules/VMware.VsanEncryption/README.md: -------------------------------------------------------------------------------- 1 | Prerequisites/Steps to use this module: 2 | 3 | 1. This module only works for vSphere products that support vSAN Encryption. E.g. vSAN 6.6 and later with a vSAN Enterprise license 4 | 2. All the functions in this module only work for KMIP Servers. 5 | 3. Install the latest version of Powershell and PowerCLI(11). 6 | 4. Import this module by running: Import-Module -Name "location of this module" 7 | 5. Get-Command -Module "This module Name" to list all available functions. -------------------------------------------------------------------------------- /Modules/VMware.VsanEncryption/VMware.VsanEncryption.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.VsanEncryption/VMware.VsanEncryption.psd1 -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/README.md: -------------------------------------------------------------------------------- 1 | # PowerCLI Example module for managing vSphere SSO Admin 2 | This module is combination of .NET binary libraries for accessing vSphere SSO Admin API and PowerShell advanced functions exposing cmdlet-like interface to the SSO Admin features.
3 |
4 | The module supports PowerShell 5.1 and PowerShell 7.0 and above.
5 | 6 | ## Install Module from PowerShell Gallery 7 | ``` 8 | Install-Module VMware.vSphere.SsoAdmin 9 | ``` 10 | 11 | # Using the source code 12 | ## '/src' directory 13 | This directory contains the .NET binaries sources code and Pester integration tests that cover both the binaries and the module advanced functions functionality.
14 | 15 | ## Required build tools 16 | - PowerShell 7.0
17 | - dotnet sdk
18 | 19 | ## Required test tools 20 | - PowerShell 7.0 21 | - PowerCLI 12.0
22 | - Pester 5.0.0
23 | 24 | ## '/src/build.ps1' script 25 | The script builds the binaries and publishes them to the 'net45' and 'netcoreapp3.1' directories of the module.
26 | 27 | It has also the option to run module Pester tests. The optional parameters for VC server and credentials has to be specified in order the script to run the tests. Tests run in separate PowreShell process because PowerShell has to load the module binaries which are build output.
28 | 29 | ## '/src/test/RunTests.ps1' script 30 | This script can be used to run the tests
31 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.LsClient.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.LsClient.dll -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Format.ps1xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Format.ps1xml -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Utils.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Utils.dll -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdminClient.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdminClient.dll -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/netcoreapp3.1/VMware.vSphere.LsClient.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/netcoreapp3.1/VMware.vSphere.LsClient.dll -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/netcoreapp3.1/VMware.vSphere.SsoAdmin.Format.ps1xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/netcoreapp3.1/VMware.vSphere.SsoAdmin.Format.ps1xml -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/netcoreapp3.1/VMware.vSphere.SsoAdmin.Utils.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/netcoreapp3.1/VMware.vSphere.SsoAdmin.Utils.dll -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/netcoreapp3.1/VMware.vSphere.SsoAdminClient.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/netcoreapp3.1/VMware.vSphere.SsoAdminClient.dll -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/.gitignore: -------------------------------------------------------------------------------- 1 | **/.vs 2 | **/bin 3 | **/obj -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/Nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.LsClient/Connected Services/LookupServiceReference/ConnectedService.json: -------------------------------------------------------------------------------- 1 | { 2 | "ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf", 3 | "Version": "15.0.20628.921", 4 | "ExtendedData": { 5 | "Uri": "https://10.23.80.205/lookupservice/wsdl/lookup.wsdl", 6 | "Namespace": "LookupServiceReference", 7 | "SelectedAccessLevelForGeneratedClass": "Public", 8 | "GenerateMessageContract": false, 9 | "ReuseTypesinReferencedAssemblies": true, 10 | "ReuseTypesinAllReferencedAssemblies": true, 11 | "CollectionTypeReference": { 12 | "Item1": "System.Array", 13 | "Item2": "System.Runtime.dll" 14 | }, 15 | "DictionaryCollectionTypeReference": { 16 | "Item1": "System.Collections.Generic.Dictionary`2", 17 | "Item2": "System.Collections.dll" 18 | }, 19 | "CheckedReferencedAssemblies": [], 20 | "InstanceId": null, 21 | "Name": "LookupServiceReference", 22 | "Metadata": {} 23 | } 24 | } -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.LsClient/VMware.vSphere.LsClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | VMware.vSphere.LsClient 5 | VMware.vSphere.LsClient 6 | vSphere Lookup Service API client. 7 | net45;netcoreapp3.1 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/AcceptAllX509CertificateValidator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.IdentityModel.Selectors; 8 | using System.Security.Cryptography.X509Certificates; 9 | 10 | namespace VMware.vSphere.SsoAdmin.Utils 11 | { 12 | public class AcceptAllX509CertificateValidator : X509CertificateValidator 13 | { 14 | public override void Validate(X509Certificate2 certificate) { 15 | // Check that there is a certificate. 16 | if (certificate == null) { 17 | throw new ArgumentNullException(nameof(certificate)); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StringToSecureStringArgumentTransformationAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Management.Automation; 10 | using System.Security; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | 14 | namespace VMware.vSphere.SsoAdmin.Utils 15 | { 16 | public class StringToSecureStringArgumentTransformationAttribute : ArgumentTransformationAttribute 17 | { 18 | private static class SecureStringConverter 19 | { 20 | public static SecureString ToSecureString(string value) { 21 | var result = new SecureString(); 22 | 23 | foreach (var c in value.ToCharArray()) { 24 | result.AppendChar(c); 25 | } 26 | 27 | return result; 28 | } 29 | } 30 | 31 | public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { 32 | object result = inputData; 33 | if (inputData is string s) { 34 | result = SecureStringConverter.ToSecureString(s); 35 | } 36 | return result; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StringToSsoAdminServerArgumentTransformationAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Management.Automation; 10 | using System.Management.Automation.Runspaces; 11 | using System.Security; 12 | using System.Text; 13 | using System.Text.RegularExpressions; 14 | using System.Threading.Tasks; 15 | using VMware.vSphere.SsoAdminClient.DataTypes; 16 | 17 | namespace VMware.vSphere.SsoAdmin.Utils 18 | { 19 | public class StringToSsoAdminServerArgumentTransformationAttribute : ArgumentTransformationAttribute 20 | { 21 | public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { 22 | object result = inputData; 23 | 24 | if (inputData is string obnValue && 25 | !string.IsNullOrEmpty(obnValue)) { 26 | // Adopt PowerShell regex chars 27 | var csharpObnValue = obnValue.Replace("*", ".*").Replace("?", ".?"); 28 | result = null; 29 | 30 | var obnMatchingServers = new List(); 31 | 32 | var ssoAdminServerVariable = engineIntrinsics.SessionState.PSVariable.GetValue("DefaultSsoAdminServers"); 33 | 34 | if (ssoAdminServerVariable is PSObject ssoAdminServersPsObj && 35 | ssoAdminServersPsObj.BaseObject is List connectedServers) { 36 | foreach (var server in connectedServers) { 37 | if (!string.IsNullOrEmpty(Regex.Match(server.ToString(), csharpObnValue)?.Value)) { 38 | obnMatchingServers.Add(server); 39 | } 40 | } 41 | } 42 | 43 | if (obnMatchingServers.Count > 0) { 44 | result = obnMatchingServers.ToArray(); 45 | } else { 46 | // Non-terminating error for not matching value 47 | engineIntrinsics.Host.UI.WriteErrorLine($"'{obnValue}' doesn't match any objects in $global:DefaultSsoAdminServers variable"); 48 | } 49 | 50 | } 51 | 52 | return result; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/VMware.vSphere.SsoAdmin.Utils.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | VMware.vSphere.SsoAdmin.Utils 5 | VMware.vSphere.SsoAdmin.Utils 6 | vSphere Lookup SsoAdmin utility types. 7 | net45;netcoreapp3.1 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient.Tests/VMware.vSphere.SsoAdminClient.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/ActiveDirectoryIdentitySource.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace VMware.vSphere.SsoAdminClient.DataTypes 13 | { 14 | public class ActiveDirectoryIdentitySource : IdentitySource 15 | { 16 | public string Type { get; set; } 17 | public string Alias { get; set; } 18 | 19 | public string AuthenticationType { get; set; } 20 | public string AuthenticationUsername { get; set; } 21 | 22 | public string FriendlyName { get; set; } 23 | public string PrimaryUrl { get; set; } 24 | public string FailoverUrl { get; set; } 25 | public string UserBaseDN { get; set; } 26 | public string GroupBaseDN { get; set; } 27 | 28 | public System.Security.Cryptography.X509Certificates.X509Certificate2[] Certificates {get ;set;} 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/AuthenticationPolicy.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System.Security.Cryptography.X509Certificates; 7 | 8 | namespace VMware.vSphere.SsoAdminClient.DataTypes 9 | { 10 | public class AuthenticationPolicy 11 | { 12 | SsoAdminClient _client; 13 | public AuthenticationPolicy(SsoAdminClient client) { 14 | _client = client; 15 | } 16 | 17 | public SsoAdminClient GetClient() { 18 | return _client; 19 | } 20 | 21 | public bool PasswordAuthnEnabled { get; internal set; } 22 | public bool WindowsAuthnEnabled { get; internal set; } 23 | public bool SmartCardAuthnEnabled { get; internal set; } 24 | public bool OCSPEnabled { get; internal set; } 25 | public bool UseCRLAsFailOver { get; internal set; } 26 | public bool SendOCSPNonce { get; internal set; } 27 | public string OCSPUrl { get; internal set; } 28 | public X509Certificate2 OCSPResponderSigningCert { get; internal set; } 29 | public bool UseInCertCRL { get; internal set; } 30 | public string CRLUrl { get; internal set; } 31 | public int CRLCacheSize { get; internal set; } 32 | public string[] Oids { get; internal set; } 33 | public string[] TrustedCAs { get; internal set; } 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/Group.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace VMware.vSphere.SsoAdminClient.DataTypes 12 | { 13 | public class Group 14 | { 15 | SsoAdminClient _client; 16 | public Group(SsoAdminClient client) 17 | { 18 | _client = client; 19 | } 20 | 21 | public string Name { get; set; } 22 | public string Domain { get; set; } 23 | public string Description { get; set; } 24 | 25 | public SsoAdminClient GetClient() 26 | { 27 | return _client; 28 | } 29 | 30 | public override string ToString() 31 | { 32 | return $"{Name}@{Domain}"; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/IdentitySource.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace VMware.vSphere.SsoAdminClient.DataTypes 13 | { 14 | public class IdentitySource 15 | { 16 | public string Name { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/LocalOSIdentitySource.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace VMware.vSphere.SsoAdminClient.DataTypes 12 | { 13 | public class LocalOSIdentitySource : IdentitySource 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/LockoutPolicy.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.ServiceModel.Security; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | 13 | namespace VMware.vSphere.SsoAdminClient.DataTypes 14 | { 15 | public class LockoutPolicy 16 | { 17 | SsoAdminClient _client; 18 | public LockoutPolicy(SsoAdminClient client) { 19 | _client = client; 20 | } 21 | 22 | public SsoAdminClient GetClient() { 23 | return _client; 24 | } 25 | 26 | public string Description { get; set; } 27 | public long AutoUnlockIntervalSec { get; set; } 28 | public long FailedAttemptIntervalSec { get; set; } 29 | public int MaxFailedAttempts { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/PasswordPolicy.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace VMware.vSphere.SsoAdminClient.DataTypes 13 | { 14 | public class PasswordPolicy 15 | { 16 | SsoAdminClient _client; 17 | public PasswordPolicy(SsoAdminClient client) { 18 | _client = client; 19 | } 20 | 21 | public string Description { get; set; } 22 | public int ProhibitedPreviousPasswordsCount { get; set; } 23 | public int MinLength { get; set; } 24 | public int MaxLength { get; set; } 25 | public int MinNumericCount { get; set; } 26 | public int MinSpecialCharCount { get; set; } 27 | public int MaxIdenticalAdjacentCharacters { get; set; } 28 | public int MinAlphabeticCount { get; set; } 29 | public int MinUppercaseCount { get; set; } 30 | public int MinLowercaseCount { get; set; } 31 | public int PasswordLifetimeDays { get; set; } 32 | 33 | public SsoAdminClient GetClient() { 34 | return _client; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/PersonUser.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace VMware.vSphere.SsoAdminClient.DataTypes 12 | { 13 | public class PersonUser 14 | { 15 | SsoAdminClient _client; 16 | public PersonUser(SsoAdminClient client) { 17 | _client = client; 18 | } 19 | 20 | public string Name { get; set; } 21 | public string Domain { get; set; } 22 | public string Description { get; set; } 23 | public string FirstName { get; set; } 24 | public string LastName { get; set; } 25 | public string EmailAddress { get; set; } 26 | public bool Locked { get; set; } 27 | public bool Disabled { get; set; } 28 | 29 | public Nullable PasswordExpirationRemainingDays { get; set; } 30 | 31 | public SsoAdminClient GetClient() { 32 | return _client; 33 | } 34 | 35 | public override string ToString() { 36 | return $"{Name}@{Domain}"; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/SsoAdminServer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IdentityModel.Selectors; 9 | using System.Linq; 10 | using System.Security; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using VMware.Binding.Sts.StsService; 14 | 15 | namespace VMware.vSphere.SsoAdminClient.DataTypes 16 | { 17 | public class SsoAdminServer { 18 | 19 | private SsoAdminClient _client; 20 | 21 | public SsoAdminServer(string hostname, 22 | string user, 23 | SecureString password, 24 | X509CertificateValidator serverCertificateValidator) { 25 | 26 | Name = hostname; 27 | 28 | _client = new SsoAdminClient( 29 | hostname, 30 | user, 31 | password, 32 | serverCertificateValidator); 33 | 34 | RefCount = 1; 35 | Id = $"/SsoAdminServer={NormalizeUserName()}@{Name}"; 36 | } 37 | 38 | private string NormalizeUserName() { 39 | string result = User; 40 | if (User.Contains('@')) { 41 | var parts = User.Split('@'); 42 | var userName = parts[0]; 43 | var domain = parts[1]; 44 | result = $"{domain}/{userName}"; 45 | } 46 | return result; 47 | } 48 | 49 | public string Name { get; } 50 | public Uri ServiceUri => _client?.ServiceUri; 51 | public string User => _client?.User; 52 | public string Id { get; set; } 53 | public bool IsConnected => _client != null; 54 | public SsoAdminClient Client => _client; 55 | public int RefCount { get; set; } 56 | 57 | public void Disconnect() { 58 | if (--RefCount == 0) { 59 | _client = null; 60 | } 61 | } 62 | 63 | public override string ToString() { 64 | return Name; 65 | } 66 | 67 | public override int GetHashCode() { 68 | return Id != null ? Id.GetHashCode() : base.GetHashCode(); 69 | } 70 | 71 | public override bool Equals(object obj) { 72 | bool result = false; 73 | if (obj is SsoAdminServer target) { 74 | result = string.Equals(Id, target.Id); 75 | } 76 | return result; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/SystemIdentitySource.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace VMware.vSphere.SsoAdminClient.DataTypes 13 | { 14 | public class SystemIdentitySource : IdentitySource 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/DataTypes/TokenLifetime.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace VMware.vSphere.SsoAdminClient.DataTypes 13 | { 14 | public class TokenLifetime 15 | { 16 | SsoAdminClient _client; 17 | public TokenLifetime(SsoAdminClient client) { 18 | _client = client; 19 | } 20 | 21 | public SsoAdminClient GetClient() { 22 | return _client; 23 | } 24 | 25 | public long MaxHoKTokenLifetime { get; set; } 26 | public long MaxBearerTokenLifetime { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/UserPassSecurityContext.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | */ 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IdentityModel.Selectors; 8 | using System.Linq; 9 | using System.Security; 10 | using System.Security.Cryptography.X509Certificates; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using System.Xml; 14 | using VMware.Binding.Sts; 15 | 16 | namespace VMware.vSphere.SsoAdminClient 17 | { 18 | public class UserPassSecurityContext 19 | { 20 | private string _user; 21 | private SecureString _password; 22 | private VmwareSecruityTokenService _stsClient; 23 | private SamlSecurityToken _validToken; 24 | public UserPassSecurityContext( 25 | string user, 26 | SecureString password, 27 | Uri stsUri, 28 | X509CertificateValidator serverCertificateValidator) { 29 | 30 | if (user == null) throw new ArgumentNullException(nameof(user)); 31 | if (password == null) throw new ArgumentNullException(nameof(password)); 32 | if (stsUri == null) throw new ArgumentNullException(nameof(stsUri)); 33 | 34 | _user = user; 35 | _password = password; 36 | 37 | Action certHandler = null; 38 | if (serverCertificateValidator != null) { 39 | certHandler = serverCertificateValidator.Validate; 40 | } 41 | _stsClient = new VmwareSecruityTokenService(stsUri, false, certHandler); 42 | } 43 | 44 | private void RenewIfNeeded() { 45 | if (_validToken == null || 46 | _validToken.Expires < (DateTime.Now + new TimeSpan(0, 0, 30))) { 47 | _validToken = _stsClient.IssueBearerTokenByUserCredential( 48 | _user, 49 | _password); 50 | } 51 | } 52 | 53 | public XmlElement GetToken() { 54 | RenewIfNeeded(); 55 | return _validToken.RawToken; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient/VMware.vSphere.SsoAdminClient.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | VMware.vSphere.SsoAdminClient 5 | VMware.vSphere.SsoAdminClient 6 | SSO Admin API client. 7 | net45;netcoreapp3.1 8 | 9 | 10 | 11 | $(DefineConstants);NET45 12 | 13 | 14 | 15 | $(DefineConstants);NETCORE20 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Binding.Sts.12.0.0.15939652.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Binding.Sts.12.0.0.15939652.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Binding.Sts.12.0.0.15939652.symbols.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Binding.Sts.12.0.0.15939652.symbols.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Binding.WsTrust.12.0.0.15939652.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Binding.WsTrust.12.0.0.15939652.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Binding.WsTrust.12.0.0.15939652.symbols.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Binding.WsTrust.12.0.0.15939652.symbols.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Http.Handlers.12.0.0.15939652.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Http.Handlers.12.0.0.15939652.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Http.Handlers.12.0.0.15939652.symbols.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Http.Handlers.12.0.0.15939652.symbols.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.System.Private.ServiceModel.4.4.4.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.System.Private.ServiceModel.4.4.4.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Util.Sspi.12.0.0.15939652.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Util.Sspi.12.0.0.15939652.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Util.Sspi.12.0.0.15939652.symbols.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/packages/VMware.Util.Sspi.12.0.0.15939652.symbols.nupkg -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/resources/powercli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/VMware.vSphere.SsoAdmin/src/resources/powercli.png -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/test/IdentitySource.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | param( 7 | [Parameter(Mandatory = $true)] 8 | [string] 9 | $VcAddress, 10 | 11 | [Parameter(Mandatory = $true)] 12 | [string] 13 | $User, 14 | 15 | [Parameter(Mandatory = $true)] 16 | [string] 17 | $Password 18 | ) 19 | 20 | # Import Vmware.vSphere.SsoAdmin Module 21 | $modulePath = Join-Path (Split-Path $PSScriptRoot | Split-Path) "VMware.vSphere.SsoAdmin.psd1" 22 | Import-Module $modulePath 23 | 24 | Describe "Get-IdentitySource Tests" { 25 | BeforeEach { 26 | Connect-SsoAdminServer ` 27 | -Server $VcAddress ` 28 | -User $User ` 29 | -Password $Password ` 30 | -SkipCertificateCheck 31 | } 32 | 33 | AfterEach { 34 | $connectionsToCleanup = $global:DefaultSsoAdminServers.ToArray() 35 | foreach ($connection in $connectionsToCleanup) { 36 | Disconnect-SsoAdminServer -Server $connection 37 | } 38 | } 39 | 40 | Context "Get-IdentitySource" { 41 | It 'Gets all available identity sources' { 42 | # Act 43 | $actual = Get-IdentitySource 44 | 45 | # Assert 46 | $actual | Should -Not -Be $null 47 | $actual.Count | Should -BeGreaterThan 1 48 | $actual[0].NAme | Should -Be 'localos' 49 | } 50 | 51 | It 'Gets localos only identity source' { 52 | # Act 53 | $actual = Get-IdentitySource -Localos 54 | 55 | # Assert 56 | $actual | Should -Not -Be $null 57 | $actual.Count | Should -Be 1 58 | $actual[0].Name | Should -Be 'localos' 59 | } 60 | 61 | It 'Gets all available identity sources' { 62 | # Act 63 | $actual = Get-IdentitySource -Localos -System 64 | 65 | # Assert 66 | $actual | Should -Not -Be $null 67 | $actual.Count | Should -Be 2 68 | $actual[0].Name | Should -Be 'localos' 69 | $actual[0].Name | Should -Not -Be $null 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/test/LockoutPolicy.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | param( 7 | [Parameter(Mandatory = $true)] 8 | [string] 9 | $VcAddress, 10 | 11 | [Parameter(Mandatory = $true)] 12 | [string] 13 | $User, 14 | 15 | [Parameter(Mandatory = $true)] 16 | [string] 17 | $Password 18 | ) 19 | 20 | # Import Vmware.vSphere.SsoAdmin Module 21 | $modulePath = Join-Path (Split-Path $PSScriptRoot | Split-Path) "VMware.vSphere.SsoAdmin.psd1" 22 | Import-Module $modulePath 23 | 24 | Describe "LockoutPolicy Tests" { 25 | BeforeEach { 26 | Connect-SsoAdminServer ` 27 | -Server $VcAddress ` 28 | -User $User ` 29 | -Password $Password ` 30 | -SkipCertificateCheck 31 | } 32 | 33 | AfterEach { 34 | $connectionsToCleanup = $global:DefaultSsoAdminServers.ToArray() 35 | foreach ($connection in $connectionsToCleanup) { 36 | Disconnect-SsoAdminServer -Server $connection 37 | } 38 | } 39 | 40 | Context "Get-SsoLockoutPolicy" { 41 | It 'Gets lockout policy' { 42 | # Act 43 | $actual = Get-SsoLockoutPolicy 44 | 45 | # Assert 46 | $actual | Should -Not -Be $null 47 | } 48 | } 49 | 50 | Context "Set-SsoLockoutPolicy" { 51 | It 'Updates lockout policy AutoUnlockIntervalSec and MaxFailedAttempts' { 52 | # Arrange 53 | $lockoutPolicyToUpdate = Get-SsoLockoutPolicy 54 | $expectedAutoUnlockIntervalSec = 33 55 | $expectedMaxFailedAttempts = 7 56 | 57 | # Act 58 | $actual = Set-SsoLockoutPolicy ` 59 | -LockoutPolicy $lockoutPolicyToUpdate ` 60 | -AutoUnlockIntervalSec $expectedAutoUnlockIntervalSec ` 61 | -MaxFailedAttempts $expectedMaxFailedAttempts 62 | 63 | # Assert 64 | $actual | Should -Not -Be $null 65 | $actual.AutoUnlockIntervalSec | Should -Be $expectedAutoUnlockIntervalSec 66 | $actual.MaxFailedAttempts | Should -Be $expectedMaxFailedAttempts 67 | $actual.FailedAttemptIntervalSec | Should -Be $lockoutPolicyToUpdate.FailedAttemptIntervalSec 68 | $actual.Description | Should -Be $lockoutPolicyToUpdate.Description 69 | 70 | # Cleanup 71 | $lockoutPolicyToUpdate | Set-SsoLockoutPolicy 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/test/LsClient.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | param( 7 | [Parameter(Mandatory = $true)] 8 | [string] 9 | $VcAddress, 10 | 11 | [Parameter(Mandatory = $true)] 12 | [string] 13 | $User, 14 | 15 | [Parameter(Mandatory = $true)] 16 | [string] 17 | $Password 18 | ) 19 | 20 | # Import Vmware.vSphere.SsoAdmin Module 21 | $modulePath = Join-Path (Split-Path $PSScriptRoot | Split-Path) "VMware.vSphere.SsoAdmin.psd1" 22 | Import-Module $modulePath 23 | 24 | $script:lsClient = $null 25 | 26 | Describe "Lookup Service Client Integration Tests" { 27 | Context "Retrieval of Service API Url" { 28 | BeforeAll { 29 | ## Create LsClient 30 | $skipCertificateCheckValidator = New-Object ` 31 | 'VMware.vSphere.SsoAdmin.Utils.AcceptAllX509CertificateValidator' 32 | 33 | $script:lsClient = New-Object ` 34 | 'VMware.vSphere.LsClient.LookupServiceClient' ` 35 | -ArgumentList @($VCAddress, $skipCertificateCheckValidator) 36 | 37 | } 38 | 39 | It 'Gets SsoAdmin API Url' { 40 | # Act 41 | $actual = $script:lsClient.GetSsoAdminEndpointUri() 42 | 43 | # Assert 44 | $actual | Should -Not -Be $null 45 | $actual.ToString().StartsWith("https://$VCAddress/sso-adminserver/sdk/") | Should -Be $true 46 | } 47 | 48 | It 'Gets STS API Url' { 49 | # Act 50 | $actual = $script:lsClient.GetStsEndpointUri() 51 | 52 | # Assert 53 | $actual | Should -Not -Be $null 54 | $actual.ToString().StartsWith("https://$VCAddress/sts/STSService") | Should -Be $true 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/test/RunTests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | param( 7 | [Parameter(Mandatory = $true)] 8 | [string] 9 | $VcAddress, 10 | 11 | [Parameter(Mandatory = $true)] 12 | [string] 13 | $User, 14 | 15 | [Parameter(Mandatory = $true)] 16 | [string] 17 | $Password 18 | ) 19 | 20 | function Test-PesterIsAvailable() { 21 | $pesterModules = Get-Module Pester -ListAvailable 22 | $pesterModule = $null 23 | # Search for Pester 4.X 24 | foreach ($p in $pesterModules) { 25 | if ($p.Version -ge [version]"5.0.0") { 26 | $pesterModule = $p 27 | break 28 | } 29 | } 30 | 31 | if ($pesterModule -eq $null) { 32 | throw "Pester Module version 5.X is not available" 33 | } 34 | 35 | Import-Module -Name $pesterModule.Name -RequiredVersion $pesterModule.RequiredVersion 36 | } 37 | 38 | Test-PesterIsAvailable 39 | 40 | $testsData = @{ 41 | VcAddress = $VcAddress 42 | User = $User 43 | Password = $Password 44 | } 45 | 46 | $pesterContainer = New-PesterContainer -Path $PSScriptRoot -Data $testsData 47 | $pesterConfiguration = [PesterConfiguration]::Default 48 | 49 | $pesterConfiguration.Run.Path = $PSScriptRoot 50 | $pesterConfiguration.Run.Container = $pesterContainer 51 | 52 | Invoke-Pester -Configuration $pesterConfiguration -------------------------------------------------------------------------------- /Modules/VMware.vSphere.SsoAdmin/src/test/TokenLifetime.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | param( 7 | [Parameter(Mandatory = $true)] 8 | [string] 9 | $VcAddress, 10 | 11 | [Parameter(Mandatory = $true)] 12 | [string] 13 | $User, 14 | 15 | [Parameter(Mandatory = $true)] 16 | [string] 17 | $Password 18 | ) 19 | 20 | # Import Vmware.vSphere.SsoAdmin Module 21 | $modulePath = Join-Path (Split-Path $PSScriptRoot | Split-Path) "VMware.vSphere.SsoAdmin.psd1" 22 | Import-Module $modulePath 23 | 24 | Describe "TokenLifetime Tests" { 25 | BeforeEach { 26 | Connect-SsoAdminServer ` 27 | -Server $VcAddress ` 28 | -User $User ` 29 | -Password $Password ` 30 | -SkipCertificateCheck 31 | } 32 | 33 | AfterEach { 34 | $connectionsToCleanup = $global:DefaultSsoAdminServers.ToArray() 35 | foreach ($connection in $connectionsToCleanup) { 36 | Disconnect-SsoAdminServer -Server $connection 37 | } 38 | } 39 | 40 | Context "Get-SsoTokenLifetime" { 41 | It 'Gets token lifetime settings' { 42 | # Act 43 | $actual = Get-SsoTokenLifetime 44 | 45 | # Assert 46 | $actual | Should -Not -Be $null 47 | $actual.MaxHoKTokenLifetime | Should -BeGreaterThan 0 48 | $actual.MaxBearerTokenLifetime | Should -BeGreaterThan 0 49 | } 50 | } 51 | 52 | Context "Set-SsoTokenLifetime" { 53 | It 'Updates MaxHoKTokenLifetime and MaxBearerTokenLifetime' { 54 | # Arrange 55 | $tokenLifetimeToUpdate = Get-SsoTokenLifetime 56 | $expectedMaxHoKTokenLifetime = 60 57 | $expectedMaxBearerTokenLifetime = 30 58 | 59 | # Act 60 | $actual = Set-SsoTokenLifetime ` 61 | -TokenLifetime $tokenLifetimeToUpdate ` 62 | -MaxHoKTokenLifetime $expectedMaxHoKTokenLifetime ` 63 | -MaxBearerTokenLifetime $expectedMaxBearerTokenLifetime 64 | 65 | # Assert 66 | $actual | Should -Not -Be $null 67 | $actual.MaxHoKTokenLifetime | Should -Be $expectedMaxHoKTokenLifetime 68 | $actual.MaxBearerTokenLifetime | Should -Be $expectedMaxBearerTokenLifetime 69 | 70 | # Cleanup 71 | $tokenLifetimeToUpdate | Set-SsoTokenLifetime ` 72 | -MaxHoKTokenLifetime $tokenLifetimeToUpdate.MaxHoKTokenLifetime ` 73 | -MaxBearerTokenLifetime $tokenLifetimeToUpdate.MaxBearerTokenLifetime 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /Modules/rCisTag/Examples/01-Get.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2016-2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | # Fetch Cis Server hostname and credentials 7 | .\CisConfig.ps1 8 | 9 | 10 | Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd 11 | 12 | # Get Tag information 13 | Get-rCisTag 14 | 15 | # Get Tag Category information 16 | Get-rCisTagCategory 17 | 18 | # Get Tag Assignment information 19 | Get-rCisTagAssignment 20 | 21 | Disconnect-rCisServer -Server $cisServer -Confirm:$false 22 | -------------------------------------------------------------------------------- /Modules/rCisTag/Examples/02-New.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2016-2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | # Fetch Cis Server hostname and credentials 7 | .\CisConfig.ps1 8 | 9 | Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd 10 | 11 | New-rCisTagCategory -Name MyCat1 -Cardinality Single -Description 'Test Tag Category' -EntityType 'VirtualMachine' 12 | New-rCisTag -Name MyTag1 -Category MyCat1 -Description 'Test Tag' 13 | $vm = Get-VM | Get-Random 14 | New-rCisTagAssignment -Entity $vm -Tag MyTag1 15 | 16 | Get-rCisTagAssignment -Tag MyTag1 17 | 18 | Disconnect-rCisServer -Server $cisServer -Confirm:$false 19 | -------------------------------------------------------------------------------- /Modules/rCisTag/Examples/03-Set.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2016-2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | # Fetch Cis Server hostname and credentials 7 | .\CisConfig.ps1 8 | 9 | Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd 10 | 11 | Get-rCisTag -Name MyTag1 | Set-rCisTag -Name MyNewTag1 -Description 'Name changed' 12 | 13 | Get-rCisTagCategory -Name MyCat1 | Set-rCisTagCategory -Cardinality Multiple -Name MyNewCat1 -Description 'Name changed' 14 | 15 | Disconnect-rCisServer -Server $cisServer -Confirm:$false 16 | -------------------------------------------------------------------------------- /Modules/rCisTag/Examples/04-Remove.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2016-2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | # Fetch Cis Server hostname and credentials 7 | .\CisConfig.ps1 8 | 9 | Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd 10 | 11 | Get-rCisTagAssignment -Tag MyNewTag1 | Remove-rCisTagAssignment -Confirm:$false 12 | 13 | Get-rCisTag -Name MyNewTag1 | Remove-rCisTag -Confirm:$false 14 | 15 | Get-rCisTagCategory -Name MyNewCat1 | Remove-rCisTagCategory -Confirm:$false 16 | 17 | Disconnect-rCisServer -Server $cisServer -Confirm:$false 18 | -------------------------------------------------------------------------------- /Modules/rCisTag/Examples/05-Tag-Datastore.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2016-2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | # Fetch Cis Server hostname and credentials 7 | .\CisConfig.ps1 8 | 9 | Connect-rCisServer -Server $cisServer -User $cisUser -Password $cisPswd 10 | 11 | $catName = 'Homelab' 12 | 13 | # Clean up 14 | Get-rCisTagCategory -Name $catName | Remove-rCisTagCategory -Confirm:$false 15 | 16 | # Tag all datastores with their type 17 | New-rCisTagCategory -Name HomeLab -Description 'Homelab datastores' -Cardinality Single -EntityType 'Datastore' | 18 | New-rCisTag -Name 'VMFS','NFS' -Description 'Datastore type' 19 | 20 | Get-Cluster -Name Cluster1 | Get-Datastore | %{ 21 | New-rCisTagAssignment -Entity $_ -Tag "$($_.Type)" 22 | } 23 | 24 | Disconnect-rCisServer -Server $cisServer -Confirm:$false 25 | -------------------------------------------------------------------------------- /Modules/rCisTag/Examples/CisConfig.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2016-2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | $cisServer = 'vcsa.my.domain' 7 | $cisUser = 'administrator@vsphere.local' 8 | $cisPswd = 'VMware1!' 9 | -------------------------------------------------------------------------------- /Modules/rCisTag/MITLicense.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) since 2015 Luc Dekens, Matt Boren 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Modules/rCisTag/README.md: -------------------------------------------------------------------------------- 1 | # rCisTag 2 | 3 | A module with cmdlets to provide CRUD functions to 4 | * Tags 5 | * Tag Categories 6 | * Tag Assignments 7 | 8 | The cmdlets use the Cis REST API 9 | 10 | ## History 11 | 12 | * Author : **Luc Dekens** 13 | * Release : 14 | * **0.9.0** First draft 15 | -------------------------------------------------------------------------------- /Modules/rCisTag/en-US/about_rCISTag.Help.txt: -------------------------------------------------------------------------------- 1 | TOPIC 2 | about_rCISTag 3 | 4 | SHORT DESCRIPTION 5 | The rCisTag module provides CRUD functions to work with vSphere Tags 6 | 7 | LONG DESCRIPTION 8 | The CisTag module provides CRUD functions to work with vSphere Tags. 9 | The functions in the module are based on the REST API 10 | 11 | NOTE 12 | The module requires PowerShell 5.0 13 | 14 | TROUBLESHOOTING NOTE 15 | 16 | 17 | 18 | EXAMPLES 19 | Get-rCisTag 20 | 21 | KEYWORDS 22 | 23 | 24 | 25 | SEE ALSO 26 | Place related topics here. -------------------------------------------------------------------------------- /Modules/rCisTag/rCISTag.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Modules/rCisTag/rCISTag.psd1 -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 VMware, Inc. All Rights Reserved. 2 | 3 | This product is licensed to you under the BSD-2-Clause License. You may not use this product except in compliance with the License. 4 | -------------------------------------------------------------------------------- /Pester/00 Test Connect-CISServer Connection to VC.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: Test Connect-CISServer to VC.Tests.ps1 3 | Created on: 04/20/2017 4 | Author: Alan Renouf, @alanrenouf 5 | Description: The purpose of this pester test is to ensure the PowerCLI modules are imported and a connection can be made to a vCenter for the CIS Service 6 | Dependencies: Pester Module 7 | Example run: 8 | 9 | Invoke-Pester -Script @{ Path = '.\Test Connect-CISServer to VC.Tests.ps1'; Parameters = @{ VCNAME="VC01.local"; VCUSER="Administrator@vsphere.local"; VCPASS="Admin!23"} } 10 | 11 | #> 12 | 13 | $VCUSER = $Parameters.Get_Item("VCUSER") 14 | $VCPASS = $Parameters.Get_Item("VCPASS") 15 | $VCNAME = $Parameters.Get_Item("VCNAME") 16 | 17 | Describe "Checking PowerCLI Cmdlets available" { 18 | $cmdletname = "Connect-CISServer" 19 | It "Checking $cmdletname is available" { 20 | $command = Get-Command $cmdletname 21 | $command | Select Name, Version 22 | $command.Name| Should Be $cmdletname 23 | } 24 | } 25 | 26 | Describe "Connect-CISServer Tests" { 27 | 28 | $connection = Connect-CISServer $VCName -User $VCUser -password $VCPass 29 | It "Connection is active" { 30 | $Global:DefaultCISServers[0].isconnected | Should Be $true 31 | } 32 | 33 | It "Checking connected server name is $VCName" { 34 | $Global:DefaultCISServers[0] | Select * 35 | $Global:DefaultCISServers[0].name | Should Be $VCName 36 | } 37 | } -------------------------------------------------------------------------------- /Pester/00 Test Connect-VIServer Connection to VC.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: Test Connection to VC.ps1 3 | Created on: 07/15/2016 4 | Author: Alan Renouf, @alanrenouf 5 | Description: The purpose of this pester test is to ensure the PowerCLI modules are imported and a connection can be made to a vCenter 6 | Dependencies: Pester Module 7 | Example run: 8 | 9 | Invoke-Pester -Script @{ Path = '.\Test Connection to VC.Tests.ps1'; Parameters = @{ VCNAME="VC01.local"; VCUSER="Administrator@vsphere.local"; VCPASS="Admin!23"} } 10 | 11 | #> 12 | 13 | $VCUSER = $Parameters.Get_Item("VCUSER") 14 | $VCPASS = $Parameters.Get_Item("VCPASS") 15 | $VCNAME = $Parameters.Get_Item("VCNAME") 16 | 17 | Describe "Checking PowerCLI Cmdlets available" { 18 | $cmdletname = "Connect-VIServer" 19 | It "Checking $cmdletname is available" { 20 | $command = Get-Command $cmdletname 21 | $command | Select Name, Version 22 | $command.Name| Should Be $cmdletname 23 | } 24 | } 25 | 26 | Describe "Connect-VIServer Tests" { 27 | 28 | $connection = Connect-VIServer $VCName -User $VCUser -password $VCPass 29 | It "Connection is active" { 30 | $Global:DefaultVIServer[0].isconnected | Should Be $true 31 | } 32 | 33 | It "Checking connected server name is $VCName" { 34 | $Global:DefaultVIServer[0].name | Should Be $VCName 35 | } 36 | } -------------------------------------------------------------------------------- /Pester/Functions/Get-VMCCommand.tests.ps1: -------------------------------------------------------------------------------- 1 | #Requires -Modules Pester, VMware.VMC, VMware.VimAutomation.Vmc 2 | 3 | 4 | inModuleScope VMware.VMC { 5 | $functionName = "Get-VMCCommand" 6 | Describe "$functionName" -Tag 'Unit' { 7 | Mock Get-Command { 8 | "Mocked Command Response" 9 | } 10 | 11 | Context "Behavior testing" { 12 | It "should call get-command on VMware.VimAutomation.Vmc" { 13 | { Get-VMCCommand } | Should Not Throw 14 | Assert-MockCalled -CommandName Get-command -Times 1 -Scope It -ParameterFilter { $Module -eq 'VMware.VimAutomation.Vmc' } 15 | 16 | } 17 | It "should call get-command on VMware.Vmc" { 18 | { Get-VMCCommand } | Should Not Throw 19 | Assert-MockCalled -CommandName Get-command -Times 1 -Scope It -ParameterFilter { $Module -eq 'VMware.VMC' } 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Pester/Functions/Shared.ps1: -------------------------------------------------------------------------------- 1 | #Requires -Modules Pester 2 | function defParam($command, $name) { 3 | It "Has a -$name parameter" { 4 | $command.Parameters.Item($name) | Should Not BeNullOrEmpty 5 | } 6 | } -------------------------------------------------------------------------------- /Pester/Test Get-CISService.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: Test Connect-CISService.Tests.ps1 3 | Created on: 04/20/2017 4 | Author: Alan Renouf, @alanrenouf 5 | Description: The purpose of this pester test is to ensure the CIS Service cmdlet works correctly 6 | Dependencies: Pester Module 7 | Example run: 8 | 9 | Invoke-Pester -Script @{ Path = '.\Test Get-CISService.ps1' } 10 | 11 | #> 12 | 13 | Describe "Checking PowerCLI Cmdlets available" { 14 | $cmdletname = "Get-CISService" 15 | It "Checking $cmdletname is available" { 16 | $command = Get-Command $cmdletname 17 | $command | Select Name, Version 18 | $command.Name| Should Be $cmdletname 19 | } 20 | } 21 | 22 | Describe "Get-CISService Tests for services" { 23 | 24 | It "Checking CIS connection is active" { 25 | $Global:DefaultCISServers[0].isconnected | Should Be $true 26 | } 27 | 28 | It "Checking Get-CISService returns services" { 29 | Get-CISService | Should Be $true 30 | } 31 | 32 | # Checking some known services which have a Get Method 33 | $servicestocheck = "com.vmware.appliance.system.version", "com.vmware.appliance.health.system" 34 | Foreach ($service in $servicestocheck) { 35 | It "Checking $service get method returns data" { 36 | Get-CisService -Name $service | Should Be $true 37 | (Get-CisService -Name $service).get() | Should Be $true 38 | } 39 | } 40 | 41 | # Checking some known services which have a List Method 42 | $servicestocheck = "com.vmware.vcenter.folder", "com.vmware.vcenter.vm" 43 | Foreach ($service in $servicestocheck) { 44 | It "Checking $service list method returns data" { 45 | Get-CisService -Name $service | Should Be $true 46 | (Get-CisService -Name $service).list() | Should Be $true 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Pester/VMCCode-Coverage.ps1: -------------------------------------------------------------------------------- 1 | Remove-Module VMware.VMC 2 | import-module ../Modules/VMware.VMC/VMware.VMC.psm1 3 | 4 | invoke-pester ./Functions -CodeCoverage ..\Modules\VMware.VMC\VMware.VMC.psm1 -------------------------------------------------------------------------------- /Pester/ZZ Test Disconnect-CISServer to VC.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: Test Disconnect-CISServer to VC.Tests.ps1 3 | Created on: 04/20/2017 4 | Author: Alan Renouf, @alanrenouf 5 | Description: The purpose of this pester test is to ensure the Disconnect-CISServer cmdlet disconnects 6 | Dependencies: Pester Module 7 | Example run: 8 | 9 | Invoke-Pester -Script @{ Path = '.\Test Disconnect-CISServer to VC.Tests.ps1'; Parameters = @{ VCNAME="VC01.local" } } 10 | 11 | #> 12 | 13 | $VCNAME = $Parameters.Get_Item("VCNAME") 14 | 15 | Describe "Disconnect-CISServer Tests" { 16 | It "Disconnect from $VCName" { 17 | Disconnect-CISServer $VCName -confirm:$false 18 | $Global:DefaultCISServers | Should Be $null 19 | } 20 | } -------------------------------------------------------------------------------- /Pester/ZZ Test Disconnect-VIServer to VC.Tests.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: Test Disconnect-VIServer to VC.ps1 3 | Created on: 04/20/2017 4 | Author: Alan Renouf, @alanrenouf 5 | Description: The purpose of this pester test is to ensure the Disconnect-VIServer cmdlet disconnects 6 | Dependencies: Pester Module 7 | Example run: 8 | 9 | Invoke-Pester -Script @{ Path = '.\Test Disconnect-VISServer to VC.ps1'; Parameters = @{ VCNAME="VC01.local" } } 10 | 11 | #> 12 | 13 | $VCNAME = $Parameters.Get_Item("VCNAME") 14 | 15 | Describe "Disconnect-VIServer Tests" { 16 | It "Disconnect from $VCName" { 17 | Disconnect-VIServer $VCName -confirm:$false 18 | $Global:DefaultVIServer | Should Be $null 19 | } 20 | } -------------------------------------------------------------------------------- /PowerActions/Example - ClusterSnapshotsReport.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [Parameter(Mandatory=$true)] 3 | [VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster[]] $cluster, 4 | [Parameter(Mandatory=$true)] 5 | [string] $smtp, 6 | [Parameter(Mandatory=$true)] 7 | [string] $email) 8 | 9 | $vms = Get-VM -Location $cluster 10 | $snapshots = @() 11 | foreach ($vm in $vms) { 12 | $snapshots += Get-Snapshot -VM $vm 13 | } 14 | 15 | $header = @" 16 | 41 | "@ 42 | 43 | $snapshots | select Name,VM,Created,@{Name="Size";Expression={[math]::Round($_.SizeMB,3)}},IsCurrent | ` 44 | ConvertTo-Html -head $header | Out-File "SnapshotReport.html" 45 | 46 | Send-MailMessage -from "Snapshot Reports " ` 47 | -to $email ` 48 | -subject "Snapshot Report" ` 49 | -body "Cluster snapshot report" ` 50 | -Attachment "SnapshotReport.html" ` 51 | -smtpServer $smtp -------------------------------------------------------------------------------- /PowerActions/Example - RemoveOldClusterSnapshots.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [Parameter(Mandatory=$true)] 3 | [VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster] $cluster, 4 | [DateTime] $date) 5 | 6 | if ($null -eq $date) { 7 | $date = (Get-Date).AddDays(-7) 8 | } 9 | 10 | $vms = Get-VM -Location $cluster 11 | foreach ($vm in $vms) { 12 | $snaphostsToBeRemoved = Get-Snapshot -VM $vm | where {$_.Created -lt $date} 13 | if ($null -ne $snaphostsToBeRemoved) { 14 | Write-Host "Removing snapshots: '$snaphostsToBeRemoved' of VM: '$vm'" 15 | Remove-Snapshot $snaphostsToBeRemoved -Confirm:$false 16 | } 17 | } -------------------------------------------------------------------------------- /PowerActions/Git Sync.ps1: -------------------------------------------------------------------------------- 1 | #Intall git 2 | tdnf install -y git 3 | 4 | #Clone the repo 5 | git clone -n --depth=1 --filter=tree:0 https://github.com/vmware/PowerCLI-Example-Scripts.git 6 | cd PowerCLI-Example-Scripts 7 | git sparse-checkout set --no-cone PowerActions 8 | git checkout 9 | cd PowerActions 10 | 11 | #Select the content library in which you want to store the scirpts from the repo 12 | $contentLibraryName = 'Power Actions' 13 | $contentLibrary = Get-ContentLibrary $contentLibraryName 14 | 15 | #Get all the files that we have cloned from the repo 16 | $files = Get-ChildItem -Path . -File 17 | foreach ($file in $files) { 18 | $name = $file.BaseName 19 | 20 | #Check if the item for this file already exists in the content library 21 | $item = Get-ContentLibraryItem -Name $name -ContentLibrary $contentLibrary -ErrorAction SilentlyContinue 22 | if ($item) { 23 | #If the item exists, check if it is up to date 24 | #Create a folder to store the current content library item 25 | if (-not (Test-Path -Path ./cl_versions -PathType Container)) 26 | { 27 | New-Item -Path ./cl_versions -ItemType Directory 28 | } 29 | #Download the item from the content library 30 | $clFile = Export-ContentLibraryItem -ContentLibraryItem $item -Destination ((Get-Location).Path + "/cl_version") -Force 31 | #Compare if it's the same as the file we have downloaded from the repo 32 | $compResult = Compare-Object -ReferenceObject (Get-Content $file.FullName) -DifferenceObject (Get-Content ($clFile.FullName+"/"+$file.Name)) 33 | if ($compResult) { 34 | #If the item is not up to date, update it 35 | Write-Host "Updating $name" 36 | Set-ContentLibraryItem -ContentLibraryItem $item -Files $file.FullName 37 | } else { 38 | Write-Host "$name is up to date" 39 | } 40 | } else { 41 | #If the item does not exist, create it 42 | New-ContentLibraryItem -Name $name -Files $file.FullName -ContentLibrary $contentLibrary 43 | } 44 | } -------------------------------------------------------------------------------- /PowerActions/README.md: -------------------------------------------------------------------------------- 1 | PowerAction Scripts 2 | -------------------------------------------------------------------------------- /Scripts/At_Your_Fingertips/install-profile.ps1: -------------------------------------------------------------------------------- 1 | [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')] 2 | param( 3 | # [Parameter(Mandatory = $true)] 4 | [ValidateSet('CurrentUserCurrentHost', 'CurrentUserAllHosts', 5 | 'AllUsersCurrentHost', 'AllUsersAllHosts')] 6 | [string]$Scope, 7 | [switch]$NoClobber, 8 | [switch]$Backup, 9 | [string]$NewProfile = '.\NewProfile.ps1' 10 | ) 11 | 12 | if ($PSCmdlet.ShouldProcess("$($Profile.$Scope)", "Create $Scope profile")) 13 | { 14 | $profilePath = $Profile."$Scope" 15 | Write-Verbose -Message "Target is $profilePath" 16 | $createProfile = $true 17 | if (Test-Path -Path $profilePath) 18 | { 19 | Write-Verbose -Message "Target exists" 20 | if ($NoClobber) 21 | { 22 | Write-Verbose -Message "Cannot overwrite target due to NoClobber" 23 | $createProfile = $false 24 | } 25 | elseif ($Backup) 26 | { 27 | Write-Verbose -Message "Create a backup as $profilePath.bak" 28 | Copy-Item -Path $profilePath -Destination "$profilePath.bak" -Confirm:$false -Force 29 | } 30 | elseif (-not $NoClobber) 31 | { 32 | Write-Verbose -Message "Target will be overwritten" 33 | } 34 | else 35 | { 36 | Write-Verbose -Message "Use -NoClobber:$false or -Backup" 37 | } 38 | } 39 | if ($createProfile) 40 | { 41 | if (-not $NewProfile) 42 | { 43 | $script:MyInvocation.MyCommand | select * 44 | $folder = Split-Path -Parent -Path $script:MyInvocation.MyCommand.Path 45 | $folder = Get-Location 46 | $NewProfile = "$folder\NewProfile.ps1" 47 | } 48 | Write-Verbose -Message "New profile expected at $NewProfile" 49 | if (Test-Path -Path $NewProfile) 50 | { 51 | Write-Verbose -Message "Copy $NewProfile to $profilePath" 52 | Copy-Item -Path $NewProfile -Destination $profilePath -Confirm:$false 53 | } 54 | else 55 | { 56 | Write-Warning -Message "Could not find the new profile file!" 57 | Write-Warning -Message "Use the NewProfile parameter or store a NewProfile.ps1 file in folder $folder." 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Scripts/Check-VMwareTools.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | function Check-Tools { 6 | <# 7 | .NOTES 8 | =========================================================================== 9 | Created by: Brian Graf 10 | Organization: VMware 11 | Official Blog: blogs.vmware.com/PowerCLI 12 | Personal Blog: www.vtagion.com 13 | Twitter: @vBrianGraf 14 | =========================================================================== 15 | .DESCRIPTION 16 | This will quickly return all VMs that have VMware Tools out of date 17 | Along with the version that it is running 18 | .Example 19 | Check-Tools -VMs (Get-VM) 20 | .Example 21 | $SampleVMs = Get-VM "Mgmt*" 22 | Check-Tools -VMs $SampleVMs 23 | #> 24 | [CmdletBinding()] 25 | param( 26 | [Parameter(Mandatory=$true, 27 | ValueFromPipeline=$True, 28 | Position=0)] 29 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] 30 | $VMs 31 | ) 32 | Process { 33 | #foreach ($VM in $VMs) { 34 | $OutofDate = $VMs | where {$_.ExtensionData.Guest.ToolsStatus -ne "toolsOk"} 35 | $Result = @($OutofDate | select Name,@{Name="ToolsVersion";Expression={$_.ExtensionData.Guest.Toolsversion}}) 36 | 37 | $Result 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /Scripts/CreateVLANonStandardSwitch: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: CreateVLANonStandardSwitch.ps1 3 | Created on: 10/26/2017 4 | Author: Alan Comstock, @Mr_Uptime 5 | Description: Adds VLANs to an existing standard switch 6 | Dependencies: None known 7 | PowerCLI Version: VMware PowerCLI 6.5 Release 1 build 4624819 8 | PowerShell Version: 5.1.14393.1532 9 | OS Version: Windows 10 10 | #> 11 | 12 | $esxhost="HOSTNAME" 13 | $vswitch="vSwitch0" 14 | $vlanlist=10,20,30,40,50 15 | Foreach ($vlan in $vlanlist) { 16 | $portgroupname="VLAN " + $vlan 17 | Get-VMHost $esxhost | Get-VirtualSwitch -name $vswitch | New-VirtualPortGroup -Name $portgroupname -VLanId $vlan 18 | } 19 | #The End 20 | -------------------------------------------------------------------------------- /Scripts/ESXInstallDate.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | <# 7 | .SYNOPSIS Retrieve the installation date of an ESXi host 8 | .NOTES Author: William Lam 9 | .NOTES Site: www.virtuallyghetto.com 10 | .NOTES Reference: http://www.virtuallyghetto.com/2016/10/super-easy-way-of-getting-esxi-installation-date-in-vsphere-6-5.html 11 | .PARAMETER Vmhost 12 | ESXi host to query installation date 13 | .EXAMPLE 14 | Get-Vmhost "mini" | Get-ESXInstallDate 15 | #> 16 | 17 | Function Get-ESXInstallDate { 18 | param( 19 | [Parameter( 20 | Mandatory=$true, 21 | ValueFromPipeline=$true, 22 | ValueFromPipelineByPropertyName=$true) 23 | ] 24 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$Vmhost 25 | ) 26 | 27 | if($Vmhost.Version -eq "6.5.0") { 28 | $imageManager = Get-View ($Vmhost.ExtensionData.ConfigManager.ImageConfigManager) 29 | $installDate = $imageManager.installDate() 30 | 31 | Write-Host "$Vmhost was installed on $installDate" 32 | } else { 33 | Write-Host "ESXi must be running 6.5" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Scripts/ESXInstalledVIBs.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | 6 | <# 7 | .SYNOPSIS Retrieve the installation date of an ESXi host 8 | .NOTES Author: William Lam 9 | .NOTES Site: www.virtuallyghetto.com 10 | .PARAMETER Vmhost 11 | ESXi host to query installed ESXi VIBs 12 | .EXAMPLE 13 | Get-ESXInstalledVibs -Vmhost (Get-Vmhost "mini") 14 | .EXAMPLE 15 | Get-ESXInstalledVibs -Vmhost (Get-Vmhost "mini") -vibname vsan 16 | #> 17 | 18 | Function Get-ESXInstalledVibs { 19 | param( 20 | [Parameter( 21 | Mandatory=$true, 22 | ValueFromPipeline=$true, 23 | ValueFromPipelineByPropertyName=$true) 24 | ] 25 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$Vmhost, 26 | [Parameter( 27 | Mandatory=$false, 28 | ValueFromPipeline=$true, 29 | ValueFromPipelineByPropertyName=$true) 30 | ] 31 | [String]$vibname="" 32 | ) 33 | 34 | $imageManager = Get-View ($Vmhost.ExtensionData.ConfigManager.ImageConfigManager) 35 | $vibs = $imageManager.fetchSoftwarePackages() 36 | 37 | foreach ($vib in $vibs) { 38 | if($vibname -ne "") { 39 | if($vib.name -eq $vibname) { 40 | return $vib | select Name, Version, Vendor, CreationDate, Summary 41 | } 42 | } else { 43 | $vib | select Name, Version, Vendor, CreationDate, Summary 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Scripts/FindVSphereCommand/FindVSphereCommand.Format.ps1xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | vSphereCommand 5 | 6 | Operation 7 | 8 | 9 | 10 | 11 | 12 | 20 13 | left 14 | 15 | 16 | 17 | 40 18 | left 19 | 20 | 21 | 22 | 7 23 | center 24 | 25 | 26 | 27 | 53 28 | left 29 | 30 | 31 | 32 | 33 | 34 | 35 | Name 36 | 37 | 38 | CommandName 39 | 40 | 41 | Method 42 | 43 | 44 | Path 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Scripts/Get-BasicVMCapacityReport: -------------------------------------------------------------------------------- 1 | 2 | $myCol = @() 3 | $start = (Get-Date).AddDays(-30) 4 | $finish = Get-Date 5 | $cluster= "Demo" 6 | 7 | $objServers = Get-Cluster $cluster | Get-VM 8 | foreach ($server in $objServers) { 9 | if ($server.guest.osfullname -ne $NULL){ 10 | if ($server.guest.osfullname.contains("Windows")){ 11 | $stats = get-stat -Entity $server -Stat "cpu.usage.average","mem.usage.average" -Start $start -Finish $finish 12 | 13 | $ServerInfo = "" | Select-Object vName, OS, Mem, AvgMem, MaxMem, CPU, AvgCPU, MaxCPU, pDisk, Host 14 | $ServerInfo.vName = $server.name 15 | $ServerInfo.OS = $server.guest.osfullname 16 | $ServerInfo.Host = $server.vmhost.name 17 | $ServerInfo.Mem = $server.memoryGB 18 | $ServerInfo.AvgMem = $("{0:N2}" -f ($stats | Where-Object {$_.MetricId -eq "mem.usage.average"} | Measure-Object -Property Value -Average).Average) 19 | $ServerInfo.MaxMem = $("{0:N2}" -f ($stats | Where-Object {$_.MetricId -eq "mem.usage.average"} | Measure-Object -Property Value -Maximum).Maximum) 20 | $ServerInfo.CPU = $server.numcpu 21 | $ServerInfo.AvgCPU = $("{0:N2}" -f ($stats | Where-Object {$_.MetricId -eq "cpu.usage.average"} | Measure-Object -Property Value -Average).Average) 22 | $ServerInfo.MaxCPU = $("{0:N2}" -f ($stats | Where-Object {$_.MetricId -eq "cpu.usage.average"} | Measure-Object -Property Value -Maximum).Maximum) 23 | $ServerInfo.pDisk = [Math]::Round($server.ProvisionedSpaceGB,2) 24 | 25 | $mycol += $ServerInfo 26 | } 27 | } 28 | } 29 | 30 | $myCol | Sort-Object vName | Export-Csv "VM_report.csv" -NoTypeInformation 31 | -------------------------------------------------------------------------------- /Scripts/Get-BiosBootStatus.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Copyright 2021 VMware, Inc. 3 | SPDX-License-Identifier: BSD-2-Clause 4 | #> 5 | function Get-BiosBootStatus { 6 | <# 7 | .NOTES 8 | =========================================================================== 9 | Created by: Brian Graf 10 | Organization: VMware 11 | Official Blog: blogs.vmware.com/PowerCLI 12 | Personal Blog: www.vtagion.com 13 | Twitter: @vBrianGraf 14 | =========================================================================== 15 | .DESCRIPTION 16 | This will return the boot status of Virtual Machines, whether they 17 | are booting to the Guest OS or being forced to boot into BIOS. 18 | .Example 19 | # Returns all VMs and where they are booting 20 | Get-BiosBootStatus -VMs (Get-VM) 21 | .Example 22 | # Only returns VMs that are booting to BIOS 23 | Get-BiosBootStatus (Get-VM) -IsSetup 24 | 25 | #> 26 | [CmdletBinding()] 27 | param( 28 | [Parameter(Mandatory=$true, 29 | ValueFromPipeline=$True, 30 | Position=0)] 31 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] 32 | $VM, 33 | [switch]$IsSetup 34 | ) 35 | Process { 36 | if($IsSetup) 37 | { 38 | $Execute = $VM | where {$_.ExtensionData.Config.BootOptions.EnterBiosSetup -eq "true"} | Select Name,@{Name="EnterBiosSetup";Expression={$_.ExtensionData.config.BootOptions.EnterBiosSetup}} 39 | } 40 | else 41 | { 42 | $Execute = $VM | Select Name,@{Name="EnterBiosSetup";Expression={$_.ExtensionData.config.BootOptions.EnterBiosSetup}} 43 | } 44 | } 45 | End {$Execute} 46 | } -------------------------------------------------------------------------------- /Scripts/Get-Migrations.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: get-migrations.ps1 3 | Created on: 20/12/2018 4 | Author: Chris Bradshaw @aldershotchris 5 | Description: The purpose of the script is to list the currently running + recently finished VM migrations. 6 | Dependencies: None known 7 | #> 8 | Function Get-Migrations{ 9 | Get-Task | 10 | Where-Object{$_.Name -eq "RelocateVM_Task"} | 11 | Select-Object @{Name="VM";Expression={Get-VM -Id $_.ObjectID}}, State, @{Name="% Complete";Expression={$_.PercentComplete}},StartTime 12 | } 13 | -------------------------------------------------------------------------------- /Scripts/Get-TotalDiskUsage.ps1: -------------------------------------------------------------------------------- 1 | #Script returns total disk usage by all Powered On VMs in the environment in Gigabytes 2 | #Author: Chris Bradshaw via https://isjw.uk/using-powercli-to-measure-vm-disk-space-usage/ 3 | 4 | [math]::Round(((get-vm | Where-object{$_.PowerState -eq "PoweredOn" }).UsedSpaceGB | measure-Object -Sum).Sum) 5 | -------------------------------------------------------------------------------- /Scripts/Get-TotalMemoryAllocation.ps1: -------------------------------------------------------------------------------- 1 | #Script gets total memory allocation in GB of all powered on VMs in the environment 2 | #Author: Chris Bradshaw via https://isjw.uk/powercli-snippet-total-memory-allocation/ 3 | 4 | [System.Math]::Round(((get-vm | 5 | where-object{$_.PowerState -eq "PoweredOn" }).MemoryGB | 6 | Measure-Object -Sum).Sum ,0) 7 | -------------------------------------------------------------------------------- /Scripts/Get-TriggeredAlarm.ps1: -------------------------------------------------------------------------------- 1 | function Get-TriggeredAlarm { 2 | <# 3 | .SYNOPSIS 4 | This function lists the triggered alarms for the specified entity in vCenter 5 | .DESCRIPTION 6 | List the triggered alarms for the given object 7 | .NOTES 8 | Author: Kyle Ruddy, @kmruddy, kmruddy.com 9 | .PARAMETER VM 10 | Specifies the name of the VM 11 | .PARAMETER VMHost 12 | Specifies the name of the VMHost 13 | .PARAMETER Datacenter 14 | Specifies the name of the Datacenter 15 | .PARAMETER Datastore 16 | Specifies the name of the Datastore 17 | .EXAMPLE 18 | Get-TriggeredAlarm -VM VMname 19 | 20 | Entity Alarm AlarmStatus AlarmMoRef EntityMoRef 21 | ---- ---- ---- ---- ---- 22 | VMname Name Yellow Alarm-MoRef Entity-MoRef 23 | #> 24 | 25 | [CmdletBinding()] 26 | param( 27 | [string]$VM, 28 | [string]$VMHost, 29 | [string]$Datacenter, 30 | [string]$Datastore 31 | ) 32 | BEGIN { 33 | switch ($PSBoundParameters.Keys) { 34 | 'VM' {$entity = Get-VM -Name $vm -ErrorAction SilentlyContinue} 35 | 'VMHost' {$entity = Get-VMHost -Name $VMHost -ErrorAction SilentlyContinue} 36 | 'Datacenter' {$entity = Get-Datacenter -Name $Datacenter -ErrorAction SilentlyContinue} 37 | 'Datastore' {$entity = Get-Datastore -Name $Datastore -ErrorAction SilentlyContinue} 38 | default {$entity = $null} 39 | } 40 | 41 | if ($null -eq $entity) { 42 | Write-Warning "No vSphere object found." 43 | break 44 | } 45 | } 46 | PROCESS { 47 | if ($entity.ExtensionData.TriggeredAlarmState -ne "") { 48 | $alarmOutput = @() 49 | foreach ($alarm in $entity.ExtensionData.TriggeredAlarmState) { 50 | $tempObj = "" | Select-Object -Property Entity, Alarm, AlarmStatus, AlarmMoRef, EntityMoRef 51 | $tempObj.Entity = Get-View $alarm.Entity | Select-Object -ExpandProperty Name 52 | $tempObj.Alarm = Get-View $alarm.Alarm | Select-Object -ExpandProperty Info | Select-Object -ExpandProperty Name 53 | $tempObj.AlarmStatus = $alarm.OverallStatus 54 | $tempObj.AlarmMoRef = $alarm.Alarm 55 | $tempObj.EntityMoRef = $alarm.Entity 56 | $alarmOutput += $tempObj 57 | } 58 | $alarmOutput | Format-Table -AutoSize 59 | } 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /Scripts/Get-VMHostWWPN.ps1: -------------------------------------------------------------------------------- 1 | function Get-VMHostWWPN { 2 | <# 3 | Script name: Get-VMHostWWPN.ps1 4 | Created on: 08/31/2017 5 | Author: Robin Haberstroh, @strohland 6 | Description: This script returns the WWPN of the hosts FiberChannel HBA in a readable format that corresponds to what storage team expects 7 | Dependencies: None known 8 | #> 9 | param( 10 | [string]$cluster 11 | ) 12 | 13 | Get-Cluster $cluster | get-vmhost | get-vmhosthba -type FibreChannel | 14 | format-table VMHost, Device, @{ 15 | n='WorldWidePortName';e={[convert]::ToString($_.PortWorldWideName, 16)} 16 | } 17 | } -------------------------------------------------------------------------------- /Scripts/Get-VMID.ps1: -------------------------------------------------------------------------------- 1 | function Get-VMID { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Organization: Private 7 | Personal Blog: mycloudrevolution.com 8 | Twitter: @vMarkus_K 9 | =========================================================================== 10 | .DESCRIPTION 11 | This will quickly return all IDs of VMs 12 | .Example 13 | Get-VMID -myVMs (Get-VM) | ft 14 | .Example 15 | $SampleVMs = Get-VM "tst*" 16 | Get-VMID -myVMs $SampleVMs 17 | #> 18 | [CmdletBinding()] 19 | param( 20 | [Parameter(Mandatory=$true, 21 | ValueFromPipeline=$True, 22 | Position=0)] 23 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] 24 | $myVMs 25 | ) 26 | Process { 27 | 28 | $MyView = @() 29 | ForEach ($myVM in $myVMs){ 30 | $UUIDReport = [PSCustomObject] @{ 31 | Name = $myVM.name 32 | UUID = $myVM.extensiondata.Config.UUID 33 | InstanceUUID = $myVM.extensiondata.config.InstanceUUID 34 | LocationID = $myVM.extensiondata.config.LocationId 35 | MoRef = $myVM.extensiondata.Moref.Value 36 | } 37 | $MyView += $UUIDReport 38 | } 39 | $MyView 40 | } 41 | } -------------------------------------------------------------------------------- /Scripts/Get-VMNetworkPortId.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Finds the local ESXi network Port-ID where a VM is assigned 4 | .DESCRIPTION 5 | Reports back a VM's Port-ID according to the local ESXi host. This correlates to the Port-ID which is displayed via ESXTop 6 | .NOTES 7 | Author: Kyle Ruddy, @kmruddy, thatcouldbeaproblem.com 8 | .PARAMETER vm 9 | The name of the desired VM 10 | .EXAMPLE 11 | PS> .\Get-VMNetworkPortId.ps1 -vm vmname 12 | .EXAMPLE 13 | PS> Get-VM -Name vmname | .\Get-VMNetworkPortId.ps1 14 | #> 15 | [CmdletBinding(SupportsShouldProcess=$True)] 16 | param( 17 | [Parameter(Mandatory=$true,Position=0,ValueFromPipelineByPropertyName=$true)] 18 | [Alias('Name')] 19 | [String[]]$vm 20 | ) 21 | 22 | Begin { 23 | #Create an array to store output prior to return 24 | $output = @() 25 | 26 | } 27 | 28 | Process { 29 | #Loop through each of the input values 30 | foreach ($v in $vm) { 31 | #Validate the input is a valid VM 32 | $vmobj = Get-VM -Name $v -erroraction silentlycontinue 33 | if (!$vmobj) {Write-Verbose "No VM found by the name $v."} 34 | else { 35 | #Create a temporary object to store individual ouput 36 | $tempout = "" | select VM,PortId 37 | #Start an ESXCLI session with the host where the VM resides 38 | $esxcli = Get-EsxCli -VMHost $vmobj.VMHost -v2 39 | #ESXCLI call to obtain information about the VM, specifically its WorldID 40 | $vmNetInfo = $esxcli.network.vm.list.Invoke() | ?{$_.Name -eq $vmobj.Name} 41 | #Create spec to poll the host for the network information of the VM 42 | $portArgs = $esxcli.network.vm.port.list.CreateArgs() 43 | $portArgs.worldid = $vmNetInfo.WorldID 44 | #Output the values to the temporary object 45 | $tempout.VM = $vmobj.Name 46 | $tempout.PortId = $esxcli.network.vm.port.list.Invoke($portArgs).PortId 47 | $output += $tempout 48 | } 49 | } 50 | } 51 | 52 | End { 53 | 54 | return $output 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Scripts/Get-VMToolsParts.ps1: -------------------------------------------------------------------------------- 1 | $vms = Get-VM | where {$_.PowerState -eq "PoweredOn" -and $_.GuestId -match "Windows"} 2 | 3 | ForEach ($vm in $vms){ 4 | Write-Host $vm 5 | $namespace = "root\CIMV2" 6 | $componentPattern = "hcmon|vmci|vmdebug|vmhgfs|VMMEMCTL|vmmouse|vmrawdsk|vmxnet|vmx_svga" 7 | (Get-WmiObject -class Win32_SystemDriver -computername $vm -namespace $namespace | 8 | where-object { $_.Name -match $componentPattern } | 9 | Format-Table -Auto Name,State,StartMode,DisplayName 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /Scripts/Get-VsanHclDatabase.ps1: -------------------------------------------------------------------------------- 1 | Function Get-VsanHclDatabase { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Alan Renouf 6 | Organization: VMware 7 | Blog: http://virtu-al.net 8 | Twitter: @alanrenouf 9 | =========================================================================== 10 | .SYNOPSIS 11 | This function will allow you to view and download the VSAN Hardware Compatability List (HCL) Database 12 | 13 | .DESCRIPTION 14 | Use this function to view or download the VSAN HCL 15 | .EXAMPLE 16 | View the latest online HCL Database from online source 17 | PS C:\> Get-VsanHclDatabase | Format-Table 18 | .EXAMPLE 19 | Download the latest HCL Database from online source and store locally 20 | PS C:\> Get-VsanHclDatabase -filepath ~/hcl.json 21 | #> 22 | param ($filepath) 23 | $uri = "https://partnerweb.vmware.com/service/vsan/all.json" 24 | If ($filepath) { 25 | Invoke-WebRequest -Uri $uri -OutFile $filepath 26 | } Else { 27 | Invoke-WebRequest -Uri $uri | ConvertFrom-Json | Select-Object -ExpandProperty Data | Select-object -ExpandProperty Controller 28 | } 29 | } -------------------------------------------------------------------------------- /Scripts/Home Lab/Home Lab Delete settings.ps1: -------------------------------------------------------------------------------- 1 | $ESXIP = "192.168.1.201" 2 | $ESXUser = "root" 3 | $ESXPWD = "VMware1!" 4 | 5 | Connect-viserver $esxip -user $ESXUser -pass $ESXPWD 6 | 7 | #Leaving confirm off just in case someone happens to be connected to more than one vCenter/Host! 8 | Get-VM | Stop-VM 9 | Get-VM | Remove-VM 10 | 11 | $ESXCLI = Get-EsxCli -v2 -VMHost (get-VMHost) 12 | $esxcli.vsan.cluster.leave.invoke() 13 | 14 | $VSANDisks = $esxcli.storage.core.device.list.invoke() | Where {$_.isremovable -eq "false"} | Sort size 15 | $Performance = $VSANDisks[0] 16 | $Capacity = $VSANDisks[1] 17 | 18 | $removal = $esxcli.vsan.storage.remove.CreateArgs() 19 | $removal.ssd = $performance.Device 20 | $esxcli.vsan.storage.remove.Invoke($removal) 21 | 22 | $capacitytag = $esxcli.vsan.storage.tag.remove.CreateArgs() 23 | $capacitytag.disk = $Capacity.Device 24 | $capacitytag.tag = "capacityFlash" 25 | $esxcli.vsan.storage.tag.remove.Invoke($capacitytag) 26 | 27 | Set-VMHostSysLogServer $null 28 | Remove-VMHostNtpServer (Get-VMHostNtpServer) -Confirm:$false -------------------------------------------------------------------------------- /Scripts/Horizon View Example Desktop Script.ps1: -------------------------------------------------------------------------------- 1 | Function Get-HVDesktop { 2 | <# 3 | .SYNOPSIS 4 | This cmdlet retrieves the virtual desktops on a horizon view Server. 5 | .DESCRIPTION 6 | This cmdlet retrieves the virtual desktops on a horizon view Server. 7 | .NOTES 8 | Author: Alan Renouf, @alanrenouf,virtu-al.net 9 | .PARAMETER State 10 | Hash table containing states to filter on 11 | .EXAMPLE 12 | List All Desktops 13 | Get-HVDesktop 14 | 15 | .EXAMPLE 16 | List All Problem Desktops 17 | Get-HVDesktop -state @('PROVISIONING_ERROR', 18 | 'ERROR', 19 | 'AGENT_UNREACHABLE', 20 | 'AGENT_ERR_STARTUP_IN_PROGRESS', 21 | 'AGENT_ERR_DISABLED', 22 | 'AGENT_ERR_INVALID_IP', 23 | 'AGENT_ERR_NEED_REBOOT', 24 | 'AGENT_ERR_PROTOCOL_FAILURE', 25 | 'AGENT_ERR_DOMAIN_FAILURE', 26 | 'AGENT_CONFIG_ERROR', 27 | 'UNKNOWN') 28 | #> 29 | Param ( 30 | $State 31 | ) 32 | 33 | $ViewAPI = $global:DefaultHVServers[0].ExtensionData 34 | $query_service = New-Object "Vmware.Hv.QueryServiceService" 35 | $query = New-Object "Vmware.Hv.QueryDefinition" 36 | $query.queryEntityType = 'MachineSummaryView' 37 | if ($State) { 38 | [VMware.Hv.QueryFilter []] $filters = @() 39 | foreach ($filterstate in $State) { 40 | $filters += new-object VMware.Hv.QueryFilterEquals -property @{'memberName' = 'base.basicState'; 'value' = $filterstate} 41 | } 42 | $orFilter = new-object VMware.Hv.QueryFilterOr -property @{'filters' = $filters} 43 | $query.Filter = $orFilter 44 | } 45 | $Desktops = $query_service.QueryService_Query($ViewAPI,$query) 46 | $Desktops.Results.Base 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /Scripts/Horizon-GetUsageStats.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | Script name: Horizon-UsageStats.ps1 4 | Author: Ray Heffer, @rayheffer 5 | Last Edited on: 04/18/2017 6 | Dependencies: PowerCLI 6.5 R1 or later, Horizon 7.0.2 or later 7 | .DESCRIPTION 8 | This is a sample script that retrieves the Horizon usage statistics. This produces the same metrics as listed under View Configuration > Product Licensing and Usage. Service providers can use this script or incorporate it with their existing scripts to automate the reporting of Horizon usage. 9 | 10 | Example Output: 11 | NumConnections : 180 12 | NumConnectionsHigh : 250 13 | NumViewComposerConnections : 0 14 | NumViewComposerConnectionsHigh : 0 15 | NumTunneledSessions : 0 16 | NumPSGSessions : 180 17 | #> 18 | 19 | # User Configuration 20 | $hzUser = "Administrator" 21 | $hzPass = "VMware1!" 22 | $hzDomain = "vmw.lab" 23 | $hzConn = "connect01.vmw.lab" 24 | 25 | # Import the Horizon module 26 | Import-Module VMware.VimAutomation.HorizonView 27 | 28 | # Establish connection to Connection Server 29 | $hvServer = Connect-HVServer -server $hzConn -User $hzUser -Password $hzPass -Domain $hzDomain 30 | 31 | # Assign a variable to obtain the API Extension Data 32 | $hvServices = $Global:DefaultHVServers.ExtensionData 33 | 34 | # Retrieve Connection Server Health metrics 35 | $hvHealth =$hvServices.ConnectionServerHealth.ConnectionServerHealth_List() 36 | 37 | # Display ConnectionData (Usage stats) 38 | $hvHealth.ConnectionData 39 | -------------------------------------------------------------------------------- /Scripts/Invoke-BiosBoot.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-BiosBoot { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Brian Graf 6 | Organization: VMware 7 | Official Blog: blogs.vmware.com/PowerCLI 8 | Personal Blog: www.vtagion.com 9 | Twitter: @vBrianGraf 10 | =========================================================================== 11 | .DESCRIPTION 12 | This function allows you to set a VM to boot into BIOS or Guest OS 13 | .Example 14 | # Set a VM to boot to BIOS 15 | Invoke-BiosBoot -VMs (Get-VM) -Bios 16 | .Example 17 | Invoke-BiosBoot -VMs (Get-VM) -OS 18 | #> 19 | [CmdletBinding()] 20 | param( 21 | [Parameter(Mandatory=$true, 22 | ValueFromPipeline=$True, 23 | Position=0)] 24 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] 25 | $VM, 26 | [switch]$Bios, 27 | [switch]$OS 28 | ) 29 | Process { 30 | if($Bios) 31 | { 32 | Foreach ($VirtualMachine in $VM) { 33 | $object = New-Object VMware.Vim.VirtualMachineConfigSpec 34 | $object.bootOptions = New-Object VMware.Vim.VirtualMachineBootOptions 35 | $object.bootOptions.enterBIOSSetup = $true 36 | 37 | $Reconfigure = $VirtualMachine | Get-View 38 | $Reconfigure.ReconfigVM_Task($object) 39 | $Return 40 | } 41 | } 42 | if($OS) 43 | { 44 | Foreach ($VirtualMachine in $VM) { 45 | $object = New-Object VMware.Vim.VirtualMachineConfigSpec 46 | $object.bootOptions = New-Object VMware.Vim.VirtualMachineBootOptions 47 | $object.bootOptions.enterBIOSSetup = $false 48 | 49 | $Reconfigure = $VirtualMachine | Get-View 50 | $Reconfigure.ReconfigVM_Task($object) 51 | $Return 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Scripts/Move-DatastoreCluster.ps1: -------------------------------------------------------------------------------- 1 | function Move-DatastoreCluster { 2 | <# 3 | .SYNOPSIS 4 | Moves a datastore cluster to a new location 5 | .DESCRIPTION 6 | Will move a datastore cluster to a new location 7 | .NOTES 8 | Author: Kyle Ruddy, @kmruddy 9 | .PARAMETER DatastoreCluster 10 | Specifies the datastore cluster you want to move. 11 | .PARAMETER Destination 12 | Specifies a destination where you want to place the datastore cluster 13 | .EXAMPLE 14 | Move-DatastoreCluster -DatastoreCluster $DSCluster -Destination $DSClusterFolder 15 | Moves the $DSCluster datastore cluster to the specified $DSClusterFolder folder. 16 | #> 17 | [CmdletBinding(SupportsShouldProcess = $True)] 18 | param( 19 | [Parameter(Mandatory=$false,Position=0,ValueFromPipelineByPropertyName=$true)] 20 | [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.DatastoreCluster]$DatastoreCluster, 21 | [Parameter(Mandatory=$false,Position=1,ValueFromPipelineByPropertyName=$true)] 22 | [VMware.VimAutomation.ViCore.Types.V1.Inventory.Folder]$Destination 23 | ) 24 | 25 | if ($Global:DefaultVIServer.IsConnected -eq $false) { 26 | Write-Warning -Message "No vCenter Server connection found." 27 | break 28 | } 29 | 30 | If ($Pscmdlet.ShouldProcess($DatastoreCluster,"Move Datastore Cluster")) { 31 | $Destination.ExtensionData.MoveIntoFolder($DatastoreCluster.ExtensionData.MoRef) 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /Scripts/NVME Info.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Created by: Alan Renouf 5 | Organization: VMware 6 | Blog: http://virtu-al.net 7 | Twitter: @alanrenouf 8 | =========================================================================== 9 | #> 10 | 11 | Foreach ($vmhost in Get-VMHost) { 12 | $esxcli = get-esxcli -V2 -vmhost $vmhost 13 | Write-Host "Host: $($vmhost.name)" -ForegroundColor Green 14 | $devices = $esxcli.nvme.device.list.Invoke() 15 | Foreach ($device in $devices) { 16 | $nvmedevice = $esxcli.nvme.device.get.CreateArgs() 17 | $nvmedevice.adapter = $device.HBAName 18 | $esxcli.nvme.device.get.invoke($nvmedevice) | Select-Object ModelNumber, FirmwareRevision 19 | $features = $esxcli.nvme.device.feature.ChildElements | Select-object -ExpandProperty name 20 | ForEach ($feature in $features){ 21 | Write-Host "Feature: $feature" -ForegroundColor Yellow 22 | $currentfeature = $esxcli.nvme.device.feature.$feature.get.CreateArgs() 23 | $currentfeature.adapter = $device.HBAName 24 | $esxcli.nvme.device.feature.$feature.get.Invoke($currentfeature) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Scripts/New-ClusterHostGroup.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Script name: New-ClusterHostGroup.ps1 5 | Created on: 2016-10-25 6 | Author: Peter D. Jorgensen (@pjorg, pjorg.com) 7 | Dependencies: None known 8 | ===Tested Against Environment==== 9 | vSphere Version: 5.5, 6.0 10 | PowerCLI Version: PowerCLI 6.5R1 11 | PowerShell Version: 5.0 12 | OS Version: Windows 10, Windows 7 13 | =========================================================================== 14 | .DESCRIPTION 15 | Creates a DRS Host Group in a vSphere cluster. 16 | .Example 17 | $ProdCluster = Get-Cluster *prod* 18 | $OddHosts = $ProdCluster | Get-VMHost | ?{ $_.Name -match 'esxi-\d*[13579]+.\lab\.local' } 19 | .\New-ClusterHostGroup.ps1 -Name 'OddProdHosts' -Cluster $ProdCluster -VMHost $OddHosts 20 | #> 21 | [CmdletBinding()] 22 | Param( 23 | [Parameter(Mandatory=$True,Position=1)] 24 | [String]$Name, 25 | [Parameter(Mandatory=$True,ValueFromPipeline=$True,Position=2)] 26 | [VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster]$Cluster, 27 | [Parameter(Mandatory=$False,Position=3)] 28 | [VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost[]]$VMHost 29 | ) 30 | 31 | $NewGroup = New-Object VMware.Vim.ClusterHostGroup -Property @{ 32 | 'Name'=$Name 33 | 'Host'=$VMHost.Id 34 | } 35 | 36 | $spec = New-Object VMware.Vim.ClusterConfigSpecEx -Property @{ 37 | 'GroupSpec'=(New-Object VMware.Vim.ClusterGroupSpec -Property @{ 38 | 'Info'=$NewGroup 39 | }) 40 | } 41 | 42 | $ClusterToReconfig = Get-View -VIObject $Cluster -Property Name 43 | $ClusterToReconfig.ReconfigureComputeResource($spec, $true) -------------------------------------------------------------------------------- /Scripts/New-ClusterVmGroup.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Script name: New-ClusterVmGroup.ps1 5 | Created on: 2016-10-25 6 | Author: Peter D. Jorgensen (@pjorg, pjorg.com) 7 | Dependencies: None known 8 | ===Tested Against Environment==== 9 | vSphere Version: 5.5, 6.0 10 | PowerCLI Version: PowerCLI 6.5R1 11 | PowerShell Version: 5.0 12 | OS Version: Windows 10, Windows 7 13 | =========================================================================== 14 | .DESCRIPTION 15 | Creates a DRS VM Group in a vSphere cluster. 16 | .Example 17 | $ProdCluster = Get-Cluster *prod* 18 | $EvenVMs = $ProdCluster | Get-VM | ?{ $_.Name -match 'MyVM-\d*[02468]+' } 19 | .\New-ClusterVmGroup.ps1 -Name 'EvenVMs' -Cluster $ProdCluster -VM $EvenVMs 20 | #> 21 | [CmdletBinding()] 22 | Param( 23 | [Parameter(Mandatory=$True,Position=1)] 24 | [String]$Name, 25 | [Parameter(Mandatory=$True,ValueFromPipeline=$True,Position=2)] 26 | [VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster]$Cluster, 27 | [Parameter(Mandatory=$False,Position=3)] 28 | [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]]$VM 29 | ) 30 | 31 | $NewGroup = New-Object VMware.Vim.ClusterVmGroup -Property @{ 32 | 'Name'=$Name 33 | 'VM'=$VM.Id 34 | } 35 | 36 | $spec = New-Object VMware.Vim.ClusterConfigSpecEx -Property @{ 37 | 'GroupSpec'=(New-Object VMware.Vim.ClusterGroupSpec -Property @{ 38 | 'Info'=$NewGroup 39 | }) 40 | } 41 | 42 | $ClusterToReconfig = Get-View -VIObject $Cluster -Property Name 43 | $ClusterToReconfig.ReconfigureComputeResource($spec, $true) -------------------------------------------------------------------------------- /Scripts/New-ClusterVmHostRule.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Script name: New-ClusterVmHostRule.ps1 5 | Created on: 2016-10-25 6 | Author: Peter D. Jorgensen (@pjorg, pjorg.com) 7 | Dependencies: None known 8 | ===Tested Against Environment==== 9 | vSphere Version: 5.5, 6.0 10 | PowerCLI Version: PowerCLI 6.5R1 11 | PowerShell Version: 5.0 12 | OS Version: Windows 10, Windows 7 13 | =========================================================================== 14 | .DESCRIPTION 15 | Creates a VM to Host affinity rule in a vSphere cluster. 16 | .Example 17 | $ProdCluster = Get-Cluster *prod* 18 | .\New-ClusterVmHostRule.ps1 -Name 'Even VMs to Odd Hosts' -AffineHostGroupName 'OddHosts' -VMGroupName 'EvenVMs' -Enabled:$true -Cluster $ProdCluster 19 | #> 20 | [CmdletBinding()] 21 | Param( 22 | [Parameter(Mandatory=$True,Position=1)] 23 | [String]$Name, 24 | [Parameter(Mandatory=$True,Position=2)] 25 | [String]$AffineHostGroupName, 26 | [Parameter(Mandatory=$True,Position=3)] 27 | [String]$VMGroupName, 28 | [Parameter(Mandatory=$False,Position=4)] 29 | [Switch]$Enabled=$True, 30 | [Parameter(Mandatory=$True,ValueFromPipeline=$True,Position=5)] 31 | [VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster]$Cluster 32 | ) 33 | 34 | $NewRule = New-Object VMware.Vim.ClusterVmHostRuleInfo -Property @{ 35 | 'AffineHostGroupName'=$AffineHostGroupName 36 | 'VmGroupName'=$VMGroupName 37 | 'Enabled'=$Enabled 38 | 'Name'=$Name 39 | } 40 | 41 | $spec = New-Object VMware.Vim.ClusterConfigSpecEx -Property @{ 42 | 'RulesSpec'=(New-Object VMware.Vim.ClusterRuleSpec -Property @{ 43 | 'Info'=$NewRule 44 | }) 45 | } 46 | 47 | $ClusterToReconfig = Get-View -VIObject $Cluster -Property Name 48 | $ClusterToReconfig.ReconfigureComputeResource($spec, $true) -------------------------------------------------------------------------------- /Scripts/PAIF-N/README.md: -------------------------------------------------------------------------------- 1 | # VMware Private AI Foundation with NVIDIA Guide 2 | 3 | This example demonstrates how a VI admin would: 4 | 5 | * instantiate a new VCF workload domain for data scientist teams 6 | * setup the following infrastructure configuration required for **PAIF-N** workload domain 7 | 8 | ## Deploying a VI workload domain 9 | 10 | This script creates a VI workload domain using the **PowerCLI** SDK module for **VCF SDDC Manager**. 11 | 12 | The script can be broken into two main parts. First, the ESXi hosts are being commissioned. Then, the actual VI domain is created using the commissioned ESXi hosts. 13 | 14 | Both steps - ESXi host commissioning and VI domain creations - are three-stage operations themselves. The commissioning/creation specs are constructed. The specs are validated. The actual operation is invoked. The validation and operation invocation are long-running tasks. This requires awaiting and status tracking until their completion. The waiting for validation and the actual operation is done using helper cmdlets - 15 | Wait-VcfValidation and Wait-VcfTask, located in `utils` sub-folder. 16 | 17 | On completion, a new VI workload domain reflecting the given parameters should be created. 18 | 19 | ## ESXi hosts configuration for AI workloads 20 | 21 | This script configures the ESXi host for AI workloads which includes installing the Nvidia AI Enterprise vGPU driver and Nvidia GPU Management Daemon on the ESXi hosts. vLCM is used for that purpose. 22 | 23 | The script changes the default graphics type of the GPU devices to Shared Direct. The Xorg service is then restarted. Finally, the vLCM is used to install the NVIDIA GPU driver and management daemon. 24 | 25 | ## NSX Edge Cluster creation 26 | 27 | This script creates an NSX edge cluster to provide connectivity from external networks to Supervisor Cluster objects. 28 | 29 | ## Workload Management enablement and configuration 30 | 31 | This script enables Workload Management (Kubernetes) and sets it up for AI workloads. 32 | 33 | The script: 34 | 35 | 1. Enables the Supervisor cluster 36 | 2. Creates content library for the deep learning VM template 37 | 3. Creates GPU-enabled VMClass 38 | 4. Creates namespace(s) and assigns the created VMClass and assigns deep learning VM content library 39 | -------------------------------------------------------------------------------- /Scripts/README.md: -------------------------------------------------------------------------------- 1 | Sample Scripts 2 | -------------------------------------------------------------------------------- /Scripts/Remove-HostClient.ps1: -------------------------------------------------------------------------------- 1 | function Remove-HostClient { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created on: 8/13/2015 9:12 AM 6 | Created by: Brian Graf 7 | Github: http://www.github.com/vtagion 8 | Twitter: @vBrianGraf 9 | Website: http://www.vtagion.com 10 | =========================================================================== 11 | .DESCRIPTION 12 | This advanced function will allow you to remove the ESXi Host Client 13 | on all the hosts in a specified cluster. 14 | .Example 15 | Remove-HostClient -Cluster (Get-Cluster Management-CL) 16 | 17 | .Example 18 | $Cluster = Main-CL 19 | Remove-HostClient -Cluster $cluster 20 | #> 21 | [CmdletBinding()] 22 | param( 23 | [ValidateScript({Get-Cluster $_})] 24 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.ComputeResourceImpl]$Cluster 25 | ) 26 | Process { 27 | 28 | # Get all ESX hosts in cluster that meet criteria 29 | Get-VMhost -Location $Cluster | where { $_.PowerState -eq "PoweredOn" -and $_.ConnectionState -eq "Connected" } | foreach { 30 | 31 | Write-host "Preparing to remove Host Client from $($_.Name)" -ForegroundColor Yellow 32 | 33 | # Prepare ESXCLI variable 34 | $ESXCLI = Get-EsxCli -VMHost $_ 35 | 36 | # Check to see if VIB is installed on the host 37 | if (($ESXCLI.software.vib.list() | Where {$_.Name -match "esx-ui"})) { 38 | 39 | Write-host "Removing ESXi Embedded Host Client on $($_.Name)" -ForegroundColor Yellow 40 | 41 | # Command saved to variable for future verification 42 | $action = $esxcli.software.vib.remove($null,$null,$null,$null,"esx-ui") 43 | 44 | # Verify VIB removed successfully 45 | if ($action.Message -eq "Operation finished successfully."){Write-host "Action Completed successfully on $($_.Name)" -ForegroundColor Green} else {Write-host $action.Message -ForegroundColor Red} 46 | 47 | } else { Write-host "It appears Host Client is not installed on this host. Skipping..." -ForegroundColor Yellow } 48 | } 49 | } 50 | End {Write-host "Function complete" -ForegroundColor Green} 51 | } 52 | -------------------------------------------------------------------------------- /Scripts/Remove-IPPool.ps1: -------------------------------------------------------------------------------- 1 | Function Remove-IPPool { 2 | <# 3 | .Synopsis 4 | This function will remove IP-Pools from vCenter 5 | .Description 6 | This function will remove IP-Pools from vCenter based on the inputs provided 7 | .Example 8 | Assuming my datacenter was 'westwing' and my IPPool was 'IPPool1' 9 | remove-ippool westwing IPPool1 10 | .Notes 11 | Author: Brian Graf 12 | Role: Technical Marketing Engineer, VMware 13 | Last Edited: 05/01/2014 14 | 15 | #> 16 | [cmdletbinding()] 17 | Param ( 18 | [Parameter(ValueFromPipeline = $true, valuefrompipelinebypropertyname = $true)] 19 | [String]$Datacenter, 20 | [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 21 | [String]$PoolName 22 | ) 23 | 24 | Process { 25 | $dc = (Get-datacenter $Datacenter) 26 | $dcenter = New-Object VMware.Vim.ManagedObjectReference 27 | $dcenter.type = $dc.ExtensionData.moref.type 28 | $dcenter.Value = $dc.ExtensionData.moref.value 29 | 30 | $IPPoolManager = Get-View -Id 'IpPoolManager' 31 | $SelectedPool = ($IPPoolManager.QueryIpPools($dc.ID) | Where-Object { $_.Name -like $PoolName }) 32 | 33 | $IPPool = Get-View -Id 'IpPoolManager-IpPoolManager' 34 | $IPPool.DestroyIpPool($dcenter, $SelectedPool.id, $true) 35 | 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Scripts/Report-LUNPath-ESXCLI.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Created by: Markus Kraus 5 | Organization: Private 6 | Personal Blog: mycloudrevolution.com 7 | Twitter: @vMarkus_K 8 | =========================================================================== 9 | Tested Against Environment: 10 | vSphere Version: 6.0 U1, 5.5 U2 11 | PowerCLI Version: PowerCLI 6.3 R1 12 | PowerShell Version: 5.0 13 | OS Version: Windows 8.1, Server 2012 R2 14 | Keyword: ESXi, LUN, Path, Storage 15 | 16 | Dependencies: 17 | PowerCLI Version: PowerCLI 6.3 R1 18 | 19 | .DESCRIPTION 20 | This script will create a Report of LUNs with Paths that have more than one unique LUN ID or have more than the defined Paths. 21 | Information’s will be gathered via ESXCLI. This is necessary to report also hidden Paths! 22 | 23 | .Example 24 | ./Report-LUNPath-ESXCLI.ps1 25 | 26 | #> 27 | 28 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 29 | 30 | #region 1: Global Definitions 31 | $MaxLUNPaths = 2 32 | #endregion 33 | 34 | #region 2: Get all Connected Hosts 35 | $myHosts = Get-VMHost | where {$_.ConnectionState -eq "Connected" -and $_.PowerState -eq "PoweredOn"} 36 | #endregion 37 | 38 | #region 3: Create Report 39 | $Report = @() 40 | foreach ($myHost in $myHosts) { 41 | $esxcli2 = Get-ESXCLI -VMHost $myHost -V2 42 | $devices = $esxcli2.storage.core.path.list.invoke() | select Device -Unique 43 | 44 | foreach ($device in $devices) { 45 | $arguments = $esxcli2.storage.core.path.list.CreateArgs() 46 | $arguments.device = $device.Device 47 | $LUNs = $esxcli2.storage.core.path.list.Invoke($arguments) 48 | 49 | $LUNReport = [PSCustomObject] @{ 50 | HostName = $myHost.Name 51 | Device = $device.Device 52 | LUNPaths = $LUNs.Length 53 | LUNIDs = $LUNs.LUN | Select-Object -Unique 54 | } 55 | $Report += $LUNReport 56 | } 57 | } 58 | #endregion 59 | 60 | #region 4: Output Report 61 | $Report | where {$_.LUNPaths -gt $MaxLUNPaths -or ($_.LUNIDs | measure).count -gt 1 } | ft -AutoSize 62 | #endregion -------------------------------------------------------------------------------- /Scripts/Sample VMC firewall rules management.ps1: -------------------------------------------------------------------------------- 1 | $MyRefreshToken = "XXXX-XXXX-XXXX-XXXX" 2 | Connect-VMC -RefreshToken $MyRefreshToken 3 | 4 | #List the user firewall Rules for MGW 5 | Get-VMCFirewallRule -SDDCName "vGhetto" -OrgName "BashFest - Red Team" -GatewayType MGW 6 | 7 | #List the firewall rules including system firewall rules for MGW 8 | Get-VMCFirewallRule -SDDCName "vGhetto" -OrgName "BashFest - Red Team" -GatewayType MGW -ShowAll 9 | 10 | #Export Firewall Rules from original SDDC 11 | Export-VMCFirewallRule -SDDCName "vGhetto" -OrgName "BashFest - Red Team" -GatewayType MGW -Path ~/Desktop/VMCFirewallRules.json 12 | 13 | #Import Firewall Rules to new SDDC 14 | Import-VMCFirewallRule -SDDCName “Single-Host-SDDC” -OrgName "BashFest - Red Team" -GatewayType MGW -Path ~/Desktop/VMCFirewallRules.json 15 | 16 | #Remove the firewall Rules we just created for the SDDC 17 | $Rules = Get-VMCFirewallRule -SDDCName "Single-Host-SDDC" -OrgName "BashFest - Red Team" -GatewayType MGW 18 | Foreach ($rule in $rules){ 19 | Remove-VMCFirewallRule -SDDCName “Single-Host-SDDC” -OrgName "BashFest - Red Team" -GatewayType MGW -RuleId $rule.id 20 | } -------------------------------------------------------------------------------- /Scripts/SecureBoot.ps1: -------------------------------------------------------------------------------- 1 | Function Get-SecureBoot { 2 | <# 3 | .SYNOPSIS Query Seure Boot setting for a VM in vSphere 6.5 4 | .NOTES Author: William Lam 5 | .NOTES Site: www.virtuallyghetto.com 6 | .PARAMETER Vm 7 | VM to query Secure Boot setting 8 | .EXAMPLE 9 | Get-VM -Name Windows10 | Get-SecureBoot 10 | #> 11 | param( 12 | [Parameter( 13 | Mandatory=$true, 14 | ValueFromPipeline=$true, 15 | ValueFromPipelineByPropertyName=$true) 16 | ] 17 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$Vm 18 | ) 19 | 20 | $secureBootSetting = if ($vm.ExtensionData.Config.BootOptions.EfiSecureBootEnabled) { "enabled" } else { "disabled" } 21 | Write-Host "Secure Boot is" $secureBootSetting 22 | } 23 | 24 | Function Set-SecureBoot { 25 | <# 26 | .SYNOPSIS Enable/Disable Seure Boot setting for a VM in vSphere 6.5 27 | .NOTES Author: William Lam 28 | .NOTES Site: www.virtuallyghetto.com 29 | .PARAMETER Vm 30 | VM to enable/disable Secure Boot 31 | .EXAMPLE 32 | Get-VM -Name Windows10 | Set-SecureBoot -Enabled 33 | .EXAMPLE 34 | Get-VM -Name Windows10 | Set-SecureBoot -Disabled 35 | #> 36 | param( 37 | [Parameter( 38 | Mandatory=$true, 39 | ValueFromPipeline=$true, 40 | ValueFromPipelineByPropertyName=$true) 41 | ] 42 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$Vm, 43 | [Switch]$Enabled, 44 | [Switch]$Disabled 45 | ) 46 | 47 | if($Enabled) { 48 | $secureBootSetting = $true 49 | $reconfigMessage = "Enabling Secure Boot for $Vm" 50 | } 51 | if($Disabled) { 52 | $secureBootSetting = $false 53 | $reconfigMessage = "Disabling Secure Boot for $Vm" 54 | } 55 | 56 | $spec = New-Object VMware.Vim.VirtualMachineConfigSpec 57 | $bootOptions = New-Object VMware.Vim.VirtualMachineBootOptions 58 | $bootOptions.EfiSecureBootEnabled = $secureBootSetting 59 | $spec.BootOptions = $bootOptions 60 | 61 | Write-Host "`n$reconfigMessage ..." 62 | $task = $vm.ExtensionData.ReconfigVM_Task($spec) 63 | $task1 = Get-Task -Id ("Task-$($task.value)") 64 | $task1 | Wait-Task | Out-Null 65 | } 66 | -------------------------------------------------------------------------------- /Scripts/Set-ClusterDpm.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | Script name: Set-ClusterDpm.ps1 4 | Created on: 10/10/2019 5 | Author: Doug Taliaferro, @virtually_doug 6 | Description: Configures Distributed Power Management (DPM) on a cluster. 7 | Dependencies: None known 8 | 9 | ===Tested Against Environment==== 10 | vSphere Version: 6.7 11 | PowerCLI Version: 11.3.0 12 | PowerShell Version: 5.1 13 | OS Version: Windows 7, 10 14 | Keyword: Cluster, DPM 15 | .SYNOPSIS 16 | Configures Distributed Power Management (DPM). 17 | 18 | .DESCRIPTION 19 | Enables/disables Distributed Power Management (DPM) for one or more clusters and optionally sets the automation level. 20 | 21 | .PARAMETER Clusters 22 | Specifies the name of the cluster(s) you want to configure. 23 | 24 | .PARAMETER DpmEnabled 25 | Indicates whether Distributed Power Management (DPM) should be enabled/disabled. 26 | 27 | .PARAMETER DpmAutomationLevel 28 | Specifies the Distributed Power Management (DPM) automation level. The valid values are 'automated' and 'manual'. 29 | 30 | .EXAMPLE 31 | Set-ClusterDpm -Cluster 'Cluster01' -DpmEnabled:$true 32 | 33 | .EXAMPLE 34 | Get-Cluster | Set-ClusterDpm -DpmEnabled:$true -DpmAutomationLevel 'automated' 35 | #> 36 | [CmdletBinding()] 37 | param ( 38 | [Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] 39 | [Alias('Name')] 40 | [string[]]$Clusters, 41 | 42 | [Parameter(Mandatory=$true)] 43 | [bool]$DpmEnabled, 44 | 45 | [Parameter(Mandatory = $false)] 46 | [ValidateSet('automated','manual')] 47 | [string]$DpmAutomationLevel 48 | ) 49 | Begin { 50 | # Create a configuration spec 51 | $spec = New-Object VMware.Vim.ClusterConfigSpecEx 52 | $spec.dpmConfig = New-Object VMware.Vim.ClusterDpmConfigInfo 53 | $spec.dpmConfig.enabled = $DpmEnabled 54 | if ($DpmAutomationLevel) { 55 | $spec.dpmConfig.defaultDpmBehavior = $DpmAutomationLevel 56 | } 57 | } 58 | Process { 59 | ForEach ($cluster in $Clusters) { 60 | # Configure the cluster 61 | (Get-Cluster $cluster).ExtensionData.ReconfigureComputeResource_Task($spec, $true) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Scripts/Set-NetworkAdapterOpaqueNetwork.ps1: -------------------------------------------------------------------------------- 1 | function Set-NetworkAdapterOpaqueNetwork { 2 | param( 3 | [Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 1)] 4 | [VMware.VimAutomation.Types.NetworkAdapter] 5 | $NetworkAdapter, 6 | 7 | [Parameter(Mandatory = $true, Position = 2)] 8 | [string] 9 | $OpaqueNetworkName, 10 | 11 | [Parameter()] 12 | [switch] 13 | $Connected, 14 | 15 | [Parameter()] 16 | [switch] 17 | $StartConnected 18 | ) 19 | process { 20 | $opaqueNetwork = Get-View -ViewType OpaqueNetwork | ? {$_.Name -eq $OpaqueNetworkName} 21 | if (-not $opaqueNetwork) { 22 | throw "'$OpaqueNetworkName' network not found." 23 | } 24 | 25 | $opaqueNetworkBacking = New-Object VMware.Vim.VirtualEthernetCardOpaqueNetworkBackingInfo 26 | $opaqueNetworkBacking.OpaqueNetworkId = $opaqueNetwork.Summary.OpaqueNetworkId 27 | $opaqueNetworkBacking.OpaqueNetworkType = $opaqueNetwork.Summary.OpaqueNetworkType 28 | 29 | $device = $NetworkAdapter.ExtensionData 30 | $device.Backing = $opaqueNetworkBacking 31 | 32 | if ($StartConnected) { 33 | $device.Connectable.StartConnected = $true 34 | } 35 | 36 | if ($Connected) { 37 | $device.Connectable.Connected = $true 38 | } 39 | 40 | $spec = New-Object VMware.Vim.VirtualDeviceConfigSpec 41 | $spec.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit 42 | $spec.Device = $device 43 | $configSpec = New-Object VMware.Vim.VirtualMachineConfigSpec 44 | $configSpec.DeviceChange = @($spec) 45 | $NetworkAdapter.Parent.ExtensionData.ReconfigVM($configSpec) 46 | 47 | # Output 48 | Get-NetworkAdapter -Id $NetworkAdapter.Id 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Scripts/SetClusterMultiPathToRoundRobin.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: SetClusterMultiPathToRoundRobin.ps1 3 | Created on: 09/14/2017 4 | Author: Alan Comstock, @Mr_Uptime 5 | Description: Set the MultiPath policy for FC devices to RoundRobin and IOPS to 1 for all hosts in a cluster based upon the vendor tag. 6 | Dependencies: None known 7 | PowerCLI Version: VMware PowerCLI 6.5 Release 1 build 4624819 8 | PowerShell Version: 5.1.14393.1532 9 | OS Version: Windows 10 10 | #> 11 | 12 | $pathpolicy="RoundRobin" 13 | $iops="1" 14 | $vendor="3PARdata" 15 | $AllESXHosts = Get-VMHost -Location CLUSTERNAME | Sort Name 16 | Foreach ($esxhost in $AllESXHosts) { 17 | Write-Host "Working on" $esxhost 18 | $scsilun = Get-VMhost $esxhost | Get-VMHostHba -Type "FibreChannel" | Get-ScsiLun -LunType disk | Where-Object {$_.Vendor -like $vendor -and ($_.MultipathPolicy -notlike $pathpolicy -or $_.CommandsToSwitchPath -ne $iops)} 19 | if ($scsilun -ne $null){ 20 | Set-ScsiLun -ScsiLun $scsilun -MultipathPolicy $pathpolicy -CommandsToSwitchPath $iops 21 | } 22 | } 23 | #The End 24 | -------------------------------------------------------------------------------- /Scripts/SetMultiPathToRoundRobin: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: SetMultiPathToRoundRobin.ps1 3 | Created on: 09/13/2017 4 | Author: Alan Comstock, @Mr_Uptime 5 | Description: Set the MultiPath policy for FC devices to RoundRobin 6 | Dependencies: None known 7 | PowerCLI Version: VMware PowerCLI 6.5 Release 1 build 4624819 8 | PowerShell Version: 5.1.14393.1532 9 | OS Version: Windows 10 10 | #> 11 | 12 | #Check a host for any Fibre Channel devices that are not set to Round Robin. Modify to check clusters if needed. 13 | Get-VMhost HOSTNAME | Get-VMHostHba -Type "FibreChannel" | Get-ScsiLun -LunType disk | Where { $_.MultipathPolicy -notlike "RoundRobin" } | Select CanonicalName,MultipathPolicy 14 | 15 | #Set the Multipathing Policy on a host to Round Robin for any Fibre Channel devices that are not Round Robin 16 | $scsilun = Get-VMhost HOSTNAME | Get-VMHostHba -Type "FibreChannel" | Get-ScsiLun -LunType disk | Where { $_.MultipathPolicy -notlike "RoundRobin" } 17 | Set-ScsiLun -ScsiLun $scsilun -MultipathPolicy RoundRobin 18 | -------------------------------------------------------------------------------- /Scripts/Start-VMHostSsh.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Script name: Start-VMHostSsh.ps1 5 | Created on: 2016-07-01 6 | Author: Peter D. Jorgensen (@pjorg, pjorg.com) 7 | Dependencies: None known 8 | ===Tested Against Environment==== 9 | vSphere Version: 5.5, 6.0 10 | PowerCLI Version: PowerCLI 6.5R1 11 | PowerShell Version: 5.0 12 | OS Version: Windows 10, Windows 7 13 | =========================================================================== 14 | .DESCRIPTION 15 | Starts the TSM-SSH service on VMHosts. 16 | .Example 17 | .\Start-VMHostSsh -VMHost (Get-VMHost -Name 'esxi-001.lab.local') 18 | .Example 19 | $OddHosts = Get-VMHost | ?{ $_.Name -match 'esxi-\d*[13579]+.\lab\.local' } 20 | .\Start-VMHost -VMHost $OddHosts 21 | #> 22 | [CmdletBinding()] 23 | Param( 24 | [Parameter(ValueFromPipeline=$True,Mandatory=$True,Position=0)] 25 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl[]]$VMHost 26 | ) 27 | 28 | Process { 29 | $svcSys = Get-View $VMHost.ExtensionData.ConfigManager.ServiceSystem 30 | $svcSys.StartService('TSM-SSH') 31 | } 32 | -------------------------------------------------------------------------------- /Scripts/Stop-VMHostSsh.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Script name: Stop-VMHostSsh.ps1 5 | Created on: 2016-07-01 6 | Author: Peter D. Jorgensen (@pjorg, pjorg.com) 7 | Dependencies: None known 8 | ===Tested Against Environment==== 9 | vSphere Version: 5.5, 6.0 10 | PowerCLI Version: PowerCLI 6.5R1 11 | PowerShell Version: 5.0 12 | OS Version: Windows 10, Windows 7 13 | =========================================================================== 14 | .DESCRIPTION 15 | Stops the TSM-SSH service on VMHosts. 16 | .Example 17 | .\Stop-VMHostSsh -VMHost (Get-VMHost -Name 'esxi-001.lab.local') 18 | .Example 19 | $EvenHosts = Get-VMHost | ?{ $_.Name -match 'esxi-\d*[02468]+.\lab\.local' } 20 | .\Stop-VMHost -VMHost $EvenHosts 21 | #> 22 | [CmdletBinding()] 23 | Param( 24 | [Parameter(ValueFromPipeline=$True,Mandatory=$True,Position=0)] 25 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl[]]$VMHost 26 | ) 27 | 28 | Process { 29 | $svcSys = Get-View $VMHost.ExtensionData.ConfigManager.ServiceSystem 30 | $svcSys.StopService('TSM-SSH') 31 | } 32 | -------------------------------------------------------------------------------- /Scripts/VMware_Cloud_on_AWS/AWS_Integrations_Examples/Serverless_VM_Deployment/readme.txt: -------------------------------------------------------------------------------- 1 | This is a simple 'serverless application' that allows you to create a VM in 2 | an SDDC on VMware Cloud on AWS using a few cool tools including: Lambda, 3 | Cognito, S3, and VMware Cloud on AWS. 4 | 5 | Matt Dreyer 6 | August 16, 2017 7 | 8 | 9 | To make this work you need to do the following: 10 | 11 | 1. Make sure that the vCenter in your SDDC is publicly accessible, or painfully configure Lambda 12 | to run in an VPC and NAT to a specific IP address (which requires even more IAM roles for VPC access). 13 | 2. Create a working VM, and then Clone it to an OVF template in Content Library 14 | 3. Use the vCenter API browser to discover the UUID of the your OVF template 15 | 4. Update the HTML in index.html to match the UUID(s) of the VMs you wish to deploy 16 | 5. Create a new Lambda function and upload vm-request-form.zip as your code 17 | 6. Create a new Cognito "Federated Identity" for "anonymous access" 18 | 7. Update the javascript in index.html to match your new Cognito role 19 | 8. Create an S3 bucket and configure it for Webhosting 20 | 9. Upload index.html and vmc-sticker.png into your bucket 21 | 10. Muck with IAM until Lambda and Cognito get along together 22 | (required Cognito role permissions are AWSLambdaExecute and AWSLambdaRole) -------------------------------------------------------------------------------- /Scripts/VMware_Cloud_on_AWS/AWS_Integrations_Examples/Serverless_VM_Deployment/vm-request-form.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Scripts/VMware_Cloud_on_AWS/AWS_Integrations_Examples/Serverless_VM_Deployment/vm-request-form.zip -------------------------------------------------------------------------------- /Scripts/VMware_Cloud_on_AWS/AWS_Integrations_Examples/Slack_Inventory/vmc-inventory-to-slack.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/097172029b710036232f3937dd7c04bbb6a760ad/Scripts/VMware_Cloud_on_AWS/AWS_Integrations_Examples/Slack_Inventory/vmc-inventory-to-slack.mp4 -------------------------------------------------------------------------------- /Scripts/VMware_Cloud_on_AWS/Create100VMs.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Created by: Alan Renouf 5 | Date: March 27, 2018 6 | Organization: VMware 7 | Blog: virtu-al.net 8 | Twitter: @alanrenouf 9 | =========================================================================== 10 | 11 | .DESCRIPTION 12 | This will allow you to create multiple workloads in the correct locations on VMware Cloud on AWS. 13 | 14 | .Example 15 | $vCenter = "vcenter.sddc-52-53-75-20.vmc.vmware.com" 16 | $vCenterUser = "cloudadmin@vmc.local" 17 | $vCenterPassword = 'VMware1!' 18 | $ResourcePool = "Compute-ResourcePool" 19 | $Datastore = "WorkloadDatastore" 20 | $DestinationFolder = "Workloads" 21 | $Template = "Gold_Linux_Template" 22 | $VMNamePrefix = "NEWVM" 23 | $NumofVMs = 100 24 | $RunASync = $true #Set this to $True to create the VMs and not wait for the result before starting the next one 25 | #> 26 | 27 | # ------------- VARIABLES SECTION - EDIT THE VARIABLES BELOW ------------- 28 | $vCenter = "vcenter.sddc-123456789.vmc.vmware.com" 29 | $vCenterUser = "cloudadmin@vmc.local" 30 | $vCenterPassword = '123456789' 31 | $ResourcePool = "Compute-ResourcePool" 32 | $Datastore = "WorkloadDatastore" 33 | $DestinationFolder = "Workloads" 34 | $Template = "Gold_Linux_Template" 35 | $VMNamePrefix = "NEWVM" 36 | $NumofVMs = 100 37 | $RunASync = $true 38 | # ------------- END VARIABLES - DO NOT EDIT BELOW THIS LINE ------------- 39 | 40 | # Connect to VMC vCenter Server 41 | $VCConn = Connect-VIServer -Server $vCenter -User $vCenterUser -Password $vCenterPassword 42 | 43 | 1..$NumofVMs | Foreach-Object { 44 | Write-Host "Creating $VMNamePrefix$($_)" 45 | if ($RunASync){ 46 | New-VM -Name "$VMNamePrefix$($_)" -Template $Template -ResourcePool $ResourcePool -Datastore $datastore -Location $DestinationFolder -RunAsync 47 | } Else { 48 | New-VM -Name "$VMNamePrefix$($_)" -Template $Template -ResourcePool $ResourcePool -Datastore $datastore -Location $DestinationFolder 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Scripts/VMware_Cloud_on_AWS/VMC Example Script.ps1: -------------------------------------------------------------------------------- 1 | #List the commands available for the VMC module 2 | Get-VMCCommand 3 | 4 | #Connect to VMC 5 | $MyRefreshToken = "XXXX-XXXX-XXXX-XXXX" 6 | Connect-VMC -RefreshToken $MyRefreshToken 7 | 8 | #List the Orgs available to us 9 | Get-VMCOrg 10 | 11 | #List the SDDCs 12 | Get-VMCSDDC -Org BashFest* 13 | 14 | #List the Tasks for a particular Org 15 | Get-VMCTask -Org BashFest* | Select-Object task_type, Sub_Status, start_time, End_time, user_name | Sort-Object Start_Time | Format-Table 16 | 17 | #Get the Public IPs for a SDDC 18 | Get-VMCSDDCPublicIPPool -org bashfest* 19 | 20 | #Get all ESXi hosts for given SDDC 21 | Get-VMCVMHost -org bashfest* -Sddc virtu-al 22 | 23 | #Get the credentials of a SDDC so we can login via vSphere cmdlets 24 | Get-VMCSDDCDefaultCredential -org bashfest* -Sddc virtu-al 25 | 26 | #Connect to your VMC vCenter with default creds 27 | Connect-VmcVIServer -org bashfest* -Sddc virtu-al 28 | 29 | #Run some vSphere cmdlets 30 | 31 | #List all VMs from On-Premises and VMC SDDC 32 | Get-VM | Select vCenterServer, Name, PowerState, VMHost 33 | 34 | 35 | -------------------------------------------------------------------------------- /Scripts/VMware_Cloud_on_AWS/XRef-VMC-Services.ps1: -------------------------------------------------------------------------------- 1 | $refreshToken = 'your-refresh-token' 2 | 3 | $reportPath = '.\VMC-services.xlsx' 4 | 5 | Connect-Vmc -RefreshToken $refreshToken > $null 6 | 7 | $columns = @{} 8 | $services = Get-VmcService | Sort-Object -Property Name 9 | $services | ForEach-Object -Process { 10 | $_.Help | Get-Member -MemberType NoteProperty | where{'Constants','Documentation' -notcontains $_.Name} | 11 | ForEach-Object -Process { 12 | if(-not $columns.ContainsKey($_.Name)){ 13 | $columns.Add($_.Name,'') 14 | } 15 | } 16 | } 17 | $columns = $columns.Keys | Sort-Object 18 | $report = @() 19 | foreach($service in $services){ 20 | $obj = [ordered]@{ 21 | Name = $service.Name 22 | } 23 | $columns | ForEach-Object -Process { 24 | $obj.Add($_,'') 25 | } 26 | 27 | $service.Help | Get-Member -MemberType NoteProperty | where{'Constants','Documentation' -notcontains $_.Name} | 28 | ForEach-Object -Process { 29 | # $obj.Item($_.Name) = "$($service.Help.$($_.Name).Documentation)" 30 | $obj.Item($_.Name) = "X" 31 | } 32 | $report += New-Object PSObject -Property $obj 33 | } 34 | $report | Export-Excel -Path $reportPath -WorksheetName 'Services' -FreezeTopRow -BoldTopRow -AutoSize -Show 35 | 36 | Disconnect-Vmc -Confirm:$false 37 | 38 | -------------------------------------------------------------------------------- /Scripts/VSANSmartsData.ps1: -------------------------------------------------------------------------------- 1 | Function Get-VSANSmartsData { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: William Lam 6 | Organization: VMware 7 | Blog: www.virtuallyghetto.com 8 | Twitter: @lamw 9 | =========================================================================== 10 | .DESCRIPTION 11 | This function retreives SMART drive data using new vSAN 12 | Management 6.6 API. This can also be used outside of vSAN 13 | to query existing SSD devices not being used for vSAN. 14 | .PARAMETER Cluster 15 | The name of a vSAN Cluster 16 | .EXAMPLE 17 | Get-VSANSmartsData -Cluster VSAN-Cluster 18 | #> 19 | param( 20 | [Parameter(Mandatory=$false)][String]$Cluster 21 | ) 22 | 23 | if($global:DefaultVIServer.ExtensionData.Content.About.ApiType -eq "VirtualCenter") { 24 | if(!$cluster) { 25 | Write-Host "Cluster property is required when connecting to vCenter Server" 26 | break 27 | } 28 | 29 | $vchs = Get-VSANView -Id "VsanVcClusterHealthSystem-vsan-cluster-health-system" 30 | $cluster_view = (Get-Cluster -Name $Cluster).ExtensionData.MoRef 31 | $result = $vchs.VsanQueryVcClusterSmartStatsSummary($cluster_view) 32 | } else { 33 | $vhs = Get-VSANView -Id "HostVsanHealthSystem-ha-vsan-health-system" 34 | $result = $vhs.VsanHostQuerySmartStats($null,$true) 35 | } 36 | 37 | $vmhost = $result.Hostname 38 | $smartsData = $result.SmartStats 39 | 40 | Write-Host "`nESXi Host: $vmhost`n" 41 | foreach ($data in $smartsData) { 42 | if($data.stats) { 43 | $stats = $data.stats 44 | Write-Host $data.disk 45 | 46 | $smartsResults = @() 47 | foreach ($stat in $stats) { 48 | $statResult = [pscustomobject] @{ 49 | Parameter = $stat.Parameter; 50 | Value =$stat.Value; 51 | Threshold = $stat.Threshold; 52 | Worst = $stat.Worst 53 | } 54 | $smartsResults+=$statResult 55 | } 56 | $smartsResults | Format-Table 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Scripts/VSANVersion.ps1: -------------------------------------------------------------------------------- 1 | Function Get-VSANVersion { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: William Lam 6 | Organization: VMware 7 | Blog: www.virtuallyghetto.com 8 | Twitter: @lamw 9 | =========================================================================== 10 | .DESCRIPTION 11 | This function retreives the vSAN software version for both VC/ESXi 12 | .PARAMETER Cluster 13 | The name of a vSAN Cluster 14 | .EXAMPLE 15 | Get-VSANVersion -Cluster VSAN-Cluster 16 | #> 17 | param( 18 | [Parameter(Mandatory=$true)][String]$Cluster 19 | ) 20 | $vchs = Get-VSANView -Id "VsanVcClusterHealthSystem-vsan-cluster-health-system" 21 | $cluster_view = (Get-Cluster -Name $Cluster).ExtensionData.MoRef 22 | $results = $vchs.VsanVcClusterQueryVerifyHealthSystemVersions($cluster_view) 23 | 24 | Write-Host "`nVC Version:"$results.VcVersion 25 | $results.HostResults | Select Hostname, Version 26 | } 27 | -------------------------------------------------------------------------------- /Scripts/backup-esxi-host-configuration.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Script name: backup-esxi-host-configuration.ps1 3 | Created on: 09/10/2018 4 | Author: Gerasimos Alexiou, @jerrak0s 5 | Description: The purpose of the script is to backup esxi host configuration for restore purposes. 6 | Dependencies: None known 7 | 8 | ===Tested Against Environment==== 9 | vSphere Version: 6.5 U2 10 | PowerCLI Version: PowerCLI 10.1.1 11 | PowerShell Version: 5.1 12 | OS Version: Windows 10 13 | Keyword: Backup Configuration ESXi Host 14 | #> 15 | 16 | 17 | $serverIp = Read-Host 'What is the server ip address:' 18 | $path = Read-Host 'Give path where backup configuration will be stored:' 19 | $serverPass = Read-Host 'What is the server root password:' -AsSecureString 20 | Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false 21 | Connect-VIServer serverip -user "root" -password $serverPass 22 | Get-VMHostFirmware -vmhost serverip -BackupConfiguration -DestinationPath $path -------------------------------------------------------------------------------- /Scripts/get-ping.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PingStatus 2 | { 3 | param( 4 | [Parameter(ValueFromPipeline=$true)] 5 | [string]$device, 6 | 7 | [validateSet("Online","Offline","ObjectTable")] 8 | [String]$getObject 9 | ) 10 | 11 | begin{ 12 | $hash = @() 13 | 14 | } 15 | process{ 16 | 17 | $device| foreach { 18 | if (Test-Connection $_ -Count 1 -Quiet) { 19 | 20 | if(-not($GetObject)){write-host -ForegroundColor green "Online: $_ "} 21 | 22 | $Hash = $Hash += @{Online="$_"} 23 | }else{ 24 | 25 | if(-not($GetObject)){write-host -ForegroundColor Red "Offline: $_ "} 26 | 27 | $Hash = $Hash += @{Offline="$_"} 28 | } 29 | } 30 | } 31 | 32 | end { 33 | if($GetObject) { 34 | 35 | $Global:Objects = $Hash | foreach { [PSCustomObject]@{ 36 | 37 | DeviceName = $_.Values| foreach { "$_" } 38 | Online = $_.Keys| where {$_ -eq "Online"} 39 | offline = $_.Keys| where {$_ -eq "Offline"} 40 | } 41 | } 42 | 43 | Switch -Exact ($GetObject) 44 | { 45 | 46 | 'Online' { $Global:Objects| where 'online'| select -ExpandProperty DeviceName } 47 | 'Offline' { $Global:Objects| where 'offline'| select -ExpandProperty DeviceName } 48 | 'ObjectTable' { return $Global:Objects } 49 | } 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Scripts/ha-vcenter-deploy-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "__version": "0.1", 3 | "__comments": "Configuration for ha-vcenter-deploy.ps1 - www.definit.co.uk", 4 | "target": { 5 | "server": "vcsa.definit.local", 6 | "user": "administrator@vsphere.local", 7 | "password": "VMware1!", 8 | "datacenter": "Lab", 9 | "cluster": "Workload", 10 | "datastore": "vsanDatastore", 11 | "folder": "Nested Labs/HA-vCenter", 12 | "portgroup": "HA-vCenter-Management", 13 | "ha-portgroup": "HA-vCenter-Heartbeat", 14 | "network": { 15 | "netmask": "255.255.255.0", 16 | "gateway": "10.0.11.1", 17 | "prefix": "24", 18 | "dns": "192.168.1.20", 19 | "domain": "definit.local", 20 | "ntp": "192.168.1.1" 21 | } 22 | }, 23 | "sources": { 24 | "VCSAInstaller": "e:\\Pod-Deploy\\vSphere\\VMware-VCSA-all-6.5.0-4944578" 25 | }, 26 | "active": { 27 | "deploymentSize": "small", 28 | "name": "ha-vc-active", 29 | "ip": "10.0.11.10", 30 | "ha-ip": "172.16.1.1", 31 | "hostname": "ha-vc.definit.local", 32 | "rootPassword": "VMware1!", 33 | "sso": { 34 | "domain": "vsphere.local", 35 | "site": "Default-First-Site", 36 | "password": "VMware1!" 37 | }, 38 | "datacenter": "HA-vCenter-Datacenter", 39 | "cluster": "HA-vCenter-Cluster-1", 40 | "distributedSwitch": "HA-vCenter-VDS", 41 | "portgroup": "HA-vCenter-PortGroup" 42 | }, 43 | "cluster": { 44 | "passive-ip": "172.16.1.2", 45 | "passive-name": "ha-vc-passive", 46 | "witness-ip": "172.16.1.3", 47 | "witness-name": "ha-vc-witness", 48 | "ha-mask": "255.255.255.248" 49 | }, 50 | "general": { 51 | "syslog": "192.168.1.26", 52 | "ssh": true, 53 | "log": "ha-vcenter-deploy.log" 54 | }, 55 | "license": { 56 | "vcenter": "7H23H-11111-22222-33333-90ZQN" 57 | } 58 | } -------------------------------------------------------------------------------- /Scripts/modules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for file in $( ls /powershell/PowerCLI-Example-Scripts/Modules/ ) 3 | do 4 | mkdir "/root/.local/share/powershell/Modules/${file%.*}/" 5 | mv "/powershell/PowerCLI-Example-Scripts/Modules/$file" "/root/.local/share/powershell/Modules/${file%.*}/$file" 6 | done 7 | -------------------------------------------------------------------------------- /Scripts/vCenterSnapshot.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | Script name: vCenterSnapshot.ps1 4 | Created on: 20/09/2017 5 | Author: Lukas Winn, @lukaswinn 6 | Dependencies: Password is set to VMware123 in my test environment but this can be changed. 7 | 8 | .DESCRIPTION 9 | Script to retrieve snapshot information for all VM's in a given vCenter 10 | 11 | #> 12 | Write-Host "`nGet VM Snapshot Information!" 13 | Write-Host "Copyright 2017 Lukas Winn / @lukaswinn" 14 | Write-Host "Version 1.0" "`n" 15 | 16 | $vCenter = Read-Host -prompt 'Enter FQDN / IP address of vCenter' 17 | 18 | if ($vCenter) { 19 | $vcUser = Read-Host -prompt 'Username' 20 | 21 | Write-Host 'vCenter:' $vCenter '' 22 | 23 | # Connect to vCenter with $vCenter variable value 24 | Connect-VIServer -Server $vCenter -User $vcUser -Password VMware123 25 | 26 | Write-Host "`nConnected to vCenter: " $vCenter 27 | Write-Host 'Retrieving snapshot information...' 28 | Write-Progress -Activity 'Working...' 29 | 30 | # Get VM snapshot information and output in table format 31 | $getSnap = Get-VM | Get-Snapshot | sort SizeGB -descending | Select VM, Name, Created, @{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}}, Id 32 | $getSnap | Format-Table | Out-Default 33 | 34 | # Close connection to active vCenter 35 | Disconnect-VIServer $vCenter -Confirm:$false 36 | Write-Host 'Connection closed to' $vCenter 37 | } 38 | else { 39 | Write-Warning "Error: No data entered for vCenter!" 40 | } 41 | -------------------------------------------------------------------------------- /Scripts/vSphereLogins.ps1: -------------------------------------------------------------------------------- 1 | Function Get-vSphereLogins { 2 | <# 3 | .SYNOPSIS Retrieve information for all currently logged in vSphere Sessions (excluding current session) 4 | .NOTES Author: William Lam 5 | .NOTES Site: www.virtuallyghetto.com 6 | .REFERENCE Blog: http://www.virtuallyghetto.com/2016/11/an-update-on-how-to-retrieve-useful-information-from-a-vsphere-login.html 7 | .EXAMPLE 8 | Get-vSphereLogins 9 | #> 10 | if($DefaultVIServers -eq $null) { 11 | Write-Host "Error: Please connect to your vSphere environment" 12 | exit 13 | } 14 | 15 | # Using the first connection 16 | $VCConnection = $DefaultVIServers[0] 17 | 18 | $sessionManager = Get-View ($VCConnection.ExtensionData.Content.SessionManager) 19 | 20 | # Store current session key 21 | $currentSessionKey = $sessionManager.CurrentSession.Key 22 | 23 | foreach ($session in $sessionManager.SessionList) { 24 | # Ignore vpxd-extension logins as well as the current session 25 | if($session.UserName -notmatch "vpxd-extension" -and $session.key -ne $currentSessionKey) { 26 | $session | Select Username, IpAddress, UserAgent, @{"Name"="APICount";Expression={$Session.CallCount}}, LoginTime 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Scripts/vlcm-sample-cmdlets/vLCM-cmdlets.ps1: -------------------------------------------------------------------------------- 1 | 2 | #Get vLCM Image Profile 3 | #.....List all types of vLCM images 4 | Get-LcmImage 5 | 6 | #.....List Only baseImage (ESXi) vLCM images 7 | Get-LCMImage -Type 'BaseImage' 8 | 9 | #.....List Only VendorAddOn vLCM images 10 | Get-LCMImage -Type 'VendorAddOn' 11 | 12 | #.....List Only Component vLCM images 13 | Get-LCMImage -Type 'Component' 14 | 15 | #.....List Only Package(Firmware) vLCM images 16 | Get-LCMImage -Type 'Package' 17 | 18 | #.....List Only Package vLCM images 19 | Get-LCMImage -Type 'BaseImage', 'VendorAddOn' 20 | 21 | #.....List vLCM Image based on a version 22 | 23 | #Create a new Cluster with vLCM Desired Image and 24 | $clusterName= Read-Host -Prompt 'Provide the cluster Name' 25 | $vLCMBaseImage = Get-LCMImage -Version '7.0 GA - 15843807' 26 | New-Cluster -Location Datacenter -Name $clusterName -BaseImage $vLCMBaseImage -HAEnabled -DrsEnabled 27 | 28 | 29 | #Get Cluster vlcm desired Image 30 | #.....Cluster with a vLCM desired Image 31 | Get-Cluster -Name $clusterName |Select-Object -Property Name, Image, @{n='BaseImageVersion'; e={$_.BaseImage.Version}}, Componenets, VendorAddon 32 | 33 | #Update Cluster vLCM desired Image 34 | #.....Change the Cluster Base Image to ESXi 7.0 U2 35 | $vLCMBaseImageu2= Get-LcmImage -Version '7.0 U2a - 17867351' 36 | Get-Cluster -Name $clusterName|Set-Cluster -BaseImage $vLCMBaseImageu2 37 | 38 | #Check the Cluster Compliance 39 | #.....Check the Cluster Compliance 40 | Get-Cluster -Name $clusterName|Test-LcmClusterCompliance 41 | 42 | #Remediate vLCM Cluster 43 | #.....Remediating vLCM 44 | Get-Cluster -Name $clusterName|Set-Cluster -Remediate -AcceptEULA 45 | 46 | #Export vLCM Desired Image 47 | Get-Cluster -Name $clusterName|Export-LcmClusterDesiredState -Destination 'F:\Image' -ExportOfflineBundle -ExportIsoImage 48 | 49 | #Import vLCM Desired Image 50 | #Cluster as a parameter 51 | Import-LcmClusterDesiredState -Cluster 'Jatin' -LocalSpecLocation F:\Image\TAM-APJ-desired-state-spec.json -Verbose 52 | #get-cluster and Import vLCM desired image 53 | Get-Cluster -Name 'Jatin1' |Import-LcmClusterDesiredState -LocalSpecLocation F:\Image\TAM-APJ-desired-state-spec.json 54 | 55 | #Create a new Cluster and Import LCM desired image 56 | New-Cluster -Name 'Lab-test' -Location Datacenter |Import-LcmClusterDesiredState -LocalSpecLocation F:\Image\TAM-APJ-desired-state-spec.json 57 | -------------------------------------------------------------------------------- /resources/vmw-ico-powercli-vmc-rgb_16px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/vmw-ico-powercli-vmc-rgb_400px.svg: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------