powershell add send as full access permissions

techdrive
techdrive used Ask the Experts™
on
Guys thanks for your help so far. I got this code to check for existing permissions. If the permissions are not there looking for a snippet of code in powershell to add them

GC C:\Users.txt | %{
      New-object PSObject -Property @{
      User = $_
      SendAS =  [Bool](Get-MailboxPermission $_ | ?{$_.AccessRights -like "*FullAccess*" -and $_.User -like "NT AUTHORITY\SELF"})
      FullAccess = [Bool](Get-ADPermission $_ | ?{$_.ExtendedRights -like "*Send-As*" -and $_.User -like "NT AUTHORITY\SELF"})
      }
} | Export-Csv C:\report.csv -nti
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Infrastructure Architect
Commented:
Updated code for automatically fixing the full mailbox and send as permission with some reporting. Check and let me know if you have any question regarding the code..
GC C:\Users.txt | %{
$user = $_
If (!(Get-MailboxPermission $user | ?{$_.AccessRights -like "*FullAccess*" -and $_.User -like "NT AUTHORITY\SELF"})) {
Try{
	ADD-MailboxPermission -Identity $user -User 'NT AUTHORITY\SELF' -InheritanceType 'All' -AccessRights 'FullAccess' -EA STOP | Out-Null
	$FullAccess = $true
	$Ffixed = "Fixed"
}Catch{
	$FullAccess = $False
	$Ffixed = "Not Fixed"
}
}Else{
	$FullAccess = $true
	$Ffixed = "UnChanged"
}
If (!(Get-ADPermission $user | ?{$_.ExtendedRights -like "*Send-As*" -and $_.User -like "NT AUTHORITY\SELF"})){
	Try {ADD-ADPermission -Identity $user -User 'NT AUTHORITY\SELF' -ExtendedRights 'send-as' -EA STOP | Out-Null
	$SendAS = $True
	$Sfixed = "Fixed"
}
Catch{
	$SendAS = $false
	$Sfixed = "Not Fixed"
}
}Else{
	$SendAS = $True
	$Sfixed = "UnChanged"
}
	New-object PSObject -Property @{
	User = $User
	SendAS = $SendAS
	SendASFixed = $SFixed
	FullAccess = $FullAccess
	FullAccessFixed = $FFixed
	}
} | Select User,SendAS,SendASFixed,FullAccess,FullAccessFixed |Export-Csv C:\report.csv -nti

Open in new window

Subash SundharanIT Infrastructure Architect

Commented:
If you don't have any further queries, Please don't forget to close the question.. :-)

Author

Commented:
thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial