#powershell #skype4b Get List of Not Enabled Skype for Business Users (Without #skype4b Cmdlets)

#requires -version 3.0
###############################################################################
# Copyright (c) 201x-2018 leedesmond.com
# All Rights Reserved. Use at your own risk and responsibility.
# Version 1.00
#
# Get a list of not enabled Skype for Business Users (without SkypeForBusiness
# Module Cmdlets)
#
###############################################################################
#

$dtStart = Get-Date
$dtStart
#
$searchString = "(&(objectClass=user)"
$searchString += "(!(msrtcsip-userenabled=*))"
$searchString += "(!(msrtcsip-primaryuseraddress=*))"
$searchString += "(!(samaccountname=*$)))" #skip computer accounts with trailing $
#
$searcher = [ADSISearcher]$searchString
$searcher.PageSize = 1000
$searcher.PropertiesToLoad.AddRange(
@(
"samaccountname",
"displayname",
"msrtcsip-primaryuseraddress")
)
#
$searchResults = $searcher.FindAll()
#
$ulist = @()
if ($searchResults.Count -gt 0 )
{
foreach ($searchResult in $searchResults)
{
$prop = $searchResult.Properties
$ulist +=
$searchResult | Select-Object `
@{Name="samaccountname";
Expression={$prop["samaccountname"][0]}},
@{Name="displayname";
Expression={$prop["displayname"][0]}},
@{Name="msrtcsip-primaryuseraddress";
Expression={$prop["msrtcsip-primaryuseraddress"][0]}}
}
}
#
$searchResults.Dispose()
#
#$searcher | ogv -Title "searcher $($searcher.count)"
$ulist | ogv -Title "ulist $($ulist.count)"
#
$dtEnd = Get-Date
$dtEnd
$dtEnd - $dtStart

REFERENCE
Powershell DirectorySearcher Null Output (stackoverflow)

Bookmark the permalink.

Leave a Reply