-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_script.ps1
More file actions
36 lines (32 loc) · 1.28 KB
/
custom_script.ps1
File metadata and controls
36 lines (32 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# ==============================
# custom_script.ps1
# ==============================
# 1️ Altera o hostname
$desiredHostname = "SRV-SAO-PAULO"
Rename-Computer -NewName $desiredHostname -Force -Restart
# 2️ Cria pasta de dados
$folderPath = "C:\Dados"
if (-Not (Test-Path -Path $folderPath)) {
New-Item -Path $folderPath -ItemType Directory | Out-Null
Write-Host "Pasta $folderPath criada."
} else {
Write-Host "Pasta $folderPath já existe."
}
# 3️ Compartilha a pasta (permite acesso total)
$shareName = "Dados"
if (-Not (Get-SmbShare -Name $shareName -ErrorAction SilentlyContinue)) {
New-SmbShare -Name $shareName -Path $folderPath -FullAccess "Everyone"
Write-Host "Compartilhamento $shareName criado."
} else {
Write-Host "Compartilhamento $shareName já existe."
}
# 4️ Instala o IIS (Feature opcional)
Write-Host "Instalando IIS..."
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
# 5️ (Opcional) cria um site teste no IIS apontando para C:\Dados
Import-Module WebAdministration
$siteName = "SiteTeste"
if (-Not (Get-Website -Name $siteName -ErrorAction SilentlyContinue)) {
New-Item -Path "IIS:\Sites\$siteName" -PhysicalPath $folderPath -BindingInformation "*:80:"
Write-Host "Site $siteName criado."
}