Deployment IIS from TFS

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Nitin Gupta Nitin Gupta 2 months ago.

  • Author
    Posts
  • #54205
    Profile photo of Marcel Czech
    Marcel Czech
    Participant

    Hello together,

    maybe some of you can help me. I m a newbie in powershell, and i have to make a script that deploy sources which droped on a tfs server on a iis webserver. on the end i have to execute a sql file on the specific database, which is also on the server stored. Can you tell me where i have to fill in the right parameters?

    Write-Host "`$env:PSModulePath=$($env:PSModulePath)"
    Write-Host "`$env:ProgramFiles=$($env:ProgramFiles)"
    Write-Host "`$CurrentValue=$CurrentValue"
    Write-Host "`$PSVersionTable.PSVersion=$($PSVersionTable.PSVersion)"
    Get-Module -ListAvailable
    Write-Host "`n`n==== DscResources ====="
    Get-DscResource | Select Name, Properties | ft -AutoSize 
    
    
    
    
    
    configuration Sample_xWebsite_NewWebsite 
    { 
        param 
        ( 
            # Target nodes to apply the configuration 
            [string[]]$NodeName = 'localhost', 
            # Name of the website to create 
            [Parameter(Mandatory)] 
            [ValidateNotNullOrEmpty()] 
            [String]$WebSiteName ='testsite', 
            # Source Path for Website content 
            #[Parameter(Mandatory)] 
            #[ValidateNotNullOrEmpty()] 
            #[String]$SourcePath, 
            # Destination path for Website content 
            [Parameter(Mandatory)] 
            [ValidateNotNullOrEmpty()] 
            [String]$DestinationPath = 'd:\test\testsite\'
        )
          
        # Import the module that defines custom resources 
        Import-DscResource -Module xWebAdministration 
    
        Node $NodeName 
        { 
            # Install the IIS role 
            WindowsFeature IIS 
            { 
                Ensure          = "Present" 
                Name            = "Web-Server" 
            } 
    
            # Install the ASP .NET 4.5 role 
            WindowsFeature AspNet45 
            { 
                Ensure          = "Present" 
                Name            = "Web-Asp-Net45" 
            } 
    
            # Stop the default website 
            xWebsite DefaultSite  
            { 
                Ensure          = "Present" 
                Name            = "Default Web Site" 
                State           = "Stopped" 
                PhysicalPath    = "C:\inetpub\wwwroot" 
                DependsOn       = "[WindowsFeature]IIS" 
            } 
    
            xWebsite NewWebsite 
            { 
                Ensure          = "Present" 
                Name            = $WebSiteName 
                State           = "Started" 
                PhysicalPath    = $DestinationPath 
                BindingInfo     = MSFT_xWebBindingInformation 
                                 { 
                                   Protocol              = "HTTP" 
                                   Port                  = 8080 
                                   #CertificateThumbprint ="71AD93562316F21F74606F1096B85D66289ED60F" 
                                   #CertificateStoreName  = "WebHosting" 
                                 } 
                
            } 
        } 
    } 
    
    Sample_xWebsite_NewWebsite -WebSiteName 'testsite' -DestinationPath 'd:\test\testsite\'
    
    Start-DscConfiguration -Wait -Force -Verbose -Path .\Sample_xWebsite_NewWebsite
    
    
    • This topic was modified 2 months, 2 weeks ago by Profile photo of Marcel Czech Marcel Czech.
  • #54212
    Profile photo of Nitin Gupta
    Nitin Gupta
    Participant

    This sample configuration in itself won't do everything you need for your scenario. You have to find the set of resources that can do simple tasks like creating website and then bind them together like this sample configuration is doing. For starters:
    You can use either *File* (from PSDesiredStateConfiguration Module) or *xRemoteFile* (from xPsDesiredStateConfiguration module) to copy contents from a location to your target Node.
    To deploy a website, you can use *xWebsite* from xWebAdministration module.
    To start a process you can use *xWindowsProcess* from xPsDesiredStateConfiguration module.
    To configuration SQL server you can use resources from xSQLServer module.

    Here are the links to the module and documentation on github:
    xPsDesiredStateConfiguration
    xSQLServer
    xWebAdministration

    There are tons of DSC resources that starts with 'x' (for experimental) and 'c' (for community). You will find most of them on github. The following query DSC Resources can get you started in exploring some of them.

  • #54607
    Profile photo of Marcel Czech
    Marcel Czech
    Participant

    Tanks for you response first !

    I looked at all files from "PSDesiredStateConfiguration" Module to copy first a file with "xRemoteFile". I cannot find or understand how i can do this. I searched on youtube too for this configuration. But i don t find such configurations or tutorials. Can you explain it pls detailed how i can make this first step with this module?

    thanks

  • #54715
    Profile photo of Nitin Gupta
    Nitin Gupta
    Participant

    Most of the modules comes with samples. Sample for xRemoteFile: https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/dev/Examples/Sample_xRemoteFile.ps1

    Take a look into these samples to get an idea on the basic usage of the resource.

You must be logged in to reply to this topic.