How to – Create multiple IIS sites from text file using Powershell

The end result is the following script which will import the contents of a .txt file from c:\rs-pkgs\websites.txt by default. Simply populate your text file with each site name on a separate line, e.g.:

test1.com

test2.com

test3.com

test4.com

Save that in C:\rs-pkgs as websites.txt and then run the following script:

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
37
Import-Module WebAdministration
$i = 0
ForEach ($Item in Get-Content -Path C:\rs-pkgs\website.test.txt)
{
    $iisAppPoolName = [string]$Item
    $iisAppPoolDotNetVersion = "v4.0"
    $iisAppName = $iisAppPoolName
    $directoryPath = "C:\inetpub\wwwroot\" + $iisAppPoolName
    #navigate to the app pools root
    cd IIS:\AppPools\
    #check if the app pool exists
    if (!(Test-Path $iisAppPoolName -pathType container))
    {
        #create the app pool
        $appPool = New-Item $iisAppPoolName
        $appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $iisAppPoolDotNetVersion
    }
    #navigate to the sites root
    cd IIS:\Sites\
    #check if the site exists
    if (Test-Path $iisAppName -pathType container)
    {
        return
    }
    #create the directory
    md $directoryPath
    #create the site
    $iisApp = New-Item $iisAppName -bindings @{protocol="http";bindingInformation=":80:" + $iisAppName} -physicalPath $directoryPath
    $iisApp | Set-ItemProperty -Name "applicationPool" -Value $iisAppPoolName
    $i += 1
}

from https://community.rackspace.com/developers/f/7/t/1735

TABLE LAYOUT USING DIV TAGS

1.
<div class=“container”>
    <div class=“heading”>
         <div class=“col”>category ID</div>
         <div class=“col”>category </div>
    </div>
    <div class=“table-row”>
         <div class=“col”>1</div>
         <div class=“col”>PHP</div>
    </div>
    <div class=“table-row”>
         <div class=“col”>2</div>
         <div class=“col”>WordPress</div>
    </div>
</div>
2.
.container{
    display:table;
    width:90%;
    bordercollapse: collapse;
    }
.heading{
     fontweight: bold;
     display:tablerow;
     backgroundcolor:#C91622;
     textalign: center;
     lineheight: 25px;
     fontsize: 14px;
     fontfamily:georgia;
     color:#fff;
    
}
.tablerow{  
     display:tablerow;
     textalign: center;
}
.col{
    display:tablecell;
    border: 1px solid #CCC;
}

윈도우서버 | [Windows 2012] SMTP 서버 설치 및 구성

윈도우서버 | [Windows 2012] SMTP 서버 설치 및 구성

페이지 정보

작성일

2015-02-01 13:28 조회9,219회 댓글0건

게시물 상단 버튼 시작 {

} 게시물 상단 버튼 끝

본문

