Skip to content

Instantly share code, notes, and snippets.

@bmcguirk
Created August 11, 2016 14:17
Show Gist options
  • Save bmcguirk/0b2de6f03d7804c264317edf49c79d47 to your computer and use it in GitHub Desktop.
Save bmcguirk/0b2de6f03d7804c264317edf49c79d47 to your computer and use it in GitHub Desktop.
Find All Sharepoint Sites on Local Network - Sharepoint PS Module Not Required
# Because they pop up like crazy and are often not well-maintained, which is just kind of asking for something awful to happen.
# I didn't write this script, but you can see the original blog post here:
# http://www.wildwires.com/blog/12-02-24/finding_every_server_that_has_sharepoint_installed.aspx
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.Filter = '(OperatingSystem=Window*Server*)'
"Name","canonicalname","distinguishedname" | Foreach-Object {$null = $objSearcher.PropertiesToLoad.Add($_) }
$names = $objSearcher.FindAll() | Select-Object @{n='Name';e={$_.properties['name']}},@{n='ParentOU';e={$_.properties['distinguishedname'] -replace '^[^,]+,'}},@{n='CanonicalName';e={$_.properties['canonicalname']}},@{n='DN';e={$_.properties['distinguishedname']}}
$names | forEach-object{$_.name + "`n" + "=================="; get-wmiobject -computerName $_.name -class win32_product | where {$_.Name -eq "Microsoft SharePoint Server 2010 "}; "`n"; "`n"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment