Using Add-RdsAccount in a function

%3CLINGO-SUB%20id%3D%22lingo-sub-1862083%22%20slang%3D%22en-US%22%3EUsing%20Add-RdsAccount%20in%20a%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1862083%22%20slang%3D%22en-US%22%3E%3CP%3EI%20want%20to%20use%20Add-RdsAccount%20in%20a%20function%20that's%20called%20by%20other%20scripts.%26nbsp%3B%20But%20for%20the%20life%20of%20me%2C%20I%20cannot%20make%20work.%26nbsp%3B%20The%20%22Add-RdsAccount%22%20call%20works%20and%20successfully%20authenticates%2C%20but%20*only*%20for%20the%20local%20scope.%26nbsp%3B%20I%20cannot%20get%20that%20authentication%20to%20persist%20within%20a%20script%20or%20globally.%26nbsp%3B%20Every%20single%20time%20I%20want%20to%20call%20a%20new%20function%20to%20perform%20some%20task%20with%20WVD%2C%20I%20have%20to%20call%20%22Add-RdsAccount%22%20directly%20from%20that%20function.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20never%20had%20this%20problem%20before.%26nbsp%3B%20I%20can%20authenticate%20to%20Azure%2C%20for%20example%2C%20and%20have%20that%20authentication%20persist%20script-wide%20or%20globally.%26nbsp%3B%20There's%20something%20peculiar%20about%20Micorsoft.RDInfra.Powershell%20that%20doesn't%20allow%20%22Add-RdsAccount%22%20to%20persist%20outside%20a%20local%20scope.%3CBR%20%2F%3E%3CBR%20%2F%3EHas%20anyone%20else%20come%20across%20this%20and%20found%20a%20solution%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

I want to use Add-RdsAccount in a function that's called by other scripts.  But for the life of me, I cannot make work.  The "Add-RdsAccount" call works and successfully authenticates, but *only* for the local scope.  I cannot get that authentication to persist within a script or globally.  Every single time I want to call a new function to perform some task with WVD, I have to call "Add-RdsAccount" directly from that function.

 

I've never had this problem before.  I can authenticate to Azure, for example, and have that authentication persist script-wide or globally.  There's something peculiar about Micorsoft.RDInfra.Powershell that doesn't allow "Add-RdsAccount" to persist outside a local scope.

Has anyone else come across this and found a solution?

0 Replies