VMware Cloud Community
miguelvelezwhit
Enthusiast
Enthusiast

If we can't use the 'Client' property anymore because it's being deprecated, what are we supposed to use?

I've been deep in configuring alarm definitions today.  I ran my test script, using parts from the masters (i.e. LucD, Jonathan, Brian et al) and some parts I added myself.  As I was running the script, which did what it was supposed to do, I saw this message just after the script logs me onto a vCenter Server:

WARNING: PowerCLI scripts should not use the 'Client' property. The property will be removed in a future release.

I understand the warning but what I don't understand is why no subsitute is ever offered.  The future release removal has been hanging over our heads as far back as February 2016.  You would think that it would be out by now and yet I see that it can't be.  All the Google searches, all the documentation (third party sources), and all the KBs don't seem to be able to give me an answer.  VMware experts are suggesting resolving this now so that you don't have this major headache to deal with when the changes come.  However, in the same breath that they're suggesting that, they're also NOT giving a substitute for the client property.

Can anyone provide some help on this one?   I've already pulled out what little bit of hair that I have and I'm trying to complete a script for my managers.  They won't see the message about the 'Client' property, but I will, and it bugs the frak out of me.

Thanks in advance if you can help me get out of this new rabbit hole, that's in a rabbit hole.   GGGGRRRRRRRRR!!  AAARRRRRGGGGGH!

Reply
0 Kudos
5 Replies
jpsider
Expert
Expert

Can you post the script so there is a bit more context?

Reply
0 Kudos
miguelvelezwhit
Enthusiast
Enthusiast

Here you go....let me know if you have enough to work with or you need more.  Thank you.

Name                           Port  User

----                           ----  ----

VC-BAKE.FLOWERS.FOODS         443 FLOWERS\Miguel.Velez-White

WARNING: PowerCLI scripts should not use the 'Client' property. The property will be removed in a future release.

Uid         : /VIServer=flowers\miguel.velez-white@vc-bake.flowers.foods:443/AdvancedSetting=VIServerSetting-mail.smtp.server/

Value       : mail.flocorp.com

Description : SMTP server

Type        : VIServer

Entity      : VC-BAKE.FLOWERS.FOODS

Id          : VIServerSetting-mail.smtp.server

Name        : mail.smtp.server

Client      : VMware.VimAutomation.ViCore.Impl.V1.VimClient

Uid         : /VIServer=flowers\miguel.velez-white@vc-bake.flowers.foods:443/AdvancedSetting=VIServerSetting-mail.smtp.port/

Value       : 25

Description : SMTP server port

Type        : VIServer

Entity      : VC-BAKE.FLOWERS.FOODS

Id          : VIServerSetting-mail.smtp.port

Name        : mail.smtp.port

Client      : VMware.VimAutomation.ViCore.Impl.V1.VimClient

Uid         : /VIServer=flowers\miguel.velez-white@vc-bake.flowers.foods:443/AdvancedSetting=VIServerSetting-mail.sender/

Value       : VC-BAKE@flowers.foods

Description : Mail sender

Type        : VIServer

Entity      : VC-BAKE.FLOWERS.FOODS

Id          : VIServerSetting-mail.sender

Name        : mail.sender

Client      : VMware.VimAutomation.ViCore.Impl.V1.VimClient

Reply
0 Kudos
jpsider
Expert
Expert

Can you supply the powercli script or snippet you are running?

Reply
0 Kudos
miguelvelezwhit
Enthusiast
Enthusiast

Here's the script - apologies for the delay, I was out of town for a few days...

#Set Variables

$vCenterFQDN = "VC-BAKE.FLOWERS.FOODS"

$SmtpServer = "mail.flocorp.com"

$SmtpPort = "25"

$FromEmail = "VC-BAKE@flowers.foods"

$MaxTaskEventsAge = "180"

$MinutesToRepeat = "60"

$AdminEmail = "seinfadmin@flocorp.com"

#Add the Alarm Definitions to be configured here

