Skip to content

Commit 50ac249

Browse files
authored
Merge branch 'vmware:master' into master
2 parents 9e4f03a + ce06c53 commit 50ac249

File tree

4 files changed

+176
-2
lines changed

4 files changed

+176
-2
lines changed

Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3925,18 +3925,26 @@ function New-HVPool {
39253925
[boolean]$enableHTMLAccess = $false,
39263926

39273927
# DesktopPCoIPDisplaySettings
3928-
#desktopSpec.desktopSettings.logoffSettings.pcoipDisplaySettings.renderer3D
3928+
#desktopSpec.desktopSettings.DisplayProtocolSettings.pcoipDisplaySettings.renderer3D
39293929
[Parameter(Mandatory = $false,ParameterSetName = 'INSTANT_CLONE')]
39303930
[Parameter(Mandatory = $false,ParameterSetName = "LINKED_CLONE")]
39313931
[Parameter(Mandatory = $false,ParameterSetName = 'MANUAL')]
39323932
[ValidateSet('MANAGE_BY_VSPHERE_CLIENT', 'AUTOMATIC', 'SOFTWARE', 'HARDWARE', 'DISABLED')]
39333933
[string]$renderer3D = 'DISABLED',
39343934

3935-
#desktopSpec.desktopSettings.logoffSettings.pcoipDisplaySettings.enableGRIDvGPUs
3935+
#desktopSpec.desktopSettings.DisplayProtocolSettings.pcoipDisplaySettings.enableGRIDvGPUs
39363936
[Parameter(Mandatory = $false,ParameterSetName = "LINKED_CLONE")]
39373937
[Parameter(Mandatory = $false,ParameterSetName = 'MANUAL')]
3938+
[Parameter(Mandatory = $false,ParameterSetName = 'INSTANT_CLONE')]
39383939
[boolean]$enableGRIDvGPUs = $false,
39393940

3941+
#desktopSpec.desktopSettings.DisplayProtocolSettings.pcoipDisplaySettings.VGPUGridProfile
3942+
[Parameter(Mandatory = $false,ParameterSetName = "LINKED_CLONE")]
3943+
# [Parameter(Mandatory = $false,ParameterSetName = 'MANUAL')]
3944+
[Parameter(Mandatory = $false,ParameterSetName = 'INSTANT_CLONE')]
3945+
[ValidateSet('grid_m10-0b','grid_m10-1b','grid_m10-2b','grid_m10-0q','grid_m10-1q','grid_m10-2q','grid_m10-4q','grid_m10-8q')]
3946+
[string]$VGPUGridProfile = $null,
3947+
39403948
#desktopSpec.desktopSettings.logoffSettings.pcoipDisplaySettings.vRamSizeMB
39413949
[Parameter(Mandatory = $false,ParameterSetName = "LINKED_CLONE")]
39423950
[ValidateRange(64,512)]
@@ -4010,6 +4018,12 @@ function New-HVPool {
40104018
[string]
40114019
$SnapshotVM,
40124020

4021+
#desktopSpec.automatedDesktopSpec.virtualCenterProvisioningSettings.addVirtualTPM if INSTANT_CLONE, ???
4022+
# [Parameter(Mandatory = $true,ParameterSetName = "LINKED_CLONE")]
4023+
[Parameter(Mandatory = $false,ParameterSetName = 'INSTANT_CLONE')]
4024+
[ValidateNotNullOrEmpty()]
4025+
[boolean]$addVirtualTPM = $false,
4026+
40134027
#desktopSpec.automatedDesktopSpec.virtualCenterProvisioningSettings.virtualCenterProvisioningData.vmFolder if LINKED_CLONE, INSTANT_CLONE, FULL_CLONE
40144028
[Parameter(Mandatory = $true,ParameterSetName = "LINKED_CLONE")]
40154029
[Parameter(Mandatory = $true,ParameterSetName = 'INSTANT_CLONE')]
@@ -4515,6 +4529,9 @@ function New-HVPool {
45154529
if ($null -ne $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterProvisioningData.Snapshot) {
45164530
$snapshotVM = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterProvisioningData.Snapshot
45174531
}
4532+
if ($null -ne $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.addVirtualTPM) {
4533+
$addVirtualTPM = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.addVirtualTPM
4534+
}
45184535
$dataCenter = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterProvisioningData.dataCenter
45194536
$vmFolder = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterProvisioningData.VmFolder
45204537
$hostOrCluster = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterProvisioningData.HostOrCluster
@@ -4658,6 +4675,7 @@ function New-HVPool {
46584675
if ($null -ne $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings) {
46594676
$renderer3D = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.renderer3D
46604677
$enableGRIDvGPUs = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.enableGRIDvGPUs
4678+
$VGPUGridProfile = $jsonObject.DesktopSettings.DisplayProtocolSettings.PcoipDisplaySettings.VGPUGridProfile
46614679
if ($jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.vRamSizeMB) {
46624680
$vRamSizeMB = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.vRamSizeMB
46634681
}
@@ -4907,6 +4925,7 @@ function New-HVPool {
49074925
$desktopSpecObj.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterProvisioningData = $desktopVirtualCenterProvisioningData
49084926
$desktopSpecObj.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings = $desktopVirtualCenterStorageSettings
49094927
$desktopSpecObj.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterNetworkingSettings = $DesktopVirtualCenterNetworkingSettings
4928+
$desktopSpecObj.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.AddVirtualTPM = $AddVirtualTPM
49104929
$desktopSpecObj.AutomatedDesktopSpec.CustomizationSettings = $desktopCustomizationSettings
49114930
$desktopSpecObj.AutomatedDesktopSpec.ProvisioningType = $provisioningType
49124931
$desktopSpecObj.AutomatedDesktopSpec.VirtualCenter = $virtualCenterID
@@ -4915,6 +4934,7 @@ function New-HVPool {
49154934
$DesktopVirtualCenterProvisioningSettings.VirtualCenterProvisioningData = $desktopVirtualCenterProvisioningData
49164935
$DesktopVirtualCenterProvisioningSettings.VirtualCenterStorageSettings = $desktopVirtualCenterStorageSettings
49174936
$DesktopVirtualCenterProvisioningSettings.VirtualCenterNetworkingSettings = $DesktopVirtualCenterNetworkingSettings
4937+
$DesktopVirtualCenterProvisioningSettings.AddVirtualTPM = $AddVirtualTPM
49184938

49194939
$DesktopAutomatedDesktopSpec = New-Object VMware.Hv.DesktopAutomatedDesktopSpec
49204940
$DesktopAutomatedDesktopSpec.ProvisioningType = $provisioningType
@@ -4981,6 +5001,16 @@ function New-HVPool {
49815001
$desktopPCoIPDisplaySettings.setRenderer3D($renderer3D)
49825002
#setEnableGRIDvGPUs is not exists, because this property cannot be updated.
49835003
$desktopPCoIPDisplaySettings.getDataObject().EnableGRIDvGPUs = $enableGRIDvGPUs
5004+
if ($enableGRIDvGPUs -eq $true -and $renderer3D -ne 'MANAGE_BY_VSPHERE_CLIENT' -and $InstantClone -eq $true) {
5005+
Write-Error "Enabling GRID support requires that 3D rendering be managed by the vSphere client"
5006+
break
5007+
}
5008+
if ($enableGRIDvGPUs -eq $true -and [string]::IsNullOrEmpty($VGPUGridProfile) -eq $true -and $InstantClone -ne $true) {
5009+
Write-Error "Enabling GRID support for Instant clones, this requires a specified VGPUGridProfile"
5010+
break
5011+
} else {
5012+
$desktopPCoIPDisplaySettings.getDataObject().VGPUGridProfile = $VGPUGridProfile
5013+
}
49845014
$desktopPCoIPDisplaySettings.setVRamSizeMB($vRamSizeMB)
49855015
$desktopPCoIPDisplaySettings.setMaxNumberOfMonitors($maxNumberOfMonitors)
49865016
$desktopPCoIPDisplaySettings.setMaxResolutionOfAnyOneMonitor($maxResolutionOfAnyOneMonitor)
@@ -6569,6 +6599,16 @@ function Start-HVFarm {
65696599
How frequently to repeat maintenance, expressed as a multiple of the maintenance period. e.g. Every 2 weeks.
65706600
This property has a default value of 1. This property has values 1-100.
65716601

6602+
.PARAMETER NumCPU
6603+
Number of CPU of the Vm Instances
6604+
6605+
.PARAMETER Ram
6606+
Ram of the Vm Instances
6607+
Units in MB for Ram parameter
6608+
6609+
.PARAMETER CoresPerSocket
6610+
CoresPerSocket of the Vm Instances
6611+
65726612
.PARAMETER HvServer
65736613
Reference to Horizon View Server to query the data from. If the value is not passed or null then first element from global:DefaultHVServers would be considered in-place of hvServer.
65746614

@@ -6673,6 +6713,21 @@ function Start-HVFarm {
66736713
[ValidateRange(1, 100)]
66746714
[int]$EveryInt = 1,
66756715

6716+
[Parameter(Mandatory = $false)]
6717+
[ValidateRange(1,[Int]::MaxValue)]
6718+
[int]
6719+
$NumCPU = 4,
6720+
6721+
[Parameter(Mandatory = $false)]
6722+
[ValidateRange(1,[Int]::MaxValue)]
6723+
[int]
6724+
$Ram = 16384,
6725+
6726+
[Parameter(Mandatory = $false)]
6727+
[ValidateRange(1,[Int]::MaxValue)]
6728+
[int]
6729+
$CoresPerSocket = 1,
6730+
66766731
[Parameter(Mandatory = $false)]
66776732
$HvServer = $null
66786733
)
@@ -6820,6 +6875,13 @@ function Start-HVFarm {
68206875
break
68216876
}
68226877
}
6878+
6879+
#set ComputeProfile in a SCHEDULEMAINTENANCE
6880+
$spec.ComputeProfile = New-Object VMware.Hv.FarmComputeProfileSpec
6881+
$spec.ComputeProfile.NumCPU = $NumCPU
6882+
$spec.ComputeProfile.Ram = $Ram
6883+
$spec.ComputeProfile.CoresPerSocket = $CoresPerSocket
6884+
68236885
# call scheduleMaintenance service on farm
68246886
if (!$confirmFlag -OR $pscmdlet.ShouldProcess($farmList.$item)) {
68256887
$farm_service_helper.Farm_ScheduleMaintenance($services, $item, $spec)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
<style>
17+
table {
18+
font-size: 12px;
19+
border: 0px;
20+
font-family: Arial, Helvetica, sans-serif;
21+
}
22+
23+
td {
24+
padding: 4px;
25+
margin: 0px;
26+
border: 0;
27+
}
28+
th {
29+
background: #395870;
30+
background: linear-gradient(#49708f, #293f50);
31+
color: #fff;
32+
font-size: 11px;
33+
text-transform: uppercase;
34+
padding: 10px 15px;
35+
vertical-align: middle;
36+
}
37+
tbody tr:nth-child(even) {
38+
background: #f0f0f2;
39+
}
40+
</style>
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 <noreply@vmware.com>" `
47+
-to $email `
48+
-subject "Snapshot Report" `
49+
-body "Cluster snapshot report" `
50+
-Attachment "SnapshotReport.html" `
51+
-smtpServer $smtp
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
}

0 commit comments

Comments
 (0)