| |
| ||||||
SSAS: Powershell to replace a group member in a roleThis is a discussion on SSAS: Powershell to replace a group member in a role within the Random Procrastination forums, part of the CORTEX Blogs category; There was a question in the SSAS forum recently on how to replace one group name with another within the membership of a number of SSAS roles in a number ... |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
| | #1 |
| Senior Member Join Date: Jun 2009
Posts: 62
![]() | There was a question in the SSAS forum recently on how to replace one group name with another within the membership of a number of SSAS roles in a number of databases. While you could possibly do this with XMLA it would be tricky as you have to re-submit the whole membership list, you can't just add/remove single members. The easiest way to do this is to write something using the AMO library and in my opinion the easiest way to write a script for AMO is using Powershell. Below is my short script which loops through all roles in all databases on the server and swaps out one group or user with another. I tried to make the script verbose and readable and I added some strings which are echoed out to the console so that you can see the roles and members that the script is iterating over. * [System.reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices" ) $svr = new-Object Microsoft.AnalysisServices.Server $svr.Connect("localhost\sql08") foreach ($db in $svr.Databases) { # Print the Database Name "Database: " + $db.Name foreach ($role in $db.Roles) * { *** $foundMember = $null *** # Print the Role Name *** "** Role: " + $role.Name*** #Print the *** foreach ($member in $role.Members) *** { **** # Print the member name(s) ***** "***** " + $member.Name ***** if ($member.Name -eq "domain_name\old_group_name") ***** { ******* $foundMember = $member ***** } *** } *** If ($foundMember -ne $null) *** { ***** "*** Member Found!" ***** $role.Members.Remove($foundMember) ***** $newRole = New-Object Microsoft.AnalysisServices.RoleMember("domain_name\new_group_name") ***** $role.Members.Add($newRole) ***** $role.Update() *** } * } } $svr.Disconnect() More... |
| | |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SSAS: Executing Arbitrary SQL queries | Darren Gosbell | Random Procrastination | 0 | 23rd June 2009 08:30 PM |
| Alliant Credit Union to boost decision making and provide enhanced member service wit | Latest News Headlines | SAS Forum | 0 | 19th May 2009 02:59 AM |
| User Group Meeting 22 May 2009 | Amendra | TM1 Australian User Group | 0 | 13th May 2009 05:30 PM |
| New Business Objects User Group | Doug Heywood | SAP and Business Objects Forum | 2 | 3rd February 2009 03:27 PM |
| Super role for Cognos BA | The_Best_Are_BI | People Wanted | 0 | 5th February 2008 02:48 PM |
| | |
| | |