본문 내용 시작 {

Windows Server 2008 R2: SMTP 서버 설치 및 구성

SMTP 서버 설치

다음 단계에서는 SMTP 서버 기능을 설치합니다.

1. 서버 관리자 열기: 키보드에서 Windows 단추를 클릭합니다. 서버 관리자를 입력합니다. 결과 창에서 서버 관리자를 클릭합니다.

2. 왼쪽 창에서 대시보드를 클릭합니다.

3. 역할 및 기능 추가를 클릭합니다. 역할 및 기능 추가는 오른쪽 상단의 관리 메뉴에서도 열 수 있습니다.

4. 시작하기 전에 창에서 다음을 클릭합니다.

5. 설치 유형에서 역할 기반 또는 기능 기반 설치를 클릭합니다. Next를 클릭합니다.

6. 서버 선택에서 서버 풀에서 서버 선택을 클릭하고 원하는 서버를 클릭한 후 다음을 클릭합니다. 서버 선택 창에 서버 관리자에서 서버 추가를 사용하여 추가된 서버가 표시됩니다. 기본적으로 로컬 서버가 선택됩니다. 서버 관리자에 서버 추가에는 Windows Server 2012에서 서버 추가를 사용하는 단계가 표시됩니다.

7. 서버 역할 창에서 다음을 클릭합니다.

8. 기능 창에서 SMTP 서버를 선택합니다. 메시지가 표시되면 기능 추가를 클릭합니다. Next를 클릭합니다.

9. 확인에서 필요한 경우 자동으로 대상 서버 다시 시작을 클릭한 후 설치를 클릭합니다. 완료되면 닫기를 클릭합니다.

SMTP 서버 구성

다음 단계에서는 IIS 6.0 관리자를 사용하여 SMTP 가상 서버를 구성합니다.

1.  IIS 관리자 열기: 키보드에서 Windows 단추를 클릭합니다. IIS를 입력합니다. 결과 창에서 IIS(인터넷 정보 서비스) 6.0 관리자를 클릭합니다.

2. 컴퓨터 이름을 확장합니다. [SMTP 가상 서버 #1]을 마우스 오른쪽 단추로 클릭하고 속성을 클릭합니다.

3. 액세스 탭에서 릴레이 단추를 클릭합니다.

4. 추가를 클릭합니다. 단일 컴퓨터의 경우 127.0.0.1을 입력하고 확인을 클릭합니다.

5. 127.0.0.1을 추가하면 로컬 서버에서 이 SMTP 서버를 통해 메시지를 보낼 수 있습니다. 추가 컴퓨터에서 이 SMTP 서버를 통해 메시지를 보내려면 해당 IP 주소를 입력합니다.

6. 배달 탭에서 아웃바운드 연결을 클릭합니다. 기본적으로 TCP 포트는 25입니다. 이 포트가 방화벽 내에서 열려 있는 경우 다른 포트를 입력할 수 있습니다. 확인을 클릭합니다.

7. 배달 탭에서 고급을 클릭합니다. 기본적으로 로컬 서버의 정규화된 도메인 이름이 표시됩니다. 인터넷 공급자에 따라 스마트 호스트 속성이 비어 있을 수 있습니다. 스마트 호스트가 필요한지 여부를 확인하기 위해 인터넷 공급자에게 문의해야 할 수도 있습니다. 그렇지 않은 경우 smtp.EMailProvider.com을 입력할 수 있습니다.

8. 확인을 클릭하여 모든 창을 닫습니다.

9. SMTP 서버 다시 시작: [SMTP 가상 서버 #1]을 마우스 오른쪽 단추로 클릭하고 중지를 클릭한 후 시작을 클릭합니다. SMTP 서버 설정을 적용하려면 다시 시작해야 합니다.

SMTP 서버 테스트

텔넷을 사용하여 SMTP 서버 구성을 테스트할 수 있습니다. 다음 단계에서는 구성된 SMTP 서버를 사용하여 전자 메일 주소로 메시지를 보냅니다. http://support.microsoft.com/kb/153119 에서는 텔넷 명령에 대한 설명을 제공합니다.

1. 관리자 권한으로 명령 창을 엽니다.

 Windows Server 2008 R2 : 시작을 클릭하고 검색 입력란에 명령을 입력합니다. 명령 프롬프트를 마우스 오른쪽 단추로 클릭한 다음 관리자 권한으로 실행을 클릭합니다.

 Windows Server 2012 : 키보드에서 Windows 단추를 클릭합니다. 명령을 입력합니다. 결과 창에서 명령 프롬프트를 마우스 오른쪽 단추로 클릭한 다음 작업 표시줄에서 관리자 권한으로 실행을 클릭합니다.

2. 명령 프롬프트에서 다음을 입력합니다.

telnet localhost 25

텔넷이 설치되지 않은 경우 다음을 입력하여 설치합니다.

pkgmgr /iu:”TelnetClient”

3. 다음을 입력하여 통신을 시작합니다.

EHLO server

4. 메일 보낸 사람 주소를 입력합니다.

MAIL FROM: YourEmailAddress@YourProvider.com

예를 들어 다음과 같이 입력합니다.

MAIL FROM: EmailAddress@outlook.com

5. 메일 받는 사람 주소를 입력합니다.

RCPT TO: YourEmailAddress@YourProvider.com

예를 들어 다음과 같이 입력합니다.

RCPT TO: EmailAddress@outlook.com

6. 다음을 입력하여 SMTP 서버에 데이터를 보낼 준비가 완료되었음을 알립니다.

DATA

7. 다음을 입력하여 제목을 입력합니다.

Subject: Test Message

8. Enter 키를 두 번 누릅니다.

9. 다음을 입력하여 메시지 본문을 입력합니다.

This is the message body of the test message.

10. Enter 키를 누르고 마침표(.)를 입력한 후 Enter 키를 누릅니다.

전자 메일 메시지의 RCPT TO 주소를 확인합니다. 전자 메일 메시지가 배달되지 않은 경우(받은 편지함 및 스팸 폴더 확인) 메시지가 전송되지 않고 SMTP 큐 폴더(C:\inetpub\mailroot\Queue)에 남아 있습니다.

참고자료

https://msdn.microsoft.com/ko-kr/library/dn292550.aspx

 

asp 2 dimension array

Dim arr(3, 4)
‘4행 5열 배열
‘0부터 시작하므로 행은 0,1,2,3까지 총 4행
‘0부터 시작하므로 열은 0,1,2,3,4 까지 총 5열

numrows = UBound(arr, 1) ‘행
numcols = UBound(arr, 2) ‘열
cnt = 0

For i = 0 To numrows ‘행
For j = 0 To numcols ‘열
arr(i, j) = cnt
‘ response.write “{“& i &”,”&j&”}”
Response.Write(“{ ” & arr(i, j) & ” }”)
cntcnt = cnt + 1
Next
Response.Write(“<br /><br />”)
Next

​ webknight korean(uploading) considerations

Url Scanning

 –> deny url highbitshellcode 옵션 해제
 –> RFC Compliant Url 옵션 해제
 –> RFC Compliant HTTP Url 옵션 해제
Referer
–> Referer URL RFC Compliant 옵션 해제
–> Referer URL RFC HTTP Compliant 옵션 해제
Querystring
–> Deny Querystring High Bit Shellcode 옵션 해제
Request file deny
–> webknight.xml ‘nul’ 제거됨

asp <-> php 상호 변환

General syntax
ASP Comments, inline
'my dog has fleas
PHP Comments, inline
//my dog has fleas
ASP Comments, block

not available?
PHP Comments, block
/*
The quick brown fox
jumped over the lazy dogs.
*/
ASP, Escaping quotes
""

“var text1=””<img src=\””blank.gif\””>””;”

PHP, Escaping quotes
\" or use ' like javascript

‘var text1=”<img src=\”blank.gif\”>”;’;

ASP Command termination
None, but only one command per line.
PHP Command termination
Each command must end with ; but
multiple commands per line are allowed.
ASP Screen output
response.write "hello"
PHP Screen output
echo "hello";
ASP Newline characters
vbCrLf

response.write “hello” & vbCrLf

PHP Newline characters
"\n" (must be inside "", not '')

echo “hello \n”;

ASP Variable Names
Not case sensitive,
so fName is the same as FNAME
PHP Variable Names
Case sensitive AND must begin with $
so $fName is NOT the same as $FNAME
String Functions
ASP String concatenation
&

fname=name1 & ” ” & name2
emsg=emsg & “error!”

PHP String concatenation
. and .=

$fname=$name1.” “.$name2;
$emsg.=”error!”;

ASP, Change case
LCase(), UCase()

lowerName=LCase(chatName)
upperName=UCase(chatName)

PHP, Change case
strtolower(), strtoupper()

$lowerName=strtolower($chatName);
$upperName=strtoupper($chatName);

ASP String length
Len()

n=Len(chatName)

PHP String length
strlen()

$n=strlen($chatName);

ASP, Trim whitespace
Trim()

temp=Trim(xpage)

PHP, Trim whitespace
trim() and also ltrim(), rtrim()

$temp=trim($xpage);

ASP String sections
Left(), Right(), Mid()

Left("abcdef",3)      result = "abc"
Right("abcdef",2)     result = "ef"
Mid("abcdef",3)       result = "cdef"
Mid("abcdef",2,4)     result = "bcde"
PHP String sections
substr()

substr("abcdef",0,3);     result = "abc"
substr("abcdef",-2);      result = "ef"
substr("abcdef",2);       result = "cdef"
substr("abcdef",1,4);     result = "bcde"
ASP String search forward, reverse
Instr(), InstrRev()

x=Instr("abcdef","de")        x=4 
x=InstrRev("alabama","a")     x=7
PHP String search forward, reverse
strpos(), strrpos()

$x=strpos("abcdef","de");      x=3
$x=strrpos("alabama","a");     x=6
ASP String replace
Replace(string exp,search,replace)

temp=Replace(temp,”orange”,”apple”)
temp=Replace(temp,”‘”,”\'”)
temp=Replace(temp,””””,”\”””)

PHP String replace
str_replace(search,replace,string exp)

$temp=str_replace(“orange”,”apple”,$temp); $temp=str_replace(“‘”,”\\'”,$temp);
$temp=str_replace(“\””,”\\\””,$temp);

ASP, split a string into an array
Split()

temp="cows,horses,chickens"
farm=Split(temp,",",-1,1)  
x=farm(0)
PHP, split a string into an array
explode()

$temp="cows,horses,chickens";
$farm=explode(",",$temp);
$x=$farm[0];
ASP, convert ASCII to String
x=Chr(65) x="A"
PHP, convert ASCII to String
$x=chr(65); x="A"
ASP, convert String to ASCII
x=Asc("A") x=65
PHP, convert String to ASCII
$x=ord("A") x=65
Control Structures
ASP, if statements
if x=100 then
  x=x+5 
elseif x<200 then 
  x=x+2 
else 
  x=x+1 
end if
PHP, if statements
if ($x==100) { 
  $x=$x+5; 
} 
else if ($x<200) { 
  $x=$x+2; 
} 
else { 
  $x++; 
}
ASP, for loops
for x=0 to 100 step 2 
  if x>p then exit for
next
PHP, for loops
for ($x=0; $x<=100; $x+=2) { 
  if ($x>$p) {break;}
}
ASP, while loops
do while x<100 
  x=x+1 
  if x>p then exit do
loop
PHP, while loops
while ($x<100) { 
  $x++; 
  if ($x>$p) {break;}
}
ASP, branching
select case chartName
  case "TopSales"
    theTitle="Best Sellers"
    theClass="S"
  case "TopSingles"
    theTitle="Singles Chart"
    theClass="S"
  case "TopAlbums"
    theTitle="Album Chart"
    theClass="A"
  case else
    theTitle="Not Found"
end select
PHP, branching
switch ($chartName) {
  case "TopSales":
    $theTitle="Best Sellers"; $theClass="S";
    break;
  case "TopSingles":
    $theTitle="Singles Chart"; $theClass="S";
    break;
  case "TopAlbums":
    $theTitle="Album Chart"; $theClass="A";
    break;
  default:
    $theTitle="Not Found";
}
ASP functions
Function myFunction(x)
  myFunction = x*16  'Return value
End Function
PHP functions
function myFunction($x) {
  return $x*16;  //Return value
}
HTTP Environment
ASP, Server variables
Request.ServerVariables("SERVER_NAME")
Request.ServerVariables("SCRIPT_NAME")
Request.ServerVariables("HTTP_USER_AGENT")
Request.ServerVariables("REMOTE_ADDR")
Request.ServerVariables("HTTP_REFERER")
PHP, Server variables
$_SERVER["HTTP_HOST"];
$_SERVER["PHP_SELF"];
$_SERVER["HTTP_USER_AGENT"];
$_SERVER["REMOTE_ADDR"];
@$_SERVER["HTTP_REFERER"];     @ = ignore errors
ASP Page redirects
Response.redirect("wrong_link.htm")
PHP Page redirects
header("Location: wrong_link.htm");
ASP, GET and POST variables
Request.QueryString("chat")
Request.Form("username")
PHP, GET and POST variables
@$_GET["chat"];       @ = ignore errors
@$_POST["username"];
ASP, prevent page caching
Response.CacheControl="no-cache"
Response.AddHeader "pragma","no-cache"
PHP, prevent page caching
header("Cache-Control: no-store, no-cache");
header("Pragma: no-cache");
ASP, Limit script execution time, in seconds
Server.ScriptTimeout(240)
PHP, Limit script execution time, in seconds
set_time_limit(240);
ASP, Timing script execution
s_t=timer 

...ASP script to be timed...

duration=timer-s_t
response.write duration &" seconds"
PHP, Timing script execution
$s_t=microtime();

...PHP script to be timed...
  
$duration=microtime_diff($s_t,microtime());
$duration=sprintf("%0.3f",$duration);
echo $duration." seconds";
  
//required function
function microtime_diff($a,$b) {
  list($a_dec,$a_sec)=explode(" ",$a);
  list($b_dec,$b_sec)=explode(" ",$b);
  return $b_sec-$a_sec+$b_dec-$a_dec;
}
File System Functions
ASP, create a file system object (second line is wrapped)
'Required for all file system functions
fileObj=Server.CreateObject
("Scripting.FileSystemObject")
PHP, create a file system object
Not necessary in PHP
ASP, check if a file exists
pFile="data.txt"
fileObj.FileExists(Server.MapPath(pFile))
PHP, check if a file exists
$pFile="data.txt";
file_exists($pFile);
ASP, Read a text file
pFile="data.txt"
xPage=fileObj.GetFile(Server.MapPath(pFile))
xSize=xPage.Size  'Get size of file in bytes

xPage=fileObj.OpenTextFile(Server.MapPath(pFile))
temp=xPage.Read(xSize)  'Read file
linkPage.Close
PHP, Read a text file
$pFile="data.txt";
$temp=file_get_contents($pFile);  //Read file
Time and Date Functions
ASP, Server Time or Date
Now, Date, Time
PHP, Server Time or Date
date()
ASP, Date format (default)
Now = 3/19/2007 8:13:10 AM
Date = 3/19/2007
Time = 8:13:10 AM
Various ASP functions extract date parts:Month(Date) = 3
MonthName(Month(Date)) = March
Day(Date) = 19
WeekdayName(Weekday(Date)) = Monday
WeekdayName(Weekday(Date),False) = Mon
PHP, Date format
There is no default format in PHP.
The date() function is formatted using codes:
date(“n/j/Y g:i:s A”) = 3/19/2007 8:13:10 AMdate(“n”) = 3
date(“F”) = March
date(“j”) = 19
date(“l”) = Monday
date(“D”) = Mon
Numeric Functions
ASP, convert decimal to integer
Int()

n=Int(x)

PHP, convert decimal to integer
floor()

$n=floor($x);

ASP, determine if a value is numeric
IsNumeric()

if IsNumeric(n) then …

PHP, determine if a value is numeric
is_numeric()

if (is_numeric($num)) {…}

ASP, modulus function
x mod y
PHP, modulus function
$x % $

 

Microsoft IIS 7.0 and later with php 7

Microsoft IIS 7.0 and later with php 7
http://php.net/manual/kr/install.windows.iis7.php#install.windows.iis7
http://php.net/manual/kr/mysql.installation.php
mysqli vs PDO drivers
http://code.tutsplus.com/tutorials/pdo-vs-mysqli-which-should-you-use–net-24059
php 한글 manual
http://php.net/manual/kr/
deprecated in php7 – php_mysql.dll
https://wiki.php.net/rfc/remove_deprecated_functionality_in_php7
mysqli_pagenation.php
https://www.developphp.com/video/PHP/Pagination-MySQLi-Google-Style-Paged-Results-Tutorial
http://www.9lessons.info/2010/10/pagination-with-jquery-php-ajax-and.html
http://www.phpgang.com/how-to-create-advance-pagination-in-php-mysql-with-jquery_404.html
PDO_pagenation.php
http://www.phpro.org/tutorials/Pagination-with-PHP-and-PDO.html
http://www.phpro.org/tutorials/Filtering-Data-with-PHP.html

Remote Desktop Black screen Windows Server 2008 r2

Remote Desktop Black screen Windows Server 2008 r2
Nick van Vuren
29/08/2014   No
Comments on Remote Desktop Black screen Windows
Server 2008 r2
When a users tries to log on, the workstation or server hangs on a blank
screen/black screen.
With the administrator account, i found in the registry the following
Warning:
EVENT ID 4006
The Windows logon process has failed to
spawn a user application. Application name: . Command line parameters:
C:\Windows\system32\userinit.exe.
To fix this issue, i had to add the groups NT AUTHORITY\Authenticated Users
and the NT AUTHORITY\INTERACTIVE to the local group “Users”.
After this, the user was able to log on again and the Desktop did show
up.