DSCResources/MSFT_xEnableTAV1/MSFT_xEnableTAV1.schema.psm1

Configuration MSFT_xEnableTAV1
{
    param
    (
            [string]$UserName,
            [string]$Password,
            
            #PreInstall
            [string]$PreInstallSetupPath="PreInstall\Preinstall.cmd",

            #Dot Net installation EXE path
            [string]$DotNetInstallerPath = "\TASetup\dotNetFx-x86-x64-AllOS-ENU.exe",

            # TA Install
            [string]$TASetupPath="TASetup\vstf_testagent.exe",
            [string]$TAProductName="Test Agent 2014",
            [string]$TAArguments="/quiet",
            [string]$TestAgentVersion="14.0",

            # TA Configure
            [string]$TfsCollectionUri,
            [string]$TestServiceUserName,
            [string]$TestServicePassword,
            [string]$ControllerUri="localhost",
            [string]$Ensure="Present",
            [string]$AgentUri = "null",
            [uint32]$Port = 6910,
            [string]$AsServiceOrProcess = "Service",
            [boolean]$DisableScreenSaver = $false,
            [boolean]$EnableAutoLogon = $false,

            #Azure build copy
            [string]$BuildLocation,
            [string]$SASToken,
            [string]$LocalBuildPath="${env:SystemDrive}\Windows\DtlDownloads",

            #LocalFileCopy
            [string]$TestBinariesSourcePath = "DTATests",
            [string]$TestBinariesDestinationPath = "${env:SystemDrive}\Tests",
            [string]$DesktopLocation = "${env:SystemDrive}\users\$UserName\desktop\",
            [string]$BatFileSourceLocation = "TASetup\Disconnect.bat"     
    )
    
    $TASetupPath = Join-Path $LocalBuildPath $TASetupPath
    $TestBinariesSourcePath = Join-Path $LocalBuildPath $TestBinariesSourcePath
    $PreInstallSetupPath = Join-Path $LocalBuildPath $PreInstallSetupPath 
    $BatFileSourceLocation = Join-Path $LocalBuildPath $BatFileSourceLocation 
    $DotNetInstallerPath = Join-Path $LocalBuildPath $DotNetInstallerPath 
    

    Import-DscResource -ModuleName xAzureFile
    Import-DscResource -ModuleName xVisualStudio1
    Import-DscResource -ModuleName xTeamTest

    # Delete the existing folder
    File Create-LocalDirectory
    {
         Ensure = "Absent"
         Type = "Directory"
         DestinationPath = $LocalBuildPath
         Force = $True
    }

    # Copy the builds to the local machine from Azure
    xAzureFile Azure-CopyBuilds
    {
         Name="LocalBuild"
         Source=$BuildLocation
         Destination=$LocalBuildPath
         SASToken=$SASToken
         DependsOn="[File]Create-LocalDirectory"
    }
    
    # Copy Test binaries to DTA Folder (temporary)
    File Copy-TestBinaries
    {
          Ensure= $Ensure
          Type="Directory"
          Recurse=$true
          SourcePath = $TestBinariesSourcePath
          DestinationPath = $TestBinariesDestinationPath
          DependsOn = "[xAzureFile]Azure-CopyBuilds"
    }

    # Drop disconnect.cmd to Desktop
    File Copy-DisconectCmd
    {
          Ensure= $Ensure
          Type= "File"
          SourcePath = $BatFileSourceLocation
          DestinationPath = $DesktopLocation
    }
    
    # Install Preinstall
    MSFT_xPreInstall Pre-Install
    {
         Ensure = $Ensure
         Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, (ConvertTo-SecureString -String $Password -AsPlainText -Force)
         SetupPath = $PreInstallSetupPath
    }

    # Install TA
    MSFT_xTestAgent InstallTestAgent
    {
         Ensure = $Ensure    
         SetupPath = $TASetupPath
         Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, (ConvertTo-SecureString -String $Password -AsPlainText -Force)
         ProductVersion = $TestAgentVersion
         ProductName = $TAProductName
         Arguments = $TAArguments
         
    }
    
    # Configure TA
    xTestAgentConfig TAConfigure
    {
          Ensure = $Ensure
          AgentUri = $AgentUri
          TestController = $ControllerUri
          TfsCollection = $TfsCollectionUri
          AsServiceOrProcess = $AsServiceOrProcess
          UserCredential = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, (ConvertTo-SecureString -String $Password -AsPlainText -Force)
          LabServiceCredential = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, (ConvertTo-SecureString -String $Password -AsPlainText -Force)
          TestServiceCredential = New-Object System.Management.Automation.PSCredential -ArgumentList $TestServiceUserName , (ConvertTo-SecureString -String $TestServicePassword -AsPlainText -Force)
          Port = $Port
          DisableScreenSaver = $DisableScreenSaver
          EnableAutoLogon = $EnableAutoLogon
          TestAgentVersion = $TestAgentVersion
   }
 }