$alarms = @(

    "Host connection and power state",

    "Host processor status",

    "Host memory status",

    "Status of other host hardware objects",

    "Host storage status",

    "Host error",

    "Host connection failure",

    "Cannot connect to storage",

    "Network connectivity lost",

    "Network uplink redundancy lost",

    "Network uplink redundancy degraded",

    "Thin-provisioned volume capacity threshold exceeded",

    "vSphere HA failover in progress",

    "vSphere HA virtual machine failover failed",

    "Cannot find vSphere HA master agent",

    "Host Baseboard Management Controller Status",

    "Host Battery Status",

    "Host Hardware Fan Status",

    "Host Hardware Power Status",

    "Host Hardware System Board Status",

    "Host Hardware Temperature Status",

    "Host Hardware Voltage",

    "Insufficient vSphere HA Failover Resources")

Connect-VIServer $vCenterFQDN

#Configure vCenter Mail Settings

Get-AdvancedSetting -Entity $vCenterFQDN -Name mail.smtp.server | Set-AdvancedSetting -Value $SmtpServer -Confirm:$false

Get-AdvancedSetting -Entity $vCenterFQDN -Name mail.smtp.port | Set-AdvancedSetting -Value $SmtpPort -Confirm:$false

Get-AdvancedSetting -Entity $vCenterFQDN -Name mail.sender | Set-AdvancedSetting -Value $FromEmail -Confirm:$false

#Configure vCenter Task and Events Database Retention

Get-AdvancedSetting -Entity $vCenterFQDN -Name task.maxAgeEnabled | Set-AdvancedSetting -Value $true -Confirm:$false

Get-AdvancedSetting -Entity $vCenterFQDN -Name task.maxAge | Set-AdvancedSetting -Value $MaxTaskEventsAge -Confirm:$false

Get-AdvancedSetting -Entity $vCenterFQDN -Name event.maxAgeEnabled | Set-AdvancedSetting -Value $true -Confirm:$false

Get-AdvancedSetting -Entity $vCenterFQDN -Name event.maxAge | Set-AdvancedSetting -Value $MaxTaskEventsAge -Confirm:$false

#Configure the Email Action on the defined list of alarms

foreach ($alarm in $alarms) {

Get-AlarmDefinition -Name $alarm | %{

            #Remove Email Action if already configured

         $_ | Get-AlarmAction -ActionType "SendEmail" | Remove-AlarmAction -Confirm:$false

             #Set the number of Minutes between Repeat Emails for Yellow to Red Triggers

         $_ | Set-AlarmDefinition -ActionRepeatMinutes $MinutesToRepeat;  

             #Create the Send Email Action and set to the admin email                

         $_ | New-AlarmAction -Email -To $AdminEmail | %{

            #Set to Email Once when Trigger from Green to Yellow

            $_ | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow"

            #Remove the Yellow to Red Trigger so we can set it to Repeat

            $_ | Get-AlarmActionTrigger | Where{$_.StartStatus -eq "Yellow" -and $_.EndStatus -eq "Red"}  | Remove-AlarmActionTrigger -Confirm:$false

            #Set to Email Repeat when Trigger from Yellow to Red

            $_ | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Red" -Repeat

            #Set to Email Once when Trigger from Red to Yellow

            $_ | New-AlarmActionTrigger -StartStatus 'Red' -EndStatus 'Yellow'

            #Set to Email Once when Trigger from Yellow to Green

            $_ | New-AlarmActionTrigger -StartStatus 'Yellow' -EndStatus "Green"

         }

      }

    }

    

Disconnect-VIServer

Reply
0 Kudos
LucD
Leadership
Leadership

Most of the data under the Client property is available via ServiceInstance.

An example

$si = Get-View ServiceInstance

$si.Content

$si.Content.About

$sessMgr = Get-View -Id $si.Content.SessionManager

$sessMgr.CurrentSession

Anything specific you are looking for?

And note that this is a warning, you don't even have to be using the $global:defaultviserver.Client object.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos