Sample/NAV/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"
$NAVInstance = "NAV"

# 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) {
    $ERP = "NAV"
    $Version = "2016"
    # Install PlannerOne packages
    Install-P1Package -ERP $ERP -Version $Version

    # Create new tenant
    New-P1Tenant $P1Tenant -ERP $ERP

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

    # Get environments of tenant and save them in a variable
    $envList += Get-P1Environments -Tenant $P1Tenant -Product "Production" 
    $envList += Get-P1Environments -Tenant $P1Tenant -Product "Project" 

    # 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
# -----------------------------------------------------------------------------