查看完整版本: [-- Get-ADUser找不到运行 AD Web 服务的默认服务器 --]

Exchange技术论坛 -> Office 365 定制版用户讨论区 -> Get-ADUser找不到运行 AD Web 服务的默认服务器 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

ycguaa 2015-10-19 17:39

Get-ADUser找不到运行 AD Web 服务的默认服务器

我自己的系统为win7 sp1 64bit,通过powershell连接到office365之后,运行ps1脚本,提示下面错误,网上扒拉半天也没有什么效果,请大神们帮忙看看,哪里没有做。
[attachment=2784]


截图的错误内容为

PS E:\ps> .\newuser.ps1Get-ADUser : 找不到运行 Active Directory Web 服务的默认服务器。
所在位置 E:\ps\newuser.ps1:56 字符: 1+ Get-ADUser -filter {Created -gt $today} -Properties sAMAccountName,displayName,m ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : ResourceUnavailable: (:) [Get-ADUser], ADServerDownException
    + FullyQualifiedErrorId : 找不到运行 Active Directory Web 服务的默认服务器。,Microsoft.ActiveDirectory.Management.Commands.GetADUser

ycguaa 2015-10-20 10:45
有没有大侠帮我解解呢?

ycguaa 2015-10-20 10:52
ps1内容如下


import-module ActiveDirectory

$csvPath = "NewEmployee.csv"
$ReadmePath = "WelcomeNewEmployees.zip"
$today=Get-Date
$yestoday=$today.AddDays(-1)

function send_email
{
#mail server configuration
$smtpServer = "smtpserver"
#$smtpUser = "username"
#$smtpPassword = "password"
#create the mail message
$mail = New-Object System.Net.Mail.MailMessage
#set the addresses
$MailAddress="mailaddress"
$mail.From = New-Object System.Net.Mail.MailAddress($MailAddress)

#set the content
$mail.Subject =  "给新员工的一封信"
$mail.Priority  = "High"
$mail.Body = $MailBody
$filename = $ReadmePath
$attachment = new-Object System.Net.Mail.Attachment($filename)
$mail.Attachments.Add($attachment)
#send the message
$smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer
$smtp.Credentials = New-Object System.Net.NetworkCredential -argumentList $smtpUser,$smtpPassword
$mail.isBodyhtml = $true

$Contents = import-csv $csvPath
foreach ($Content in $Contents)
{
$MailtoAddress = $Content.Mail
$MailtoAddress
if ($MailtoAddress -ne "")
{
  #Get-Member -InputObject $mail.To
  $mail.To.Add($MailtoAddress)
  #echo $mail
  echo $MailtoAddress" mail is send..."
  $ctime=get-date
  $mail.To | select Address | foreach {$csend=-join($csend,$_.Address,";")}
  $log=-join ($ctime,"     ",$csend)
  echo $log >> .\log.txt
  $csend=""
  $smtp.Send($mail)
  $mail.To.Clear()
}
}

$mail.Attachments.remove($attachment)
}

Get-ADUser -filter {Created -gt $yestoday} -Properties sAMAccountName,displayName,mail,employeeNumber,mobile,Created | select sAMAccountName,displayName,mail,employeeNumber,mobile,Created | export-csv -Encoding "Unicode"  -NoTypeInformation $csvPath

$NewEmployeeNumber = import-csv $csvPath | measure-object

$MailBody = "mailbody"

send_email


查看完整版本: [-- Get-ADUser找不到运行 AD Web 服务的默认服务器 --] [-- top --]



Powered by phpwind v8.7.1 Code ©2003-2011 phpwind
Time 0.019187 second(s),query:6 Gzip enabled