SQL Server AS: Set ImpersonationMode via PS Try to create a database in SQL Server Analysis Server (SQLAS, SSAS) version 2012 SP2 if that matters and set Impersonation Mode via Powershell. (try to avoid XMLA script).

Here are my attempts. Does anybody have the right command handy?

Simple create

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$DBASserver = New-Object Microsoft.AnalysisServices.Server
$DBASserver.connect("mysqldbserver.dom.com")

$database=$DBASserver.databases
$database|select-object name, id

$DBASserver.databases.add("Finance")

$db = $DBASserver.databases.item("Finance")
$db.update()
$db.description = "Finance Department Data Mart"
$db.update()


Getting info on the current mode: (works)

$db = $DBASserver.databases.item("Finance")
$dbmode = $db.DataSourceImpersonationInfo
$dbmode


Update: Setting the mode by getting it from another db works. But creating the Mode object new doesn't 
Here working by reading mode from another DB

$db1 = $DBASserver.databases.item("MyDBManualSet")
$db2 = $DBASserver.databases.item("MyNewPSDB")
$dbmode = $db1.DataSourceImpersonationInfo
$dbmode
$db2.DataSourceImpersonationInfo = $dbmode
$db2.update()


Here my attempts to set the mode ImpersonationMode to ImpersonateServiceAccount (nothing works)

$newMode.ImpersonationInfo = new ImpersonationInfo(ImpersonationMode.ImpersonateServiceAccount)
$db2.DataSourceImpersonationInfo = $newMode


or

$newMode= new ImpersonationInfo(ImpersonationMode.ImpersonateServiceAccount)
$db2.DataSourceImpersonationInfo = $newMode


here the documentation I can't piece together  MSDN SQL documentation info
Got it working:

$ImpInfo=New-Object Microsoft.AnalysisServices.ImpersonationInfo
$ImpInfo.ImpersonationMode = 'ImpersonateServiceAccount'

$db.DataSourceImpersonationInfo = $ImpInfo
$db.update()


here a full working PowerShell (PS) example

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$DBASserver = New-Object Microsoft.AnalysisServices.Server
$DBASserver.connect("mysqldbserver.dom.com")

$database=$DBASserver.databases
$database|select-object name, id

$DBASserver.databases.add("Finance5")

$db = $DBASserver.databases.item("Finance5")
$db.update()
$db.description = "Finance Test 5"
$db.update()

$db = $DBASserver.databases.item("Finance5")
$dbmode = $db.DataSourceImpersonationInfo
$dbmode #This doesn't post info, maybe a refresh issue. 

$ImpInfo=New-Object Microsoft.AnalysisServices.ImpersonationInfo
$ImpInfo.ImpersonationMode = 'ImpersonateServiceAccount'

$db.DataSourceImpersonationInfo = $ImpInfo
$db.update()
$db.description = "Finance Test 5 now changed ImpersonationInfo"
$db.update()
$dbmode = $db.DataSourceImpersonationInfo
$dbmode