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.

Revisions

  1. Brian J. McGuirk created this gist Aug 11, 2016.
    9 changes: 9 additions & 0 deletions find_sharepoint_sites.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # 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"}