PoshCode Logo PowerShell Code Repository

Get-DLRestriction by Dmitry Sotnikov 20 months ago
View followups from Dmitry Sotnikov | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1883"></script>download | new post

Uses QAD cmdlets to retrieve distribution list restriction attributes and then provides a list of users which can send email messages to the group.
Usage: Get-DLRestriction “Worldwide Everyone”

  1. ###########################################
  2. # Get-DLRestriction
  3. #
  4. # Uses QAD cmdlets to retrieve distribution list restriction attributes
  5. # and then provides a list of users which can send email messages to the group.
  6. #
  7. # Usage: Get-DLRestriction "Worldwide Everyone"
  8. #
  9. # Dmitry Sotnikov, http://dmitrysotnikov.wordpress.com
  10. ############################################
  11.  
  12. function Get-DLRestriction {
  13.         param([System.String]   $DLName )
  14.  
  15.   "Checking restrictions for $DLName"
  16.  
  17.   $DL = Get-QADGroup $DLName `
  18.       -IncludedProperties AuthOrig, UnauthOrig, dLMemRejectPerms,`
  19.                       dLMemSubmitPerms, msExchRequireAuthToSendTo
  20.  
  21.   # we'll set this to true if we see a restriction
  22.   $restricted = $false
  23.  
  24.   # if the group with such a name is found
  25.   if ( $DL -ne $null ) {
  26.    
  27.     if ( $DL.AuthOrig -ne $null ) {
  28.       $restricted = $true
  29.       "`n The following users can send messages to this list:"
  30.       $DL.AuthOrig | Get-QADUser
  31.     }
  32.    
  33.     if ( $DL.UnauthOrig -ne $null ) {
  34.       $restricted = $true
  35.       "`n Anyone BUT the following users can send messages to this list:"
  36.       $DL.UnauthOrig | Get-QADUser
  37.     }
  38.    
  39.     if ( $DL.dLMemSubmitPerms -ne $null ) {
  40.       $restricted = $true
  41.       "n` Members of this group can send messages to this list: $($DL.dLMemSubmitPerms | Get-QADGroup).Name) :"
  42.       Get-QADGroupMember $DL.dLMemSubmitPerms
  43.     }
  44.    
  45.     if ( $DL.dLMemRejectPerms -ne $null ) {
  46.       $restricted = $true
  47.       "`n Anyone BUT members of this group can send messages to this list: $($DL.dLMemRejectPerms | Get-QADGroup).Name) :"
  48.       Get-QADGroupMember $DL.dLMemRejectPerms
  49.     }
  50.    
  51.     if ( $DL.msExchRequireAuthToSendTo ) {
  52.       $restricted = $true
  53.       "`n Only authenticated users can send messages to this list.`nExternal senders get blocked."
  54.     }
  55.    
  56.     if ( -not $restricted ) {
  57.       "`n This list is not restricted. Anyone can email it."
  58.     }
  59.   } else {
  60.     "`n DL $DLName not found."
  61.   }
  62. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me