File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,29 @@ function Export-DbaLogin {
313313 $credentialName = $credential.Name
314314 $outsql += " PRINT '$userName is associated with the $credentialName credential'"
315315 }
316+
317+ # Endpoint permissions
318+ foreach ($endpoint in $server.endpoints ) {
319+ $perms = $endpoint.EnumObjectPermissions ($userName )
320+
321+ foreach ($perm in $perms ) {
322+ $permState = $perm.permissionstate
323+ $permType = $perm.PermissionType
324+ $grantor = $perm.grantor
325+
326+ if ($permState -eq " GrantWithGrant" ) {
327+ $grantWithGrant = " WITH GRANT OPTION"
328+ $permState = " GRANT"
329+ }
330+ else {
331+ $grantWithGrant = $null
332+ }
333+
334+ $outsql += " $permState $permType ON ENDPOINT::[$ ( $endpoint.Name ) ] TO [$userName ] $grantWithGrant AS [$grantor ]"
335+ }
336+
337+
338+ }
316339 }
317340
318341 if ($NoDatabases -eq $false ) {
You can’t perform that action at this time.
0 commit comments