Suppresstext info

Suppress text info, when no result found with given search parameters.
This commit is contained in:
praveenmathamsetty
2017-02-21 00:22:19 +05:30
parent c5d19509c9
commit 373579a291

View File

@@ -423,7 +423,7 @@ function Add-HVRDSServer {
process { process {
$confirmFlag = Get-HVConfirmFlag -keys $PsBoundParameters.Keys $confirmFlag = Get-HVConfirmFlag -keys $PsBoundParameters.Keys
try { try {
$farmSpecObj = Get-HVFarmSummary -farmName $farmName -hvServer $hvServer $farmSpecObj = Get-HVFarmSummary -farmName $farmName -hvServer $hvServer -suppressInfo $true
} catch { } catch {
Write-Error "Make sure Get-HVFarmSummary advanced function is loaded, $_" Write-Error "Make sure Get-HVFarmSummary advanced function is loaded, $_"
break break
@@ -924,8 +924,8 @@ function Get-HVFarm {
.PARAMETER Enabled .PARAMETER Enabled
search for farms which are enabled search for farms which are enabled
.PARAMETER Full .PARAMETER SuppressInfo
Switch to get list of FarmSummaryView or FarmInfo objects in the result. If it is true a list of FarmInfo objects is returned ohterwise a list of FarmSummaryView objects is returned. Suppress text info, when no farm found with given search parameters
.PARAMETER HvServer .PARAMETER HvServer
Reference to Horizon View Server to query the data from. If the value is not passed or null then first element from global:DefaultHVServers would be considered in-place of hvServer. 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.
@@ -987,6 +987,10 @@ function Get-HVFarm {
[boolean] [boolean]
$Enabled, $Enabled,
[Parameter(Mandatory = $false)]
[boolean]
$SuppressInfo = $false,
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
$HvServer = $null $HvServer = $null
) )
@@ -998,8 +1002,10 @@ function Get-HVFarm {
} }
$farmList = Find-HVFarm -Param $PSBoundParameters $farmList = Find-HVFarm -Param $PSBoundParameters
if (! $farmList) { if (! $farmList) {
Write-Host "Get-HVFarm: No Farm Found with given search parameters" if (! $SuppressInfo) {
break Write-Host "Get-HVFarm: No Farm Found with given search parameters"
}
return $farmList
} }
$farm_service_helper = New-Object VMware.Hv.FarmService $farm_service_helper = New-Object VMware.Hv.FarmService
$queryResults = @() $queryResults = @()
@@ -1020,18 +1026,21 @@ function Get-HVFarmSummary {
This function queries the specified Connection Server for farms which are configured on the server. If no farm is configured on the specified connection server or no farm matches the given search criteria, it will return null. This function queries the specified Connection Server for farms which are configured on the server. If no farm is configured on the specified connection server or no farm matches the given search criteria, it will return null.
.PARAMETER FarmName .PARAMETER FarmName
farmName to be searched FarmName to be searched
.PARAMETER FarmDisplayName .PARAMETER FarmDisplayName
farmDisplayName to be searched FarmDisplayName to be searched
.PARAMETER FarmType .PARAMETER FarmType
farmType to be searched. It can take following values: FarmType to be searched. It can take following values:
"AUTOMATED" - search for automated farms only "AUTOMATED" - search for automated farms only
'MANUAL' - search for manual farms only 'MANUAL' - search for manual farms only
.PARAMETER Enabled .PARAMETER Enabled
search for farms which are enabled Search for farms which are enabled
.PARAMETER SuppressInfo
Suppress text info, when no farm found with given search parameters
.PARAMETER HvServer .PARAMETER HvServer
Reference to Horizon View Server to query the data from. If the value is not passed or null then first element from global:DefaultHVServers would be considered in-place of hvServer. 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.
@@ -1093,6 +1102,10 @@ function Get-HVFarmSummary {
[boolean] [boolean]
$Enabled, $Enabled,
[Parameter(Mandatory = $false)]
[boolean]
$SuppressInfo = $false,
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
$HvServer = $null $HvServer = $null
) )
@@ -1102,7 +1115,10 @@ function Get-HVFarmSummary {
Write-Error "Could not retrieve ViewApi services from connection object" Write-Error "Could not retrieve ViewApi services from connection object"
break break
} }
Return Find-HVFarm -Param $PSBoundParameters $farmList = Find-HVFarm -Param $PSBoundParameters
if (!$farmList -and !$SuppressInfo) {
Write-Host "Get-HVFarmSummary: No Farm Found with given search parameters"
}
} }
function Find-HVFarm { function Find-HVFarm {
@@ -1213,6 +1229,9 @@ function Get-HVPool {
If the value is true then only pools which are enabled would be returned. If the value is true then only pools which are enabled would be returned.
If the value is false then only pools which are disabled would be returned. If the value is false then only pools which are disabled would be returned.
.PARAMETER SuppressInfo
Suppress text info, when no pool found with given search parameters
.PARAMETER HvServer .PARAMETER HvServer
Reference to Horizon View Server to query the pools from. If the value is not passed or null then Reference to Horizon View Server to query the pools from. If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer first element from global:DefaultHVServers would be considered in-place of hvServer
@@ -1279,6 +1298,10 @@ function Get-HVPool {
[boolean] [boolean]
$ProvisioningEnabled, $ProvisioningEnabled,
[Parameter(Mandatory = $false)]
[boolean]
$SuppressInfo = $false,
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
$HvServer = $null $HvServer = $null
) )
@@ -1290,8 +1313,10 @@ function Get-HVPool {
} }
$poolList = Find-HVPool -Param $PSBoundParameters $poolList = Find-HVPool -Param $PSBoundParameters
if (! $poolList) { if (! $poolList) {
Write-Host "Get-HVPool: No Pool Found with given search parameters" if (! $SuppressInfo) {
break Write-Host "Get-HVPool: No Pool Found with given search parameters"
}
return $poolList
} }
$queryResults = @() $queryResults = @()
$desktop_helper = New-Object VMware.Hv.DesktopService $desktop_helper = New-Object VMware.Hv.DesktopService
@@ -1343,6 +1368,9 @@ function Get-HVPoolSummary {
If the value is true then only pools which are enabled would be returned. If the value is true then only pools which are enabled would be returned.
If the value is false then only pools which are disabled would be returned. If the value is false then only pools which are disabled would be returned.
.PARAMETER SuppressInfo
Suppress text info, when no pool found with given search parameters
.PARAMETER HvServer .PARAMETER HvServer
Reference to Horizon View Server to query the pools from. If the value is not passed or null then Reference to Horizon View Server to query the pools from. If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer first element from global:DefaultHVServers would be considered in-place of hvServer
@@ -1409,6 +1437,10 @@ function Get-HVPoolSummary {
[boolean] [boolean]
$ProvisioningEnabled, $ProvisioningEnabled,
[Parameter(Mandatory = $false)]
[boolean]
$SuppressInfo = $false,
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
$HvServer = $null $HvServer = $null
) )
@@ -1418,7 +1450,11 @@ function Get-HVPoolSummary {
Write-Error "Could not retrieve ViewApi services from connection object" Write-Error "Could not retrieve ViewApi services from connection object"
break break
} }
Return Find-HVPool -Param $psboundparameters $pool_list = Find-HVPool -Param $psboundparameters
if (!$pool_list -and !$suppressInfo) {
Write-Host "Get-HVPoolSummary: No Pool Found with given search parameters"
}
Return $pool_list
} }
function Find-HVPool { function Find-HVPool {
@@ -2343,7 +2379,7 @@ function New-HVFarm {
$confirmFlag = Get-HVConfirmFlag -keys $PsBoundParameters.Keys $confirmFlag = Get-HVConfirmFlag -keys $PsBoundParameters.Keys
if ($farmName) { if ($farmName) {
try { try {
$sourceFarm = Get-HVFarmSummary -farmName $farmName -hvServer $hvServer $sourceFarm = Get-HVFarmSummary -farmName $farmName -hvServer $hvServer -suppressInfo $true
} catch { } catch {
Write-Error "Make sure Get-HVFarmSummary advanced function is loaded, $_" Write-Error "Make sure Get-HVFarmSummary advanced function is loaded, $_"
break break
@@ -4073,7 +4109,7 @@ function New-HVPool {
$confirmFlag = Get-HVConfirmFlag -keys $PsBoundParameters.Keys $confirmFlag = Get-HVConfirmFlag -keys $PsBoundParameters.Keys
if ($poolName) { if ($poolName) {
try { try {
$sourcePool = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer $sourcePool = Get-HVPoolSummary -poolName $poolName -suppressInfo $true -hvServer $hvServer
} catch { } catch {
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_" Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
break break
@@ -5285,7 +5321,7 @@ function Remove-HVFarm {
$farmList = @() $farmList = @()
if ($farmName) { if ($farmName) {
try { try {
$farmSpecObj = Get-HVFarm -farmName $farmName -hvServer $hvServer $farmSpecObj = Get-HVFarm -farmName $farmName -hvServer $hvServer -SuppressInfo $true
} catch { } catch {
Write-Error "Make sure Get-HVFarm advanced function is loaded, $_" Write-Error "Make sure Get-HVFarm advanced function is loaded, $_"
break break
@@ -5408,7 +5444,7 @@ function Remove-HVPool {
$poolList = @() $poolList = @()
if ($poolName) { if ($poolName) {
try { try {
$myPools = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer $myPools = Get-HVPoolSummary -poolName $poolName -suppressInfo $true -hvServer $hvServer
} catch { } catch {
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_" Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
break break
@@ -5589,7 +5625,7 @@ function Set-HVFarm {
$farmList = @{} $farmList = @{}
if ($farmName) { if ($farmName) {
try { try {
$farmSpecObj = Get-HVFarmSummary -farmName $farmName -hvServer $hvServer $farmSpecObj = Get-HVFarmSummary -farmName $farmName -hvServer $hvServer -suppressInfo $true
} catch { } catch {
Write-Error "Make sure Get-HVFarmSummary advanced function is loaded, $_" Write-Error "Make sure Get-HVFarmSummary advanced function is loaded, $_"
break break
@@ -5798,7 +5834,7 @@ function Set-HVPool {
$poolList = @{} $poolList = @{}
if ($poolName) { if ($poolName) {
try { try {
$desktopPools = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer $desktopPools = Get-HVPoolSummary -poolName $poolName -suppressInfo $true -hvServer $hvServer
} catch { } catch {
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_" Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
break break
@@ -5811,6 +5847,9 @@ function Set-HVPool {
} }
$poolList.add($desktopObj.id, $desktopObj.DesktopSummaryData.Name) $poolList.add($desktopObj.id, $desktopObj.DesktopSummaryData.Name)
} }
} else {
Write-Error "No desktopsummarydata found with pool name: [$poolName]"
break
} }
} elseif ($PSCmdlet.MyInvocation.ExpectingInput -or $Pool) { } elseif ($PSCmdlet.MyInvocation.ExpectingInput -or $Pool) {
foreach ($item in $pool) { foreach ($item in $pool) {
@@ -6085,7 +6124,7 @@ function Start-HVFarm {
} }
elseif ($farm.GetType().name -eq 'String') { elseif ($farm.GetType().name -eq 'String') {
try { try {
$farmSpecObj = Get-HVFarm -farmName $farm -hvServer $hvServer $farmSpecObj = Get-HVFarm -farmName $farm -hvServer $hvServer -SuppressInfo $true
} catch { } catch {
Write-Error "Make sure Get-HVFarm advanced function is loaded, $_" Write-Error "Make sure Get-HVFarm advanced function is loaded, $_"
break break
@@ -6458,7 +6497,7 @@ function Start-HVPool {
$type = $item.desktopsummarydata.type $type = $item.desktopsummarydata.type
} elseif ($item.GetType().name -eq 'String') { } elseif ($item.GetType().name -eq 'String') {
try { try {
$poolObj = Get-HVPoolSummary -poolName $item -hvServer $hvServer $poolObj = Get-HVPoolSummary -poolName $item -suppressInfo $true -hvServer $hvServer
} catch { } catch {
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_" Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
break break
@@ -6661,7 +6700,7 @@ function Find-HVMachine {
try { try {
if ($params['PoolName']) { if ($params['PoolName']) {
$poolObj = Get-HVPoolSummary -poolName $params['PoolName'] -hvServer $params['HvServer'] $poolObj = Get-HVPoolSummary -poolName $params['PoolName'] -suppressInfo $true -hvServer $params['HvServer']
if ($poolObj.Length -ne 1) { if ($poolObj.Length -ne 1) {
Write-Host "Failed to retrieve specific pool object with given PoolName : " $params['PoolName'] Write-Host "Failed to retrieve specific pool object with given PoolName : " $params['PoolName']
break; break;
@@ -6891,6 +6930,9 @@ function Get-HVMachineSummary {
If the value is null or not provided then filter will not be applied, If the value is null or not provided then filter will not be applied,
otherwise the virtual machines which has display name same as value will be returned. otherwise the virtual machines which has display name same as value will be returned.
.PARAMETER SuppressInfo
Suppress text info, when no machine found with given search parameters
.PARAMETER HvServer .PARAMETER HvServer
Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer first element from global:DefaultHVServers would be considered in-place of hvServer
@@ -6957,6 +6999,10 @@ function Get-HVMachineSummary {
[string] [string]
$JsonFilePath, $JsonFilePath,
[Parameter(Mandatory = $false)]
[boolean]
$SuppressInfo = $false,
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
$HvServer = $null $HvServer = $null
) )
@@ -6968,6 +7014,9 @@ function Get-HVMachineSummary {
} }
$machineList = Find-HVMachine -Param $PSBoundParameters $machineList = Find-HVMachine -Param $PSBoundParameters
if (!$machineList -and !$SuppressInfo) {
Write-Host "Get-HVMachineSummary: No machine(s) found with given search parameters"
}
return $machineList return $machineList
} }
@@ -7467,7 +7516,7 @@ function New-HVEntitlement {
switch($ResourceType){ switch($ResourceType){
"Desktop" { "Desktop" {
if ($ResourceName) { if ($ResourceName) {
$ResourceObjs = Get-HVPool -PoolName $ResourceName $ResourceObjs = Get-HVPool -PoolName $ResourceName -suppressInfo $true -HvServer $HvServer
if (! $ResourceObjs) { if (! $ResourceObjs) {
Write-Host "No pool found with given resourceName: " $ResourceName Write-Host "No pool found with given resourceName: " $ResourceName
return return
@@ -7704,7 +7753,7 @@ function Get-HVEntitlement {
switch($ResourceType) { switch($ResourceType) {
"Desktop" { "Desktop" {
if ($ResourceName) { if ($ResourceName) {
$ResourceObjs = Get-HVPool -PoolName $ResourceName -HvServer $HvServer $ResourceObjs = Get-HVPool -PoolName $ResourceName -suppressInfo $true -HvServer $HvServer
if (! $ResourceObjs) { if (! $ResourceObjs) {
Write-Host "No pool found with given resourceName: " $ResourceName Write-Host "No pool found with given resourceName: " $ResourceName
return return
@@ -7908,7 +7957,7 @@ function Remove-HVEntitlement {
$info = $services.PodFederation.PodFederation_get() $info = $services.PodFederation.PodFederation_get()
switch($ResourceType) { switch($ResourceType) {
"Desktop" { "Desktop" {
$ResourceObjs = Get-HVPool -PoolName $ResourceName -HvServer $HvServer $ResourceObjs = Get-HVPool -PoolName $ResourceName -suppressInfo $true -HvServer $HvServer
if (! $ResourceObjs) { if (! $ResourceObjs) {
Write-Host "No pool found with given resourceName: " $ResourceName Write-Host "No pool found with given resourceName: " $ResourceName
return return
@@ -8140,7 +8189,7 @@ PARAMETER Key
$machineList = @{} $machineList = @{}
if ($machineName) { if ($machineName) {
try { try {
$machines = Get-HVMachineSummary -MachineName $machineName -hvServer $hvServer $machines = Get-HVMachineSummary -MachineName $machineName -suppressInfo $true -hvServer $hvServer
} catch { } catch {
Write-Error "Make sure Get-HVMachineSummary advanced function is loaded, $_" Write-Error "Make sure Get-HVMachineSummary advanced function is loaded, $_"
break break
@@ -8475,6 +8524,9 @@ function Get-HVGlobalEntitlement {
.PARAMETER Description .PARAMETER Description
Description of Global Entitlement. Description of Global Entitlement.
.PARAMETER SuppressInfo
Suppress text info, when no global entitlement(s) found with given search parameters
.PARAMETER HvServer .PARAMETER HvServer
Reference to Horizon View Server. If the value is not passed or null then Reference to Horizon View Server. If the value is not passed or null then
first element from global:DefaultHVServers would be considered in-place of hvServer first element from global:DefaultHVServers would be considered in-place of hvServer
@@ -8510,6 +8562,10 @@ function Get-HVGlobalEntitlement {
[String] [String]
$Description, $Description,
[Parameter(Mandatory = $false)]
[boolean]
$SuppressInfo = $false,
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
$HvServer = $null $HvServer = $null
) )
@@ -8529,9 +8585,8 @@ function Get-HVGlobalEntitlement {
$result = @() $result = @()
$result += Find-HVGlobalEntitlement -Param $psboundparameters -Type 'GlobalEntitlementSummaryView' $result += Find-HVGlobalEntitlement -Param $psboundparameters -Type 'GlobalEntitlementSummaryView'
$result += Find-HVGlobalEntitlement -Param $psboundparameters -Type 'GlobalApplicationEntitlementInfo' $result += Find-HVGlobalEntitlement -Param $psboundparameters -Type 'GlobalApplicationEntitlementInfo'
if (! $result) { if (!$result -and !$SuppressInfo) {
Write-Host "Get-HVGlobalEntitlement: No global entitlement Found with given search parameters" Write-Host "Get-HVGlobalEntitlement: No global entitlement Found with given search parameters"
break
} }
return $result return $result
} }
@@ -8611,7 +8666,7 @@ function Remove-HVGlobalEntitlement {
$GeList = @() $GeList = @()
if ($DisplayName) { if ($DisplayName) {
try { try {
$GeList = Get-HVGlobalEntitlement -DisplayName $DisplayName -hvServer $hvServer $GeList = Get-HVGlobalEntitlement -DisplayName $DisplayName -suppressInfo $true -hvServer $hvServer
} catch { } catch {
Write-Error "Make sure Get-HVGlobalEntitlement advanced function is loaded, $_" Write-Error "Make sure Get-HVGlobalEntitlement advanced function is loaded, $_"
break break