Sample/P1SampleScript.ps1

# -----------------------------------------------------------------------------
# Install PlannerOne Demo (all-in-one script)
# This sample script is provided for demonstration
# You can adapt the following variables to your context
#
# Be sure to get an access key from Ortems before you run this script!
#
# -----------------------------------------------------------------------------
$P1Tenant = "Test"
$Adapter = "NAV"
$NAVInstance = "NAV"
$EnvironmentType = "Production"

# Technical account (must exist in $NAVInstance database)
# Replace this value if the current user is not the technical account
$UserDomain = $env:USERDOMAIN 
$UserLogin = $env:USERNAME
$UserPassword = "<EnterPassword>"

$features = Test-P1Prerequisites

$missingFeatures = ($features | Where-Object InstallState -ne Installed)

if ($missingFeatures.Count -eq 0) {
    # Install PlannerOne packages
    Install-P1Package -Adapter $Adapter
     
    # Create new tenant
    New-P1Tenant $P1Tenant -Adapter $Adapter

    # Configure adapter of tenant
    Set-P1Adapter -Tenant $P1Tenant -InstanceName $NAVInstance -ServiceDomain $UserDomain -ServiceLogin $UserLogin -ServicePassword $UserPassword -AutoPort

    # Get environments of tenant and save thel in a variable
    $envList = Get-P1Environments -Tenant $P1Tenant -Product $EnvironmentType

    # Initialize all environments in list
    Initialize-P1Environments -Tenant $P1Tenant -Environments $envList
    
} else {
    $missingFeatures
}

# -----------------------------------------------------------------------------
# To show prerequisites validation, run Uninstall-WindowsFeature 'NET-WCF-HTTP-Activation45' before running this script
# To show NAV instance validation, set "Services Default Time Zone" to UTC or set "Enable SOAP Services" to false before running this script
# To remove the Demo tenant, run Remove-P1Tenant Demo
# -----------------------------------------------------------------------------