Jestem kompletnym nowicjuszem w grze Power Shell. Potrzebuję skryptu powershell, który może zautomatyzować proces instalacji IIS7 lub nowszego. Mam pewne konfiguracje do usług ról. Każda pomoc w tym zakresie jest doceniana.Skrypt powershell do automatycznej instalacji usług IIS 7 i nowszych
Odpowiedz
znalazłem następujące blog użyteczne, z pewnymi zmianami do korzystania z pomocy udało mi się zainstalować IIS z muszli mocy z niestandardowym roli services.I mieć kod tutaj i link do bloga jest:
http://www.ithassle.nl/2010/09/powershell-script-to-install-and-configure-iis7-5/#codesyntax_1
# --------------------------------------------------------------------
# Checking Execution Policy
# --------------------------------------------------------------------
#$Policy = "Unrestricted"
$Policy = "RemoteSigned"
If ((get-ExecutionPolicy) -ne $Policy) {
Write-Host "Script Execution is disabled. Enabling it now"
Set-ExecutionPolicy $Policy -Force
Write-Host "Please Re-Run this script in a new powershell enviroment"
Exit
}
# --------------------------------------------------------------------
# Define the variables.
# --------------------------------------------------------------------
$InetPubRoot = "D:\Inetpub"
$InetPubLog = "D:\Inetpub\Log"
$InetPubWWWRoot = "D:\Inetpub\WWWRoot"
# --------------------------------------------------------------------
# Loading Feature Installation Modules
# --------------------------------------------------------------------
Import-Module ServerManager
# --------------------------------------------------------------------
# Installing IIS
# --------------------------------------------------------------------
Add-WindowsFeature -Name Web-Common-Http,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Http-Logging,Web-Request-Monitor,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Performance,Web-Mgmt-Console,Web-Mgmt-Compat,RSAT-Web-Server,WAS -IncludeAllSubFeature
# --------------------------------------------------------------------
# Loading IIS Modules
# --------------------------------------------------------------------
Import-Module WebAdministration
# --------------------------------------------------------------------
# Creating IIS Folder Structure
# --------------------------------------------------------------------
New-Item -Path $InetPubRoot -type directory -Force -ErrorAction SilentlyContinue
New-Item -Path $InetPubLog -type directory -Force -ErrorAction SilentlyContinue
New-Item -Path $InetPubWWWRoot -type directory -Force -ErrorAction SilentlyContinue
# --------------------------------------------------------------------
# Copying old WWW Root data to new folder
# --------------------------------------------------------------------
$InetPubOldLocation = @(get-website)[0].physicalPath.ToString()
$InetPubOldLocation = $InetPubOldLocation.Replace("%SystemDrive%",$env:SystemDrive)
Copy-Item -Path $InetPubOldLocation -Destination $InetPubRoot -Force -Recurse
# --------------------------------------------------------------------
# Setting directory access
# --------------------------------------------------------------------
$Command = "icacls $InetPubWWWRoot /grant BUILTIN\IIS_IUSRS:(OI)(CI)(RX) BUILTIN\Users:(OI)(CI)(RX)"
cmd.exe /c $Command
$Command = "icacls $InetPubLog /grant ""NT SERVICE\TrustedInstaller"":(OI)(CI)(F)"
cmd.exe /c $Command
# --------------------------------------------------------------------
# Setting IIS Variables
# --------------------------------------------------------------------
#Changing Log Location
$Command = "%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.logfile.directory:$InetPubLog"
cmd.exe /c $Command
$Command = "%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralBinaryLogFile.directory:$InetPubLog"
cmd.exe /c $Command
$Command = "%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralW3CLogFile.directory:$InetPubLog"
cmd.exe /c $Command
#Changing the Default Website location
Set-ItemProperty 'IIS:\Sites\Default Web Site' -name physicalPath -value $InetPubWWWRoot
# --------------------------------------------------------------------
# Checking to prevent common errors
# --------------------------------------------------------------------
If (!(Test-Path "C:\inetpub\temp\apppools")) {
New-Item -Path "C:\inetpub\temp\apppools" -type directory -Force -ErrorAction SilentlyContinue
}
# --------------------------------------------------------------------
# Deleting Old WWWRoot
# --------------------------------------------------------------------
Remove-Item $InetPubOldLocation -Recurse -Force
# --------------------------------------------------------------------
# Resetting IIS
# --------------------------------------------------------------------
$Command = "IISRESET"
Invoke-Expression -Command $Command
To tylko kwestia nazywając pkgmgr z poprawnych pakietów:
$packages = "IIS-WebServerRole;" +
"IIS-WebServer;" +
"IIS-CommonHttpFeatures;" +
"IIS-StaticContent;" +
"IIS-DefaultDocument;" +
# ... some other packages here
"IIS-ManagementConsole;" +
"IIS-ManagementService;" +
"IIS-LegacySnapIn;" +
"IIS-FTPManagement;" +
"WAS-NetFxEnvironment;" +
"WAS-ConfigurationAPI"
Start-Process "pkgmgr" "/iu:$packages"
zależności od platformy, a na wersji IIS, istnieją pewne subtelne różnice. Możesz znaleźć więcej informacji here, here i here.
Nie działa w systemie Windows 8.1. Pkgmgr jest przestarzały w tym systemie. – pbies
To jest niezły scenariusz. Sugerowałbym jeden dodatek dla przyszłych instalacji \ aplikacje, aby użyć zmodyfikowanego wwwpath
i byłoby zmodyfikować rejestr. Można to zrobić z łatwością dodanie tego do dołu skryptu:
set-ItemProperty HKLM:\Software\Microsoft\InetStp\ -Name PathWWWRoot -Value $InetPubRoot
W każdym razie dzięki za komentarz.
mogę stanie zainstalować IIS przy użyciu skryptu powershell wykonując poniżej kroku:
1) Utwórz plik wsadowy (Setup_IIS_win10.bat) z następującym skryptem w nim
@ECHO OFF
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath="%ThisScriptsDirectory%SetupIISPowerShellScript_win10.ps1"
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%PowerShellScriptPath%""' -Verb RunAs}";
2) Utwórz plik skryptu powershell (SetupIISPowerShellScript_win10.ps1) z następującym skryptem w nim
# This script installs IIS and the features required to run asp.net applications
# * Make sure you run this script from an Admin Prompt!
# * Make sure Powershell Execution Policy is bypassed to run these scripts:
# * YOU MAY HAVE TO RUN THIS COMMAND PRIOR TO RUNNING THIS SCRIPT!
Set-ExecutionPolicy Bypass -Scope Process
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment
Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HealthAndDiagnostics
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpLogging
Enable-WindowsOptionalFeature -Online -FeatureName IIS-LoggingLibraries
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestMonitor
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Security
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestFiltering
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Performance
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerManagementTools
Enable-WindowsOptionalFeature -Online -FeatureName IIS-IIS6ManagementCompatibility
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Metabase
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementConsole
Enable-WindowsOptionalFeature -Online -FeatureName IIS-BasicAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WindowsAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-StaticContent
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DefaultDocument
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebSockets
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationInit
Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIExtensions
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIFilter
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionStatic
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASP
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET35
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET47
#Enable-WindowsOptionalFeature -Online -FeatureName IIS-ServerSideIncludes
Enable-WindowsOptionalFeature -Online -FeatureName WCF-Services45
Enable-WindowsOptionalFeature -Online -FeatureName WCF-Http-Activation45
Enable-WindowsOptionalFeature -Online -FeatureName WCF-TCP-PortSharing45
# If running in the console, wait for input before closing.
if ($Host.Name -eq "ConsoleHost")
{
Write-Host "Press any key to close..."
$Host.UI.RawUI.FlushInputBuffer() # Make sure buffered input doesn't "press a key" and skip the ReadKey().
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
}
3) Uruchom plik wsadowy (Setup_IIS_win10.bat) z Adminitrator przywileju
Mam nadzieję, że przyda się komuś.
- 1. Skrypt programu PowerShell, aby włączyć "Skrypty i narzędzia zarządzania IIS"
- 2. skrypt do dodawania i usuwania właściwości automatycznej inkrementacji z kolumny
- 3. Uruchamianie usług IIS 7 i JBoss AS 7 jednocześnie z serwera Windows 2008
- 4. Usługi rejestrowania usług sieci Web w usługach IIS 7
- 5. Powershell - Restart i kontynuuj skrypt
- 6. Skrypt PowerShell nic nie zwraca na wykonanie IIS
- 7. Instrukcje dotyczące konfigurowania usług IIS i jRuby
- 8. Powershell dla instalacji GitHub
- 9. Dowolne narzędzia do monitorowania wydajności usług IIS i aplikacji
- 10. Problem kompresji statycznego IIS 7
- 11. Skrypt Bash do instalacji narzędzi AWS CLI
- 12. IIS 7: Początkujący samouczek
- 13. Protokoły IIS 7 Enabled
- 14. Skrypt powershell do zmiany konta usługi
- 15. Konfigurowanie usług IIS do zwracania 404 dla prób przeglądania katalogów
- 16. Menedżer IIS 7 nie może pisać do pliku web.config
- 17. Konfigurowanie usług IIS 7 do obsługi plików statycznych za pośrednictwem dostawcy ścieżek wirtualnych
- 18. Zmiana nazwy komputera na serwerze IIS 7
- 19. Skrypt wsadowy do instalacji lub deinstalacji usługi Windows .NET
- 20. Wykonaj skrypt Powershell od Node.js
- 21. Internetowe wdrażanie usług IIS - tworzenie wirtualnych katalogów?
- 22. Jak usunąć niestandardowy nagłówek IIS przy użyciu Powershell?
- 23. zainstalować Nuget poprzez skrypt PowerShell
- 24. Czy istnieje odpowiednik usług IIS dla Tomcat?
- 25. Niepowodzenie instalacji tomcat „7” usługi
- 26. Problemy z modułem powershell IIS 7.5
- 27. Nie można znaleźć usług IIS w systemie Windows 7 Home Basic
- 28. Nie można znaleźć usługi IIS w systemie Windows 7
- 29. Aktualizacja nagłówka hosta w IIS z PowerShell
- 30. Jaka jest różnica między aplikacją sieci Web a folderem wirtualnym w kontekście usług IIS 7.x?
Uwaga: To będzie działać tylko na serwerze 2008 R2. Nie R1 (ostatni 32-bitowy system operacyjny i ten, na którym działam ...) –