Power Shell2010. 2. 3. 08:59

일단 foreach문으로 log를 파일에 이렇게 저장하고 싶었다.


 2010-02-03 오전 8:51:37 ([Success] [Join] Machine Type: Display, Client Id: Ip Address:172.16.20.191, Machine Type: 
 2010-02-03 오전 8:48:34 ([Success] [Join] Machine Type: Display, Client Id: Ip Address:172.16.20.191, Machine Type:  
 2010-02-03 오전 8:45:31 ([Success] [Join] Machine Type: Display, Client Id: Ip Address:172.16.20.191, Machine Type:  


근데 이게  c#처럼 \r\n을 쓸수가 없어서 찾아밨지만 못찾았다...


그래서 그냥 stringbuilder의 appendline()을 이용해서 성공 


$strBld = new-object System.Text.StringBuilder

foreach ($data in $GetJoinDataSet.Tables[0])
{
$ShowJoinInfo= " {0} ({1} " -f $data[3], $data[4];
$strBld.Append($ShowJoinInfo)
$strBld.AppendLine()
}


Set-Content -Path ".\logs\JoinLog.xml" -Value $strBld
}

참고 : http://keithhill.spaces.live.com/blog/cns!5A8D2641E0963A97!811.entry

Posted by 동동(이재동)