Michael Leonard
asked on
need assistance with a Quest AD cmdlets script
Hello, I need to modify the following Quest AD CMDlets script to key on the following attribute:
l <- location = UK
currently the script only targets an OU, i need it to only pull results for accounts with the "l" field = UK.
l <- location = UK
currently the script only targets an OU, i need it to only pull results for accounts with the "l" field = UK.
# Instruction to add Quest Powershell Snap-in
Add-PSSnapin quest.ActiveRoles.admanagement
$OU="mydomain.com/Users"
$Logfile="C:\result.csv"
Get-Qaduser -SizeLimit 0 -SearchRoot $OU |
select mail,sAMAccountName,displayName,telephoneNumber,mobile,l,givenName,sn |
Export-Csv $Logfile -NoTypeInformation
#Email the data
$EmailBody = "User List Attached"
$message = New-Object System.Net.Mail.MailMessage –ArgumentList reports@mydomain.com,LDAP-Reports-AdHoc@mydomain.com,'AD DS Export Report', $EmailBody
$smtp = New-Object System.Net.Mail.SMTPClient –ArgumentList smtp.mydomain.com
$Attachment = New-Object System.Net.Mail.Attachment($Logfile)
$message.Attachments.Add($attachment)
$smtp.Send($message)
Start-Sleep 1
$Attachment.Dispose()
$Message.Dispose()
#Remove the temp file
if (Test-Path $Logfile) {Remove-Item $Logfile}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry forgot to add the ? variable. running it now in the lab.
the "?" is the same as saying "where" or "where-object"
ASKER
works great! thank you
ASKER
Expressions are only allowed as the first element of a pipeline.