0
我有VB.Net子例程,我試圖轉換爲Powershell。我對.Net並不是很好,所以我需要一些幫助,但是我找到了VB代碼的基礎並設法使其工作。我正在腳本化數據庫中的所有對象,並需要獲取角色的權限。這是VB代碼:VB.Net到Powershell幫助需要 - 枚舉數據庫角色權限
Public Sub ObjectPermissions(ByVal dbrname As String)
' dbrname = database role name
' this code will enumerate permissions on objects for a role - need to exclude fixed and public roles
Dim dbrp As ObjectPermissionInfo()
dbrp = db.EnumObjectPermissions(dbrname)
Dim opi As ObjectPermissionInfo
If db.Roles(dbrname).IsFixedRole = False And db.Roles(dbrname).Name <> "public" Then
For Each opi In dbrp
fs.WriteLine("GRANT " + opi.PermissionType.ToString + " ON [" + opi.ObjectSchema + "].[" + opi.ObjectName + "] TO [" + opi.Grantee + "]")
fs.Flush()
Next
End If
End Sub