Improved New-HVPreinstalledApplication
This commit is contained in:
@@ -12043,7 +12043,11 @@ Function Remove-HVApplication {
|
|||||||
PowerCLI Version : PowerCLI 11.1
|
PowerCLI Version : PowerCLI 11.1
|
||||||
PowerShell Version : 5.0
|
PowerShell Version : 5.0
|
||||||
#>
|
#>
|
||||||
param (
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = 'High'
|
||||||
|
)]
|
||||||
|
param (
|
||||||
[Parameter(Mandatory = $True, ValueFromPipeline = $True)]
|
[Parameter(Mandatory = $True, ValueFromPipeline = $True)]
|
||||||
[string]$ApplicationName,
|
[string]$ApplicationName,
|
||||||
|
|
||||||
@@ -12064,9 +12068,11 @@ Function Remove-HVApplication {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
$AppService= New-Object VMware.Hv.ApplicationService
|
$AppService= New-Object VMware.Hv.ApplicationService
|
||||||
$AppService.Application_Delete($services,$App.Id)
|
if ($pscmdlet.ShouldProcess($ApplicationName)) {
|
||||||
if ($?) {
|
$AppService.Application_Delete($services,$App.Id)
|
||||||
Write-Host "'$ApplicationName' has been successfully removed."
|
if ($?) {
|
||||||
|
Write-Host "'$ApplicationName' has been successfully removed."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end {
|
end {
|
||||||
@@ -12343,10 +12349,13 @@ Function New-HVPreInstalledApplication {
|
|||||||
View API service object of Connect-HVServer cmdlet.
|
View API service object of Connect-HVServer cmdlet.
|
||||||
|
|
||||||
.PARAMETER ApplicationName
|
.PARAMETER ApplicationName
|
||||||
The Application name is the unique identifier used to identify this Application.
|
The Application name to search within the Farm for. This should match the output of (Get-HVPreinstalledApplication).Name
|
||||||
|
|
||||||
|
.PARAMETER ApplicationID
|
||||||
|
The unique identifier for this application. The ApplicationID can only contain alphanumeric characters, dashes, and underscores. If ApplicationID is not specified, it will be set to match the ApplicationName, with the spaces converted to underscore (_).
|
||||||
|
|
||||||
.PARAMETER DisplayName
|
.PARAMETER DisplayName
|
||||||
The display name is the name that users will see when they connect to view client. If the display name is left blank, it defaults to Name.
|
The display name is the name that users will see when they connect with the Horizon Client. If the display name is left blank, it defaults to ApplicationName.
|
||||||
|
|
||||||
.PARAMETER FarmName
|
.PARAMETER FarmName
|
||||||
Farm name.
|
Farm name.
|
||||||
@@ -12364,12 +12373,16 @@ Function New-HVPreInstalledApplication {
|
|||||||
Client restrictions to be applied to Application. Currently it is valid for RDSH pools.
|
Client restrictions to be applied to Application. Currently it is valid for RDSH pools.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-HVPreInstalledApplication -ApplicationName 'App1' -DisplayName 'DisplayName' -FarmName 'FarmName'
|
New-HVPreInstalledApplication -ApplicationName 'App1' -DisplayName 'DisplayName' -FarmName 'FarmName'
|
||||||
Creates a application App1 from the farm specified.
|
Creates a application App1 from the farm specified.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-HVPreInstalledApplication -ApplicationName 'App2' -FarmName FarmManual -EnablePreLaunch $True
|
New-HVPreInstalledApplication -ApplicationName 'App2' -FarmName FarmManual -EnablePreLaunch $True
|
||||||
Creates a application App2 from the farm specified and the PreLaunch option will be enabled.
|
Creates a application App2 from the farm specified and the PreLaunch option will be enabled.
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-HVPreInstalledApplication -ApplicationName 'Excel 2016' -ApplicationID 'Excel-2016' -DisplayName 'Excel' -FarmName 'RDS-FARM-01'
|
||||||
|
Creates an application, Excel-2016, from the farm RDS-FARM-01. The application will display as 'Excel' to the end user.
|
||||||
|
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
A success message is displayed when done.
|
A success message is displayed when done.
|
||||||
@@ -12385,12 +12398,12 @@ Function New-HVPreInstalledApplication {
|
|||||||
PowerShell Version : 5.0
|
PowerShell Version : 5.0
|
||||||
#>
|
#>
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $False)]
|
|
||||||
$HvServer = $null,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $True, ValueFromPipeline = $True)]
|
[Parameter(Mandatory = $True, ValueFromPipeline = $True)]
|
||||||
[string][ValidateLength(1,64)]$ApplicationName,
|
[string][ValidateLength(1,64)]$ApplicationName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $False, ValueFromPipeline = $True)]
|
||||||
|
[string][ValidateLength(1,64)][ValidatePattern('(?#Alphanumeric, dashes,and underscores)^[a-zA-Z\d-_]+$')]$ApplicationID = $($ApplicationName -replace " ","_"),
|
||||||
|
|
||||||
[Parameter(Mandatory = $False, ValueFromPipeline = $True)]
|
[Parameter(Mandatory = $False, ValueFromPipeline = $True)]
|
||||||
[String][ValidateLength(1,256)]$DisplayName = $ApplicationName,
|
[String][ValidateLength(1,256)]$DisplayName = $ApplicationName,
|
||||||
|
|
||||||
@@ -12407,7 +12420,10 @@ Function New-HVPreInstalledApplication {
|
|||||||
[String][ValidateRange(1,64)]$CategoryFolderName,
|
[String][ValidateRange(1,64)]$CategoryFolderName,
|
||||||
|
|
||||||
[Parameter(Mandatory = $False, ValueFromPipeline = $True)]
|
[Parameter(Mandatory = $False, ValueFromPipeline = $True)]
|
||||||
[Boolean]$clientRestrictions = $False
|
[Boolean]$clientRestrictions = $False,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $False)]
|
||||||
|
$HvServer = $null
|
||||||
)
|
)
|
||||||
begin {
|
begin {
|
||||||
$services = Get-ViewAPIService -HvServer $HvServer
|
$services = Get-ViewAPIService -HvServer $HvServer
|
||||||
@@ -12424,17 +12440,17 @@ Function New-HVPreInstalledApplication {
|
|||||||
process {
|
process {
|
||||||
#Validate the Application name uniqueness with existing applications.
|
#Validate the Application name uniqueness with existing applications.
|
||||||
$ResourceObjs = Get-HVApplication -HvServer $HvServer
|
$ResourceObjs = Get-HVApplication -HvServer $HvServer
|
||||||
foreach($App in ($ResourceObjs.name)) {
|
foreach($App in ($ResourceObjs.Data.Name)) {
|
||||||
if($App -eq $ApplicationName) {
|
if($App -eq $ApplicationID) {
|
||||||
Write-Host "$ApplicationName already exists in the Application Pool."
|
Write-Error "$ApplicationID already exists in the Application Pool. Use the -ApplicationID parameter to specify a unique ID."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#Validate the application name uniqueness with Desktops.
|
#Validate the application name uniqueness with Desktops.
|
||||||
$DesktopSummary = Get-HVQueryResult -EntityType DesktopSummaryView -HvServer $hvserver
|
$DesktopSummary = Get-HVQueryResult -EntityType DesktopSummaryView -HvServer $hvserver
|
||||||
foreach($App in $DesktopSummary) {
|
foreach($App in $DesktopSummary) {
|
||||||
if($App.DesktopSummaryData.Name -eq $ApplicationName) {
|
if($App.DesktopSummaryData.Data.Name -eq $ApplicationID) {
|
||||||
Write-Host "$ApplicationName already exists in the Desktop Pool."
|
Write-Error "$ApplicationID already exists in the Desktop Pool. Use the -ApplicationID parameter to specify a unique ID."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12444,7 +12460,6 @@ Function New-HVPreInstalledApplication {
|
|||||||
foreach($App in ($AppsInRDS)) {
|
foreach($App in ($AppsInRDS)) {
|
||||||
if($($App.name) -eq ($ApplicationName)) {
|
if($($App.name) -eq ($ApplicationName)) {
|
||||||
$AppFoundInRDS = $True
|
$AppFoundInRDS = $True
|
||||||
$ApplicationID = $ApplicationName -replace " ","_"
|
|
||||||
$ApplicationData = New-Object VMware.Hv.ApplicationData -Property @{ 'Name' = $ApplicationID;
|
$ApplicationData = New-Object VMware.Hv.ApplicationData -Property @{ 'Name' = $ApplicationID;
|
||||||
'DisplayName' = $DisplayName;
|
'DisplayName' = $DisplayName;
|
||||||
'EnablePreLaunch' = $EnablePreLaunch;
|
'EnablePreLaunch' = $EnablePreLaunch;
|
||||||
@@ -12463,15 +12478,15 @@ Function New-HVPreInstalledApplication {
|
|||||||
$AppService = New-Object VMware.Hv.ApplicationService
|
$AppService = New-Object VMware.Hv.ApplicationService
|
||||||
$AppService.Application_Create($services,$ApplicationSpec)
|
$AppService.Application_Create($services,$ApplicationSpec)
|
||||||
if($?) {
|
if($?) {
|
||||||
Write-Host "Application '$ApplicationName' created successfully"
|
Write-Host "Application '$ApplicationId' created successfully"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Write-Host "Failed to create Application '$ApplicationName'. $_ "
|
Write-Host "Failed to create Application '$ApplicationId'. $_ "
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($AppFoundInRDS -eq $False) {
|
if ($AppFoundInRDS -eq $False) {
|
||||||
Write-Host ""$ApplicationName" does not exist in any of the RDS Server(s) belongs to the Farm $FarmName."
|
Write-Error "$ApplicationName does not exist in any of the RDS Server(s) belongs to the Farm $FarmName. Run (Get-HVPreinstalledApplication -FarmName $FarmName).Name to see a list of valid, preinstalled applications."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end {
|
end {
|
||||||
|
|||||||
Reference in New Issue
Block a user