PowerShell를 이용한 IIS 웹사이트 자동 설정 방법 입니다.
PowerSheel 파일은 D:\IIS_SETTING.ps1 으로 지정되어 있습니다.
PowerShell 파일(.ps1) 처리 내용은
1. 폴더 생성
2. Application Pool 생성
3. Site 생성
4. Site내 Application 추가
---------------- BAT 파일 ---------------------
@echo off
setlocal
@echo IIS 설정 페이지 입니다.
set /p str=프로젝트명칭(Html URL 에 사용가능한)을 입력하세요:
IF "%str%" == "" GOTO Error
Powershell.exe -noprofile -executionpolicy bypass -file "D:\IIS_SETTING.ps1" "%str%"
:Error
@echo 프로젝트 명칭은 필수 입니다.
pause
---------------- BAT 파일 끝 ------------------
---------------- PowerShell 파일 ----------------
[string]$name=$args
[string]$nameupper = $name.ToUpper("euc-kr");
[string]$webroot = "D:\wwwRoot\Project\$nameupper\Application";
[string]$serviceroot = "D:\wwwRoot\Project\$nameupper\WS";
[string]$fileroot = "D:\Upload Files\$nameupper";
[string]$sitename = "kr.d-0-b.$name"
[string]$url = $name+".d-0-b.kr"
#Set-ExecutionPolicy RemoteSigned;
import-module WebAdministration;
mkdir "$webroot";
mkdir "$serviceroot";
mkdir "$fileroot";
IIS:
echo $sitename;
Set-Content -LiteralPath "$webroot\index.html" -Value "<br /><br /><br /><br /><br /><center>$name.d-0-b.kr";
New-WebAppPool $sitename;
New-Website -Name "$sitename" -Port 80 -PhysicalPath "$webroot" -ApplicationPool "$sitename" -HostHeader $url;
New-WebApplication -Name "WS" -Site "$sitename" -PhysicalPath "$serviceroot" -ApplicationPool "$sitename";
---------------- PowerShell 파일 끝 -------------
'Server > Windows Server' 카테고리의 다른 글
[Hyper-V] 예기치 않은 오류가 발생했습니다. 로그온 실패: 사용자는 이 컴퓨터에서는 요청된 로그온 유형을 허가받지 않았습니다.(0x80070569). (0) | 2022.07.27 |
---|---|
IIS Crypto 적용 시 주의? 유의 사항 구버전 MS SQL 연결 - 추천 Cipher Suites (0) | 2022.07.22 |
[PowerShell] Windows Server Backup (0) | 2022.02.24 |
[PowerShell] Windows 자동 업데이트 (0) | 2022.02.24 |
HTTPS 연결(SSL)시 ERR_CONNECTION_RESET 문제. TLS cipher (0) | 2018.08.31 |