@@ -0,0 +1,97 @@
|
||||
{
|
||||
"Type": "AUTOMATED",
|
||||
"Data": {
|
||||
"Name": "LCFarmJson",
|
||||
"DisplayName": "FarmJsonTest",
|
||||
"AccessGroup": "Root",
|
||||
"Description": "created LC Farm from PS via JSON with NVIDIA GRID VGPU",
|
||||
"Enabled": null,
|
||||
"Deleting": false,
|
||||
"Settings": {
|
||||
"DisconnectedSessionTimeoutPolicy": "NEVER",
|
||||
"DisconnectedSessionTimeoutMinutes": 1,
|
||||
"EmptySessionTimeoutPolicy": "AFTER",
|
||||
"EmptySessionTimeoutMinutes": 1,
|
||||
"LogoffAfterTimeout": false
|
||||
},
|
||||
"Desktop": null,
|
||||
"DisplayProtocolSettings": {
|
||||
"DefaultDisplayProtocol": "PCOIP",
|
||||
"AllowDisplayProtocolOverride": false,
|
||||
"EnableHTMLAccess": false,
|
||||
"EnableCollaboration": false,
|
||||
"EnableGRIDvGPUs": true,
|
||||
"VGPUGridProfile": "grid_m10-8a"
|
||||
},
|
||||
"ServerErrorThreshold": null,
|
||||
"MirageConfigurationOverrides": {
|
||||
"OverrideGlobalSetting": false,
|
||||
"Enabled": false,
|
||||
"Url": null
|
||||
}
|
||||
},
|
||||
"AutomatedFarmSpec": {
|
||||
"ProvisioningType": "VIEW_COMPOSER",
|
||||
"VirtualCenter": null,
|
||||
"RdsServerNamingSpec": {
|
||||
"NamingMethod": "PATTERN",
|
||||
"PatternNamingSettings": {
|
||||
"NamingPattern": "LCFarmVMPS",
|
||||
"MaxNumberOfRDSServers": 1
|
||||
}
|
||||
},
|
||||
"VirtualCenterProvisioningSettings": {
|
||||
"EnableProvisioning": true,
|
||||
"StopProvisioningOnError": true,
|
||||
"MinReadyVMsOnVComposerMaintenance": 0,
|
||||
"VirtualCenterProvisioningData": {
|
||||
"ParentVm": "RDSServer",
|
||||
"Snapshot": "RDS_SNAP1",
|
||||
"Datacenter": null,
|
||||
"VmFolder": "Praveen",
|
||||
"HostOrCluster": "CS-1",
|
||||
"ResourcePool": "CS-1"
|
||||
},
|
||||
"VirtualCenterStorageSettings": {
|
||||
"Datastores": [
|
||||
{
|
||||
"Datastore": "Datastore1",
|
||||
"StorageOvercommit": "UNBOUNDED"
|
||||
}
|
||||
],
|
||||
"UseVSan": false,
|
||||
"ViewComposerStorageSettings": {
|
||||
"UseSeparateDatastoresReplicaAndOSDisks": false,
|
||||
"ReplicaDiskDatastore": null,
|
||||
"UseNativeSnapshots": false,
|
||||
"SpaceReclamationSettings": {
|
||||
"ReclaimVmDiskSpace": false,
|
||||
"ReclamationThresholdGB": null,
|
||||
"BlackoutTimes": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"VirtualCenterNetworkingSettings": {
|
||||
"Nics": null
|
||||
}
|
||||
},
|
||||
"VirtualCenterManagedCommonSettings": {
|
||||
"TransparentPageSharingScope": "VM"
|
||||
},
|
||||
"CustomizationSettings": {
|
||||
"CustomizationType": "SYS_PREP",
|
||||
"DomainAdministrator": null,
|
||||
"AdContainer": "CN=Computers",
|
||||
"ReusePreExistingAccounts": false,
|
||||
"SysprepCustomizationSettings": {
|
||||
"CustomizationSpec": "PraveenCust"
|
||||
}
|
||||
},
|
||||
"RdsServerMaxSessionsData": {
|
||||
"MaxSessionsType": "UNLIMITED",
|
||||
"MaxSessions": null
|
||||
}
|
||||
},
|
||||
"ManualFarmSpec": null,
|
||||
"NetBiosName": "adviewdev"
|
||||
}
|
||||
@@ -2243,6 +2243,21 @@ function New-HVFarm {
|
||||
[boolean]
|
||||
$EnableHTMLAccess = $false,
|
||||
|
||||
#farmSpec.data.displayProtocolSettings.EnableCollaboration
|
||||
[Parameter(Mandatory = $false)]
|
||||
[boolean]
|
||||
$EnableCollaboration = $false,
|
||||
|
||||
#farmSpec.data.displayProtocolSettings.EnableGRIDvGPUs
|
||||
[Parameter(Mandatory = $false)]
|
||||
[boolean]
|
||||
$EnableGRIDvGPUs = $false,
|
||||
|
||||
#farmSpec.data.displayProtocolSettings.VGPUGridProfile
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]
|
||||
$VGPUGridProfile,
|
||||
|
||||
#farmSpec.data.serverErrorThreshold
|
||||
[Parameter(Mandatory = $false)]
|
||||
[ValidateRange(0,[Int]::MaxValue)]
|
||||
@@ -2659,6 +2674,12 @@ function New-HVFarm {
|
||||
$defaultDisplayProtocol = $jsonObject.Data.DisplayProtocolSettings.DefaultDisplayProtocol
|
||||
$allowDisplayProtocolOverride = $jsonObject.Data.DisplayProtocolSettings.AllowDisplayProtocolOverride
|
||||
$enableHTMLAccess = $jsonObject.Data.DisplayProtocolSettings.EnableHTMLAccess
|
||||
$EnableCollaboration = $jsonObject.Data.DisplayProtocolSettings.EnableCollaboration
|
||||
|
||||
if ($null -ne $jsonObject.Data.DisplayProtocolSettings.VGPUGridProfile) {
|
||||
$EnableGRIDvGPUs = $jsonObject.Data.DisplayProtocolSettings.EnableGRIDvGPUs
|
||||
$VGPUGridProfile = $jsonObject.Data.DisplayProtocolSettings.VGPUGridProfile
|
||||
}
|
||||
}
|
||||
if ($null -ne $jsonObject.Data.serverErrorThreshold) {
|
||||
$serverErrorThreshold = $jsonObject.Data.serverErrorThreshold
|
||||
@@ -2802,6 +2823,11 @@ function New-HVFarm {
|
||||
$farmData.DisplayProtocolSettings.DefaultDisplayProtocol = $defaultDisplayProtocol
|
||||
$farmData.DisplayProtocolSettings.AllowDisplayProtocolOverride = $AllowDisplayProtocolOverride
|
||||
$farmData.DisplayProtocolSettings.EnableHTMLAccess = $enableHTMLAccess
|
||||
$farmData.DisplayProtocolSettings.EnableCollaboration = $EnableCollaboration
|
||||
if($VGPUGridProfile -ne $false){
|
||||
$farmData.DisplayProtocolSettings.EnableGRIDvGPUs = $EnableGRIDvGPUs
|
||||
$farmData.DisplayProtocolSettings.VGPUGridProfile = $VGPUGridProfile
|
||||
}
|
||||
}
|
||||
if ($farmData.MirageConfigurationOverrides){
|
||||
$farmData.MirageConfigurationOverrides.OverrideGlobalSetting = $overrideGlobalSetting
|
||||
|
||||
@@ -33,7 +33,7 @@ Function Connect-VMCVIServer {
|
||||
Organization: VMware
|
||||
Blog: http://vmware.com/go/powercli
|
||||
Twitter: @powercli
|
||||
===========================================================================
|
||||
===========================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
Cmdlet to connect to your VMC vCenter Server
|
||||
@@ -47,17 +47,25 @@ Function Connect-VMCVIServer {
|
||||
Param (
|
||||
[Parameter(Mandatory=$true)]$Org,
|
||||
[Parameter(Mandatory=$true)]$Sddc,
|
||||
[switch]$Autologin
|
||||
[switch]$Autologin,
|
||||
[switch]$UseManagementIP
|
||||
)
|
||||
|
||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
||||
$creds = Get-VMCSDDCDefaultCredential -Org $Org -Sddc $Sddc
|
||||
Write-Host "Connecting to VMC vCenter Server" $creds.vc_public_ip
|
||||
Connect-VIServer -Server $creds.vc_public_ip -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
|
||||
Write-Host "Connecting to VMC CIS Endpoint" $creds.vc_public_ip
|
||||
Connect-CisServer -Server $creds.vc_public_ip -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
|
||||
If($UseManagementIP){
|
||||
$Server = $creds.vc_management_ip
|
||||
}Else{
|
||||
$Server = $creds.vc_public_ip
|
||||
}
|
||||
|
||||
Write-Host "Connecting to VMC vCenter Server" $Server
|
||||
Connect-VIServer -Server $Server -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
|
||||
Write-Host "Connecting to VMC CIS Endpoint" $Server
|
||||
Connect-CisServer -Server $Server -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
|
||||
}
|
||||
}
|
||||
|
||||
Function Get-VMCOrg {
|
||||
<#
|
||||
.NOTES
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
# Added PowerShell-Core compatibility
|
||||
#
|
||||
# 1) PS prompt
|
||||
# - detect pwsh-core
|
||||
# - current (local) time
|
||||
# - execution time of the previous command
|
||||
# - shortened PWD
|
||||
@@ -21,10 +20,6 @@
|
||||
|
||||
function prompt
|
||||
{
|
||||
# Detect PS-Core
|
||||
If ($PSVersionTable.PSEdition -eq 'Core') {
|
||||
Write-Host '(Core) ' -NoNewLine
|
||||
}
|
||||
# Current time
|
||||
$date = (Get-Date).ToString('HH:mm:ss')
|
||||
Write-Host -Object '[' -NoNewLine
|
||||
@@ -60,7 +55,7 @@ function prompt
|
||||
function Set-Title
|
||||
{
|
||||
# Running as Administrator or a regular user
|
||||
If (($PSVersionTable.PSEdition -eq 'Core') -and ($IsWindows -eq 'True') -or ($PSVersionTable.PSEdition -ine 'Core'))
|
||||
If (($PSEdition -eq 'Core') -and ($IsWindows -eq 'True') -or ($PSEdition -ine 'Core'))
|
||||
{
|
||||
$userInfo = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
if ((New-Object Security.Principal.WindowsPrincipal $userInfo).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))
|
||||
@@ -74,7 +69,7 @@ function Set-Title
|
||||
}
|
||||
|
||||
# Usertype user@hostname
|
||||
If (($PSVersionTable.PSEdition -eq 'Core') -and ($IsWindows -ine 'True')) {
|
||||
If (($PSEdition -eq 'Core') -and ($IsWindows -ine 'True')) {
|
||||
$env:computername = hostname
|
||||
$user = "$($env:user)@$($env:computername)"
|
||||
}
|
||||
|
||||
@@ -5,15 +5,23 @@ function Export-Tag {
|
||||
[VMware.VimAutomation.ViCore.Types.V1.VIServer]$Server,
|
||||
|
||||
[Parameter(Mandatory = $True, Position = 2)]
|
||||
[string]$Destination
|
||||
[string]$Destination,
|
||||
|
||||
[Parameter(Mandatory = $False, Position = 3)]
|
||||
[boolean]$ExportAssignments
|
||||
)
|
||||
|
||||
# Retrieve all categories
|
||||
$categoryList = Get-TagCategory -Server $server
|
||||
# Retrieve all tags
|
||||
$tagList = Get-Tag -Server $server
|
||||
# Store the tags and categories in a list to export them at once
|
||||
$export = @($categoryList, $tagList)
|
||||
# Store the tags, categories and assignments (if selected) in a list to export them at once
|
||||
If ($ExportAssignments) {
|
||||
$tagAssignments = Get-TagAssignment -Server $server
|
||||
$export = @($categoryList, $tagList, $tagAssignments)
|
||||
} else {
|
||||
$export = @($categoryList, $tagList)
|
||||
}
|
||||
# Export the tags and categories to the specified destination
|
||||
Export-Clixml -InputObject $export -Path $destination
|
||||
}
|
||||
@@ -25,7 +33,10 @@ function Import-Tag {
|
||||
[VMware.VimAutomation.ViCore.Types.V1.VIServer]$Server,
|
||||
|
||||
[Parameter(Mandatory = $True, Position = 2)]
|
||||
[string]$Source
|
||||
[string]$Source,
|
||||
|
||||
[Parameter(Mandatory = $False, Position = 3)]
|
||||
[boolean]$ImportAssignments
|
||||
)
|
||||
|
||||
# Import the tags and categories from the specified source
|
||||
@@ -62,4 +73,23 @@ function Import-Tag {
|
||||
-Server $server `
|
||||
| Out-Null
|
||||
}
|
||||
|
||||
# Restore the assignments if selected
|
||||
If ($ImportAssignments) {
|
||||
# Check for assignments in the file
|
||||
If ($import[2]) {
|
||||
# If tags were found, assign them
|
||||
$tagAssignments = $import[2]
|
||||
ForEach ($assignment in $tagAssignments) {
|
||||
New-TagAssignment `
|
||||
-Tag (Get-Tag -Server $server -Name $assignment.Tag.Name -Category $assignment.Tag.Category) `
|
||||
-Entity (Get-VIObjectByVIView -MORef $assignment.Entity.id) `
|
||||
-Server $server `
|
||||
| Out-Null
|
||||
}
|
||||
} else {
|
||||
# If no assignments were found, output warning
|
||||
Write-Warning "Source file does not contain tag assignments."
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user