M4RtY

Untitled

Nov 10th, 2022
1,464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Write-Host -ForegroundColor "Yellow" -Object "`n`r - Checking if $STSPool IIS pool exists ..."
  2.     if($null -eq (Get-IISAppPool $STSPool -WarningAction SilentlyContinue)) {
  3.         New-WebAppPool -Name $STSPool | Out-Null
  4.         Write-Host -ForegroundColor "Green" -Object " - Created new application pool: $STSPool."
  5.  
  6.         Set-ItemProperty "IIS:\AppPools\$STSPool" -Name "processModel.loadUserProfile" -Value "True"
  7.  
  8.         Write-Host -ForegroundColor "Yellow" -Object "`n`r - Checking if application $STSAppName exists ..."
  9.        
  10.         if($null -eq (Get-WebApplication -Name $STSAppName)){
  11.             New-WebApplication -Name "$STSAppName" -Site $iisWebsite -PhysicalPath $STSFolder -ApplicationPool $STSPool | Out-Null
  12.             Write-Host -ForegroundColor "Green" -Object " - Created new web application: $STSAppName."
  13.         } else {
  14.             Write-Host -ForegroundColor "Green" -Object " - Web application: $STSAppName already exists."
  15.         }
  16.  
  17.         Write-Host -ForegroundColor "Yellow" -Object "`n`r - Modifying `"$STSFolder\web.config`"...`n`r"
  18.         (Get-Content -Path "$STSFolder\web.config" -Encoding "UTF8") | Foreach-Object {
  19.             $_ -replace 'connectionString="Application Name=\?\?\?;', "connectionString=`"Application Name=NBNSts;" `
  20.            -replace ' Data source=\?\?\?;', " Data source=$SQLInstance;" `
  21.            -replace 'Initial Catalog=\?\?\?;', "Initial Catalog=$DBName;" `
  22.            -replace 'User Id=\?\?\?; ', "User Id=$DBUser; " `
  23.            -replace 'Password=\?\?\?; ', "Password=$DBPassword; " `
  24.            -replace '<HostApplicationUrl url="\?\?\?"></HostApplicationUrl>',"<HostApplicationUrl url=`"https://$VPPUrl/$HostAppname/`"></HostApplicationUrl>" `
  25.            -replace '<add key="IssuerName" value="\?\?\?" />',"<add key=`"IssuerName`" value=`"PassiveSigningSTS`" />" `
  26.            -replace '<add key="SigningCertificateName" value="\?\?\?" />', "<add key=`"SigningCertificateName`" value=`"$($cert.Subject)`" />" `
  27.            -replace '<add key="CertificateThumbprint" value="\?\?\?" />', "<add key=`"CertificateThumbprint`" value=`"$($cert.Thumbprint)`" />"
  28.         } | Set-Content -Path "$STSFolder\Web.config" -Encoding "UTF8"
  29.  
  30.         Write-Host -ForegroundColor "Green" -Object " - $STSAppName Web.config file successfully modified."
  31.  
  32.     } else {
  33.         Write-Host -ForegroundColor "Green" -Object " - Application pool: $STSPool already exists."
  34.     }
  35.  
  36.     Write-Host "`n`r"
  37. }
  38.  
  39. $confirmation = Read-Host " Do you want to continue? (y/n)"
  40. switch ($confirmation) `
  41.     {
  42.     'y' {
  43.         install
  44.     }
  45.  
  46.     'n' {
  47.         Write-Host "`n`r"
  48.         break
  49.     }
  50.  
  51.     default {
  52.         Write-Host "`n`r"
  53.         break
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment