View 5.0: View PowerCLI
Everytime seems working. For those who ain't aware, my ISP issue dynamic IP. In such, I created a domain name from dyndns.org.
As to match my external IP to my View Security Server with my external dns name, I would need to use a script which was found from the source below.
I did some modification to suit my environment and corrected some mistake. Below is my script.
Now my script is running fine again and my log file is updated correctly.
& 'C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1'
# Name of the Security Server
$SecurityServer = "sg-ss"
# For logging creating a timestamp
$TimeStamp = Get-Date -format yyyy-MM-dd-H-mm
# Filling $CheckedIP with the external IP address, using
$wc = New-Object net.WebClient
$CheckedIP = $wc.downloadstring("http://checkip.dyndns.com") -replace "[^\d\.]"
# Now check the current ExternalPCoIPURL entry  is connection server  is securityserver
$CurrentSettings = Get-ConnectionBroker
$CurrentIP = $CurrentSettings.externalPCoIPURL
# Check if $CurrentIP starts with the IP address from $CheckedIP
# Used StartsWith because $CurrentIP has port address at the end
$Result = $CurrentIP.StartsWith($CheckedIP)
# Are IP address the same?
# Yes, both IP addresses are the same, do nothing, only write a log entry
$row = $TimeStamp + "," + $CheckedIP + "," + $CurrentIP + ",nochange"
# External IP is not equal to IP set in externalPCoIPURL
# Changing the externalPCoIPURL
Update-ConnectionBroker -broker_id $SecurityServer -externalPCoIPURL $CheckedIP
# Check if it was succesful
$NewSettings = Get-ConnectionBroker
$row = $TimeStamp + "," + $CheckedIP + "," + $CurrentIP + "," + $NewSettings.externalPCoIPURL + ",changed"
$row | Out-File -FilePath "c:\check-ip.log" -Append