Finding Group members in AD

This is a simple script that will pull up the names of the members of a given group in AD. I use Excell to collect all the names.

 

$group = Read-Host "Enter group name to find"
$row = 2
$as = Get-ADGroup $group | Get-ADGroupMember

$xlSummaryAbove = 0 
$xlSortValues = $xlPinYin = 1 
$xlAscending = 1 
$xlDescending = 2
$xl = New-Object -comobject excel.application 
$xl.Visible = $true 
$wb = $xl.Workbooks.Add() 
$ws = $wb.Worksheets.Item(1) 
$row = 2
 $ws.Cells.Item(1,1) = 'First Name'
 $ws.Cells.Item(1,2) = 'Last Name'
 $ws.Cells.Item(1,3) = 'EMail Address'
 $ws.Cells.Item(1,4) = 'samAccountName'
 $range = $ws.range('A1:D1')
 $range.font.bold = 'true' 
foreach ($item in $as) { 
$name = Get-ADUser $item.samAccountName
 $ws.Cells.Item($row,1) = $name.GivenName
 $ws.Cells.Item($row,2) = $name.surname
 $ws.Cells.Item($row,3) = $item.name
 $ws.Cells.Item($row,4) = $name.samAccountName 
 $row++
  }

# one-column sort --> works 
$range1 = $ws.range('A2:D2500')
$range2 = $ws.range('B2')
[void]$range1.sort($range2, $xlAscending)
[void]$range1.entireColumn.Autofit()

Import Contacts for Lync 2010

My goal was to import a contact list for my Lync Client.
The idea was to set up a new user in our group with at least a start of a contact list for our team.

You can find a write up and the code for this here:
http://gallery.technet.microsoft.com/office/Import-Contacts-for-Lync-5fe0e671
You will need to install some stuff before you can use this.
Like the LynkSdkRedist.msi which is included in the zip file that you can download from the above site. .

I found that if you have multiple people with the same name, it will add them all if you do the import.

If you know the email address of the people you want to add to your contacts, you can just create a CSV file like this:

"GroupName","GroupType","Overwrite","Contacts"
"NSD","CustomGroup","True","sip:user1.mymail.com;sip:user2.mymail.com"

You can add whole distribution groups from the GAL as well.
To add a Distribution Group include this line:

"Dist Group Name from the GAL","DistributionGroup","N/A","DistributionGroup@mymail.com"

In this case my group name was NSD. Not sure what the “sip:” is all about, but you need it.
The “True” will cause it to overwrite any names or the whole group if it already exist.