Skip to content

How to Get a List of Sites With Unique Request Access Permissions in SharePoint 2007

by on May 28, 2014

STSADM files are located in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN

You must be a local Administrator on the server

  1. On the SharePoint server > open command prompt as an administratorimage
  2. Uncheck Run this program with restricted accessimage
  3. In command prompt window, Navigate to the folder containing STSADM.exe file (right click on command prompt to paste address) EX. cd “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN”
  4. image
  5. At command prompt:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null

#For SharePoint 2007 compatibility
function global:Get-SPSite($url){
    return new-Object Microsoft.SharePoint.SPSite($url)
}

#Get the web application
Write-Host "Enter the Web Application URL:"
$WebAppURL= Read-Host
$SiteColletion = Get-SPSite($WebAppURL)
$WebApp = $SiteColletion.WebApplication

# Get All site collections
foreach ($SPsite in $webApp.Sites)
{
  # get the collection of webs
  foreach($SPweb in $SPsite.AllWebs)
  {
    # if a site inherits permissions, then the Access request mail setting also will be inherited
    if (!$SPweb.HasUniquePerm)
    {
      Write-Host "Inheriting from Parent site"
    }
    else
    {
      #$SPweb.RequestAccessEnabled=$true
      $url = $site.url
      write-host $url
    }
  }
}

Set Path to Allow STSADM.exe commands from any prompt location

  1. Open command prompt
  2. Type in the following command: @set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH%
  3. You can now run the stsadm.exe commands from anywhere in the command prompt

Example of writing all messages to a file when executing stsadm commands for sharepoint 2007

stsadm -o addsolution -filename MySoln.wsp >output.txt 2>&1

this redirects Stderr (2) to Stdout (1) so both can write to the file

>output.txt 2>&1

Read More: http://blogs.msdn.com/b/markarend/archive/2007/11/08/scripting-stsadm-commands.aspx

Do a quick test of stsadm

stsadm.exe –help

stsadm.exe -o enumsites –url “http://server_name

You must be able to login to / access the database or will receive the error below.

Site Error=”cannot open database "wss_content_db_name" requested by the login. the login failed. Login failed for user ‘username’.”

Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: