Go Back   CORTEX Forums > Local Happenings > CORTEX Blogs > Random Procrastination
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read

SSAS: Powershell to replace a group member in a role

This 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 ...


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 23rd June 2009, 08:30 PM   #1
Senior Member
 
Join Date: Jun 2009
Posts: 62
Darren Gosbell is on a distinguished road
Thumbs up SSAS: Powershell to replace a group member in a role

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...
Darren Gosbell is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiTweet this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +11. The time now is 02:23 AM.

© The Business Intelligence Group

Search Engine Optimization by vBSEO