netcoreapp2.0/VMware.VimAutomation.Sdk.ps1

. (Join-Path $PSScriptRoot 'ParameterCompleter.ps1')

if($PowerCLI_IsDiagnosticSession) {
    [VMware.VimAutomation.Sdk.Interop.V1.CoreServiceFactory]::CoreService.Diagnostics.IsDiagnosticSession = $true
}

$CustomInitScriptName = "Initialize-PowerCLIEnvironment_Custom.ps1"
$currentDir = Split-Path $MyInvocation.MyCommand.Path
$CustomInitScript = Join-Path $currentDir $CustomInitScriptName

#returns the version of Powershell
# Note: When using, make sure to surround Get-PSVersion with parentheses to force value comparison
function Get-PSVersion { 
    if (test-path variable:psversiontable) {
        $psversiontable.psversion
    } else {
        [version]"1.0.0.0"
    } 
}

# Error message to update to version 3.0 of PowerShell
# Note: Make sure to surround Get-PSVersion with parentheses to force value comparison
if((Get-PSVersion) -lt "3.0"){
    $psVersion = Get-PSVersion
    Write-Error "$productShortName requires Powershell 3.0! The version of Powershell installed on this computer is $psVersion." -Category NotInstalled
}

# Opens documentation file
function global:Get-PowerCLIHelp{
   $url = "https://www.vmware.com/support/developer/PowerCLI/"
   $docProcess = [System.Diagnostics.Process]::Start($url)
}

# Opens toolkit community url with default browser
function global:Get-PowerCLICommunity{
    $link = "https://communities.vmware.com/community/vmtn/automationtools/powercli"
    $browserProcess = [System.Diagnostics.Process]::Start($link)
}

# Find and execute custom initialization file
$existsCustomInitScript = Test-Path $CustomInitScript
if($existsCustomInitScript) {
   & $CustomInitScript
}

# Returns the path (with trailing backslash) to the directory where PowerCLI is installed.
function Get-InstallPath {
   throw "Get-InstallPath cmdlet is no longer supported. Please use (get-module <Module_Name>).ModuleBase instead."
}

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol `
    -bor [System.Net.SecurityProtocolType]::Tls12;

# CEIP

if ([VMware.VimAutomation.ViCore.Util10.SettingsManager]::ParticipateInCEIP -eq $null) {
    $message = `
            "Please consider joining the VMware Customer Experience Improvement Program, so you can help " +
            "us make PowerCLI a better product. You can join using the following command:" +
            "`n`nSet-PowerCLIConfiguration -Scope User -ParticipateInCEIP `$true`n`n" + 
            "VMware's Customer Experience Improvement Program (`"CEIP`") provides VMware with information " +
            "that enables VMware to improve its products and services, to fix problems, and to advise you " +
            "on how best to deploy and use our products. As part of the CEIP, VMware collects technical information " +
            "about your organization’s use of VMware products and services on a regular basis in association " +
            "with your organization’s VMware license key(s). This information does not personally identify " +
            "any individual." +
            "`n`nFor more details: type `"help about_ceip`" to see the related help article." +
            "`n`nTo disable this warning and set your preference use the following command and restart PowerShell: " +
            "`nSet-PowerCLIConfiguration -Scope User -ParticipateInCEIP `$true or `$false."

    Write-Warning -Message $message
}

# end CEIP