Powershell - Automatiser l'installation les modules IIS
Présentation
Il est possible d'avoir besoin de développer un site et que vous avez besoin d'un moteur Web et qui vous permettre d'utiliser ASP.NET sur Windows 10.Alors l’installation de IIS10 (Internet Information Services) sera indispensable pour vous.
Pour ceux qui ne connaissent pas. Il s’agit, d’un serveur proposant des services web tels que HTTP, SMTP, FTP …
Selon certaines études le grand concurrent à L’ISS de Microsoft est Apache qui occuperait entre 65% et 75% des parts de marché.
Dans cette article, nous allons utiliser une méthode alternative au méthode conventionnel,
Vérifier la présence des modules IIS
On peut vérifier la présence ou non des installations des différentes modules via cette commande PowerShell.Start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;WAS-WindowsActivationService;WAS-ProcessModel
Vérifier la présence des modules IIS
Avec pkgmgr (Package Manager Command-Line)
Start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;WAS-WindowsActivationService;WAS-ProcessModel
Avec pkgmgr (Package Manager Command-Line) with an unattend file
# Gets the date in a string variable for logfile naming
$date=(Get-Date).ToString('dd-MM-yyyy')
# Gets the OS Version number to append the unattend.xml file
$OSInstallVer = $(Get-ItemProperty HKLM:\Software\Microsoft\DataAccess).FullInstallVer
(Get-Content .\unattend.xml) |
ForEach-Object {$_ -replace "OS-VERSION-NB", "$OSInstallVer"} |
Set-Content .\unattend.xml
Start /w pkgmgr /n:.\unattend.xml /l:.\install-IIS-$date.log
Le fichier Unattend.xml que l'on doit utiliser.<?xml version="1.0" ?> <unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> <servicing> <!-- Install a selectable update in a package that is in the Windows Foundation namespace --> <package action="configure"> <assemblyIdentity name="Microsoft-Windows-Foundation-Package" version="OS-VERSION-NB" language="neutral" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" /> <selection name="IIS-WebServerRole" state="true"/> <selection name="IIS-WebServer" state="true"/> <selection name="IIS-CommonHttpFeatures" state="true"/> <selection name="IIS-HttpErrors" state="false"/> <selection name="IIS-HttpRedirect" state="false"/> <selection name="IIS-ApplicationDevelopment" state="false"/> <selection name="IIS-NetFxExtensibility" state="false"/> <selection name="IIS-HealthAndDiagnostics" state="true"/> <selection name="IIS-HttpLogging" state="true"/> <selection name="IIS-LoggingLibraries" state="true"/> <selection name="IIS-RequestMonitor" state="true"/> <selection name="IIS-HttpTracing" state="false"/> <selection name="IIS-Security" state="true"/> <selection name="IIS-URLAuthorization" state="false"/> <selection name="IIS-RequestFiltering" state="true"/> <selection name="IIS-IPSecurity" state="true"/> <selection name="IIS-Performance" state="false"/> <selection name="IIS-HttpCompressionDynamic" state="false"/> <selection name="IIS-WebServerManagementTools" state="true"/> <selection name="IIS-ManagementScriptingTools" state="false"/> <selection name="IIS-IIS6ManagementCompatibility" state="false"/> <selection name="IIS-Metabase" state="false"/> <selection name="WAS-WindowsActivationService" state="true"/> <selection name="WAS-ProcessModel" state="true"/> <selection name="WAS-NetFxEnvironment" state="false"/> <selection name="WAS-ConfigurationAPI" state="false"/> <selection name="IIS-HostableWebCore" state="false"/> <selection name="IIS-StaticContent" state="true"/> <selection name="IIS-DefaultDocument" state="true"/> <selection name="IIS-DirectoryBrowsing" state="true"/> <selection name="IIS-WebDAV" state="false"/> <selection name="IIS-ASPNET" state="false"/> <selection name="IIS-ASP" state="false"/> <selection name="IIS-CGI" state="false"/> <selection name="IIS-ISAPIExtensions" state="false"/> <selection name="IIS-ISAPIFilter" state="false"/> <selection name="IIS-ServerSideIncludes" state="false"/> <selection name="IIS-CustomLogging" state="false"/> <selection name="IIS-BasicAuthentication" state="false"/> <selection name="IIS-HttpCompressionStatic" state="true"/> <selection name="IIS-ManagementConsole" state="false"/> <selection name="IIS-ManagementService" state="false"/> <selection name="IIS-WMICompatibility" state="false"/> <selection name="IIS-LegacyScripts" state="false"/> <selection name="IIS-LegacySnapIn" state="false"/> <selection name="IIS-FTPServer" state="false"/> <selection name="IIS-FTPSvc" state="false"/> <selection name="IIS-FTPExtensibility" state="false"/> <selection name="IIS-WindowsAuthentication" state="false"/> <selection name="IIS-DigestAuthentication" state="false"/> <selection name="IIS-ClientCertificateMappingAuthentication" state="false"/> <selection name="IIS-IISCertificateMappingAuthentication" state="false"/> <selection name="IIS-ODBCLogging" state="false"/> </package> </servicing> </unattend>
Avec Add-WindowsFeature (Add-WindowsFeature Cmdlet)
Voici ma méthode préférée qui consiste à utiliser un pipeline et la méthode ForEach-Object.Get-WindowsOptionalFeature -Online | Where-Object FeatureName -like 'IIS-*' | ForEach-Object {Enable-WindowsOptionalFeature -Online -FeatureName $_.FeatureName -ErrorAction SilentlyContinue}
Commentaires
Enregistrer un commentaire