I am trying to add a member to server administrator role using PowerShell. I am able to add a role and member to each individual database available, but I would like to add it to the top level so that the given user can access the database.
This is what my current code, but I get the error:
Exception calling "Add" with "1" argument(s): "Collection was of a fixed size." At D:\Untitled8.ps1:15 char:1 + $targetsvr.Roles.Members.Add($syncAccount) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : NotSupportedException
Function Add-NewMember
{
[CmdletBinding()]
param(
[Parameter(Position=0,mandatory=$true)]
[string] $ssasInstance,
[Parameter(Position=1,mandatory=$true)]
[string] $syncAccount ="NT Service\SQLSERVERAGENT")
[void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$targetsvr = new-Object Microsoft.AnalysisServices.Server
$targetsvr.Connect($ssasInstance)
$targetsvr.Roles.Members.Add($syncAccount)
}
Add-NewMember -ssasInstance "localhost" -syncAccount "NT SERVICE\SQLSERVERAGENT"

Add-Memberis going to collide with Powershell's own functionality too? - vonPryz