init
This commit is contained in:
commit
1e751fcd98
43
ad-init.ps1
Executable file
43
ad-init.ps1
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
# Vérifie si le rôle AD DS est installé
|
||||||
|
if (-not (Get-WindowsFeature -Name AD-Domain-Services).Installed) {
|
||||||
|
Write-Host "Le role AD DS n'est pas installer." -ForegroundColor Red
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# Collecte les informations de l'utilisateur
|
||||||
|
$domaine = Read-Host "Entrez le nom du domaine racine (ex: contoso.local)"
|
||||||
|
$netbios = Read-Host "Entrez le nom NetBIOS du domaine (ex: CONTOSO)"
|
||||||
|
$dsrmPwd = Read-Host "Entrez le mot de passe du mode DSRM (restauration)" -AsSecureString
|
||||||
|
|
||||||
|
# Vérifie que le mot de passe n'est pas vide
|
||||||
|
if (!$dsrmPwd.Length) {
|
||||||
|
Write-Host "Le mot de passe DSRM est requis." -ForegroundColor Red
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# Affiche un récapitulatif
|
||||||
|
Write-Host " Résumé de la configuration :"
|
||||||
|
Write-Host " Domaine : $domaine"
|
||||||
|
Write-Host " NetBIOS : $netbios"
|
||||||
|
Write-Host " Promotion : Nouvelle foret (Root Domain Controller)"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# Confirmation
|
||||||
|
$confirm = Read-Host "Souhaitez-vous continuer ? (O/N)"
|
||||||
|
if ($confirm -ne "O" -and $confirm -ne "o") {
|
||||||
|
Write-Host "Operation annule."
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# Exécution de la promotion
|
||||||
|
Install-ADDSForest `
|
||||||
|
-DomainName $domaine `
|
||||||
|
-DomainNetbiosName $netbios `
|
||||||
|
-DatabasePath "C:\Windows\NTDS" `
|
||||||
|
-LogPath "C:\Windows\NTDS" `
|
||||||
|
-SYSVOLPath "C:\Windows\SYSVOL" `
|
||||||
|
-InstallDNS:$true `
|
||||||
|
-NoRebootOnCompletion:$false `
|
||||||
|
-Force:$true `
|
||||||
|
-SafeModeAdministratorPassword $dsrmPwd
|
||||||
|
|
||||||
2
wac-rm.ps1
Executable file
2
wac-rm.ps1
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "Windows Admin Center*" } | ForEach-Object { $_.Uninstall() }
|
||||||
|
|
||||||
47
wac-script.ps1
Executable file
47
wac-script.ps1
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
# Script de préparation d'une VM Windows Server PowerCore pour Windows Admin Center (WAC)
|
||||||
|
# Exécuter en administrateur !
|
||||||
|
|
||||||
|
Write-Host "--Debut de la preparation de la VM pour Windows Admin Center--" -ForegroundColor Green
|
||||||
|
|
||||||
|
# 1. Activer le service WinRM
|
||||||
|
Write-Host " -Activation du service WinRM-"
|
||||||
|
Enable-PSRemoting -Force
|
||||||
|
|
||||||
|
# 2. Définir WinRM pour accepter toutes les IP (TrustedHosts)
|
||||||
|
Write-Host " -Configuration de TrustedHosts pour WinRM-"
|
||||||
|
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force
|
||||||
|
|
||||||
|
# 3. Configurer le firewall pour WinRM (HTTP sur 5985)
|
||||||
|
Write-Host " -Ouverture du port Firewall pour WinRM-"
|
||||||
|
$InterfaceAlias = "Ethernet 2"
|
||||||
|
|
||||||
|
New-NetFirewallRule -DisplayName "WinRM HTTP Ethernet2" `
|
||||||
|
-Direction Inbound `
|
||||||
|
-Protocol TCP `
|
||||||
|
-LocalPort 5985 `
|
||||||
|
-InterfaceAlias $InterfaceAlias `
|
||||||
|
-Action Allow
|
||||||
|
|
||||||
|
# 4. S'assurer que le service WinRM est en mode automatique
|
||||||
|
Write-Host " -Forcage du demarrage automatique de WinRM-"
|
||||||
|
Set-Service -Name WinRM -StartupType Automatic
|
||||||
|
Restart-Service -Name WinRM
|
||||||
|
|
||||||
|
# 5. Activer Remote Management (Server Manager remote)
|
||||||
|
Write-Host " -Activation de Remote Management-"
|
||||||
|
Configure-SMRemoting -Enable
|
||||||
|
|
||||||
|
# 6. (Optionnel) Installer un certificat SSL pour WinRM HTTPS
|
||||||
|
# Commenté pour rester simple pour WAC en HTTP sécurisé en LAN.
|
||||||
|
<#
|
||||||
|
Write-Host "✅ (Optionnel) Configuration HTTPS WinRM (SSL Self-Signed)..."
|
||||||
|
$Cert = New-SelfSignedCertificate -DnsName "$env:COMPUTERNAME" -CertStoreLocation "cert:\LocalMachine\My"
|
||||||
|
New-Item -Path WSMan:\Localhost\Listener -Transport HTTPS -Address * -CertificateThumbprint $Cert.Thumbprint
|
||||||
|
#>
|
||||||
|
|
||||||
|
# 7. Vérification des statuts
|
||||||
|
Write-Host "#Etat des services WinRM et Firewall :"
|
||||||
|
Get-Service WinRM
|
||||||
|
Get-NetFirewallRule | Where-Object { $_.DisplayGroup -eq "Windows Remote Management" }
|
||||||
|
|
||||||
|
Write-Host "--VM prete pour Windows Admin Center--" -ForegroundColor Green
|
||||||
3
wac-web.ps1
Executable file
3
wac-web.ps1
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
# Y'avais pas de copier/coller
|
||||||
|
|
||||||
|
New-NetFirewallRule -DisplayName "WAC HTTP" -Direction Inbound -LocalPort 443 -Protocol TCP -Action Allow
|
||||||
Loading…
Reference in New Issue
Block a user