"Fossies" - the Fresh Open Source Software Archive

Member "PowerShell-7.2.6/demos/Apache/apache-demo.ps1" (11 Aug 2022, 1238 Bytes) of package /linux/misc/PowerShell-7.2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Microsoft PowerShell source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # Copyright (c) Microsoft Corporation.
    2 # Licensed under the MIT License.
    3 
    4 Import-Module $PSScriptRoot/Apache/Apache.psm1
    5 
    6 #list Apache Modules
    7 Write-Host -Foreground Blue "Get installed Apache Modules like *proxy* and Sort by name"
    8 Get-ApacheModule | Where-Object {$_.ModuleName -like "*proxy*"} | Sort-Object ModuleName | Out-Host
    9 
   10 #Graceful restart of Apache
   11 Write-Host -Foreground Blue "Restart Apache Server gracefully"
   12 Restart-ApacheHTTPServer -Graceful | Out-Host
   13 
   14 #Enumerate current virtual hosts (web sites)
   15 Write-Host -Foreground Blue "Enumerate configured Apache Virtual Hosts"
   16 Get-ApacheVHost |Out-Host
   17 
   18 #Add a new virtual host
   19 Write-Host -Foreground Yellow "Create a new Apache Virtual Host"
   20 New-ApacheVHost -ServerName "mytestserver" -DocumentRoot /var/www/html/mytestserver -VirtualHostIPAddress * -VirtualHostPort 8090 | Out-Host
   21 
   22 #Enumerate new set of virtual hosts
   23 Write-Host -Foreground Blue "Enumerate Apache Virtual Hosts Again"
   24 Get-ApacheVHost |Out-Host
   25 
   26 #Cleanup
   27 Write-Host -Foreground Blue "Remove demo virtual host"
   28 if (Test-Path "/etc/httpd/conf.d"){
   29     & sudo rm "/etc/httpd/conf.d/mytestserver.conf"
   30 }
   31 if (Test-Path "/etc/apache2/sites-enabled"){
   32     & sudo rm "/etc/apache2/sites-enabled/mytestserver.conf"
   33 }