powershell add send as full access permissions

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
techdriveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SubsunCommented:
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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SubsunCommented:
If you don't have any further queries, Please don't forget to close the question.. :-)
0
techdriveAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.