Going to give an example to make it clearer what I want to do
$AzLogin = @{
Subscription = [string] 'SubscriptionID';
Tenant = [string] 'tenantID';
Credential = [System.Management.Automation.PSCredential] $credsServicePrincipal;
ServicePrincipal = $true;
}
try{
Connect-Azaccount @$AzLogin -errorAction Stop
}catch{
Write-Host "Error: $($_.exception)" -foregroundcolor red
}
This works correctly.
The one I want to do is pass splatted arguments stored in property 'CommonArgs' of object 'CSObject', something like this:
$CSObject =@ {
[PScustomObject]@{CommonArgs=$AzLogin;}
}
try{
Connect-Azaccount @CSObject.commonArgs -errorAction Stop
}catch{
Write-Host "Error: $($_.exception)" -foregroundcolor red
}