DSCResources/MSFT_xEnableTAV1/MSFT_xEnableTAV1.schema.psm1

Configuration MSFT_xEnableTAV1
{
    param
    (
            [string]$UserName,
            [string]$Password,
            [string]$NodeName="localhost",
            [boolean]$PSDscAllowPlainTextPassword=$true,
            
            #PreInstall
            [string]$PreInstallSetupPath="$applicationPath\PreInstall\Preinstall.cmd",

            # TA Install
            [string]$TASetupPath="$applicationPath\TASetup\vstf_testagent.exe",
            [string]$TAProductName="Test Agent 2014",
            [string]$TAArguments="/quiet",
            [string]$TAProductVersion="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,
            [string]$TestAgentVersion = "14.0",

            #Local path used for dropping the build
            [string]$applicationPath = "${env:SystemDrive}\Windows\DtlDownloads",

            #Azure build copy
            [string]$BuildLocation,
            [string]$SASToken,
            [string]$Destination="$applicationPath",

            #LocalFileCopy
            [string]$TestBinariesSourcePath = "$applicationPath\DTATests\*",
            [string]$TestBinariesDestinationPath = "${env:SystemDrive}\Tests",
            [string]$DesktopLocation = "${env:SystemDrive}\users\$UserName\desktop\",
            [string]$BatFileSourceLocation = "$applicationPath\TASetup\Disconnect.bat"

            
    )

    Import-DscResource -ModuleName xAzureFile -Name xAzureFile
    Import-DscResource -ModuleName xVisualStudio1 -Name MSFT_xVisualStudio
    Import-DscResource -ModuleName xVisualStudio1 -Name MSFT_xTestAgent
    Import-DscResource -ModuleName xVisualStudio1 -Name MSFT_xPreInstall
    Import-DscResource -ModuleName xTeamTest -Name MSFT_xTestAgentConfig



    # Create the Local Directory If Not Present
    File Create-LocalDirectory
    {
         Ensure = "Present"
         Type = "Directory"
         DestinationPath = $Destination
    }

    # Copy the builds to the local machine from Azure
    xAzureFile Azure-CopyBuilds
    {
         Name="LocalBuild"
         Source=$BuildLocation
         Destination=$Destination
         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 = $TAProductVersion
         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
   }
 }