출처 : http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2112529&SiteID=17&pageid=0 Exchange 2007 부터는 PowerShell을 알아야 뭔가를 할 수 있다는 사실은 이미 다 아는 사실이다. 사용자 등록을 자동화 하려고 살펴 보던 결과 C# 코드 마저도 PowerShell을 넣어야 한다.. 다음은 MSDN Forum에서 발췌.... To do that in C# you need to use PowerShell SDK. If you have that installed, you're good to go, otherwise read about downloading and installing PowerShell SDK in MSDN. Regarding the using directives, you'll have to include: using System.Management.Automation;using System.Management.Automation.Host;using System.Management.Automation.Runspaces;using Microsoft.PowerShell.Commands;Create a runspace for your cmdlets to run and include the Exchange Management SnapIn... RunspaceConfiguration runspaceConf = RunspaceConfiguration.Create();PSSnapInException PSException = null; PSSnapInInfo info = runspaceConf.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out PSException); Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConf); runspace.Open(); Pipeline pipeline = runspace.CreatePipeline(); Command command = new Command("New-Mailbox"); command.Parameters.Add("Name", "TestName"); //set other mailbox parameters here pipeline.Commands.Add(command); Collection<PSObject> result = pipeline.Invoke(); ...and there you go, it should to the job. I removed from the code the credentials part and exception handling. If you don't know what parameters to set, try adding a user in Exchange Management Console, you'll get at the end the PowerShell command with all the parameters. Hope it helps. |
'서버' 카테고리의 다른 글
비스타 설치가이드 & 세팅 & 고스트복구 가이드-2 (0) | 2008.01.24 |
---|---|
비스타 설치가이드 & 세팅 & 고스트복구 가이드-1 :: (0) | 2008.01.24 |
AD(active directory) 용어집 (0) | 2007.11.25 |
HOWTO: Windows Server 2003에서 Active Directory 서버 만들기 (0) | 2007.11.25 |
Windows 2003 R2 개요 (0) | 2007.11.25 |