Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASG RD 2019 PowerShell Error on shell launch
#1
Hi,

This message is a continuation of an earlier post regarding PowerShell errors occurring immediately upon the launch of the ASG-RD PowerShell console.

This is the error:

import-module : Could not load file or assembly 'CloudAdminAPI, Version=11.0.6104.1, Culture=neutral,
PublicKeyToken=8dc24a72506dc878' or one of its dependencies. The system cannot find the file specified.
At line:1 char:56
+ [reflection.assembly]::loadFrom('.\ASGRD-PSAPI.dll') | import-module
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Smile [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

The named DLL is indeed in the path: C:\Program Files\ASG-Remote Desktop 2019 (X64)

The .dll library in question has been re-registered on the Windows 10 Build 1803 system (fully patched).

I have tried launching the shell from a PS script that has all the pathing information hard-coded. That too does not work.

Error messages and application log content have been sent previously.

Please help to rectify this issue as there is an active project to automate credential retrieval from Thycotic PCS and it relies on PowerShell and REST API working through ASG-RD PowerShell.
Reply
#2
Could you please try to use the following script (listed in help file)


Code:
$workingdir = "Program Files\ASG-Remote Desktop 2018\"
Set-Location $workingdir
[Environment]::CurrentDirectory = Get-Location -PSProvider FileSystem
$path = $workingdir + "ASGRD-PSAPI.dll"
Add-Type -path $path
[reflection.assembly]::LoadFrom($path) | Import-Module

If that works try to connect to your environment


Code:
Connect-RDEnvironment -Environment Test -PassThrough
Regards/Gruss
Oliver
Reply
#3
(18-04-2019, 07:44 AM)DevOma Wrote: Could you please try to use the following script (listed in help file)


Code:
$workingdir = "Program Files\ASG-Remote Desktop 2018\"
Set-Location $workingdir
[Environment]::CurrentDirectory = Get-Location -PSProvider FileSystem
$path = $workingdir + "ASGRD-PSAPI.dll"
Add-Type -path $path
[reflection.assembly]::LoadFrom($path) | Import-Module

If that works try to connect to your environment


Code:
Connect-RDEnvironment -Environment Test -PassThrough
Reply
#4
This is the error that is received when running the code provided: NOTE: pathing information has been updated accordingly

Add-Type -path $path
[reflection.assembly]::LoadFrom($path) | Import-Module
Get-Location : A positional parameter cannot be found that accepts argument '$null'.
At line:3 char:35
+ ... Directory = Get-Location -PSProvider FileSystem $path = $workingdir + ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Smile [Get-Location], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetLocationCommand

Add-Type : Cannot bind argument to parameter 'Path' because it is null.
At line:4 char:16
+ Add-Type -path $path
+ ~~~~~
+ CategoryInfo : InvalidData: (Smile [Add-Type], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddTypeCommand

Exception calling "LoadFrom" with "1" argument(s): "String cannot have zero length."
At line:5 char:1
+ [reflection.assembly]::LoadFrom($path) | Import-Module
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Smile [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException

Ideas?
Reply
#5
The errors looks like that your $patch variable can't be set correctly - and then everything else will fail...

Try to set path variable and write output to console - if this is working you should go on with the script

I tried on 2 different computers and the script is working - be sure to use the right Powershell module - x86 or x64 - must be the same as you use ASGRD on your computer...
Regards/Gruss
Oliver
Reply
#6
Any progress on this issue? I need to resolve this quickly. It has been an issue going back to ASG RD 2018.
Reply
#7
I posted my answer yesterday - it works on different computers - try to run as Administrator (PowerShell) - use the right one (x86 / x64) - try to execute command by command (not in a script) and tell me the first error you get - I'm thinking it has something to do with setting the $path variable

And nothing has changed between version 2018 to 2019 for starting the PowerShell API...
Regards/Gruss
Oliver
Reply
#8
Hi Oliver,

You were right about the path issue. the command Add-Type -Path $path throws this error:

PS C:\Program Files\ASG-Remote Desktop 2019 (x64)> $workingDir = "C:\Program Files\ASG-Remote Desktop 2019 (x64)\"
PS C:\Program Files\ASG-Remote Desktop 2019 (x64)> Set-Location $workingDir
PS C:\Program Files\ASG-Remote Desktop 2019 (x64)> [Environment]::CurrentDirectory = Get-Location -PSProvider Filesystem
PS C:\Program Files\ASG-Remote Desktop 2019 (x64)> $path = $workingDir + "ASGRD-PSAPI.dll"
PS C:\Program Files\ASG-Remote Desktop 2019 (x64)> Add-Type -Path $path
Add-Type : Could not load file or assembly 'file:///C:\Program Files\ASG-Remote Desktop 2019 (x64)\ASGRD-PSAPI.dll' or
one of its dependencies. An attempt was made to load a program with an incorrect format.
At line:1 char:1
+ Add-Type -Path $path
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Smile [Add-Type], BadImageFormatException
    + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.AddTypeCommand

How to overcome this?
Reply
#9
Could you check if you are really running PowerShell x64?

Just try the command

[Environment]::Is64BitProcess

It should return True - or did you download the 32bit ASGRD setup and installed it to the x64 directory? You can easily see that in Task Manager...
Regards/Gruss
Oliver
Reply
#10
Hi,

Executing the [Environment]::Is64BitProcess command returned false. This now seems to start making sense as to why the PS module will not load. However, according to the icons in my Start folder, and what the system is reporting is installed, I have the x64 bit version of ASG installed.

See attachment.


Attached Files
.docx   ASG2019 Version Info - 26-04-2019.docx (Size: 61.43 KB / Downloads: 4)
Reply
#11
Hi,
I'm not a PowerShell expert, but are you sure you used the correct powershell version ? The environment should be 64bit if using the 64bit PSAPI.dll. Check the ASG-RD version in taskmanager - if it's 32bit you see that directly in the process name. Otherwise open the correct 64bit shell with the "powershell" command and do the check again - should return true. Then the initializing as above should work - just checked the 32bit version that works well.
best regards,
Michael
best regards,
Michael -- michael.scholz@asg.com --
Reply
#12
(29-04-2019, 01:15 PM)Michael Scholz Wrote: Hi,
I'm not a PowerShell expert, but are you sure you used the correct powershell version ?  The environment should be 64bit if using the 64bit PSAPI.dll. Check the ASG-RD version in taskmanager - if it's 32bit you see that directly in the process name. Otherwise open the correct 64bit shell with the "powershell" command and do the check again - should return true. Then the initializing as above should work - just checked the 32bit version that works well.
best regards,
Michael
Reply
#13
Hi,

After removing the 64-bit version of the ASG 2019 program and installing the 32-bit version, the ASG RD PowerShell prompt loads without any errors relating to importing the PSAPI.dll. However, the connect-rdenvironment refuses to connect to my environment.
Reply
#14
Any error message for that? Did you compare the Environment name used in PowerShell and in ASGRD? Case sensitive?
Regards/Gruss
Oliver
Reply
#15
Must have been a fluke that the console loaded without an error. Ever since then the original error listed in this thread continues to appear and the module does not load.

Attempting Connect-RDEnvironment did throw an error if I recall correctly. I cannot reproduce because of the original error. I was careful to use the same environment name in PS as in ASGRD. Tried surrounding the environment name in quotes as well. Neither worked.
Reply
#16
Again no error message for Connect-RDEnvironment command? You told me that you can load the API now - hope that still works - and now you can't connect to your environment using the console?

Could you try to setup a very small solution - by just creating a new file based environment (with Windows Account encryption, so you can login without any more parameters) - then try to connect first via console and then via the API - does that work? So many customers are using the API - and we can run it almost on every computer - so it must be something local on your system...
Regards/Gruss
Oliver
Reply
#17
After restarting my computer and launching the ASG RD PS console I still get the error trying to load the API. Even with the x86 version of ASG RD installed. The API loaded correctly exactly 1 time. Every other attempt it failed. The one time the API did load I tried to connect to the defined environment and that failed. However I can't even get the console to load the API again to repeat the process.

Please help me get the API issue resolved and then we can focus on the connect-rdenvironment issue.
Reply
#18
I launched the ASG RD PS console directly from my Start Menu, as opposed to the desktop icon I copied from the Start Menu folder, and the API loaded.

Attempting to connect to the environment directly from the console and using a small script as suggested I get the following errors. They appear to be the same

PS C:\> Connect-RDEnvironment -Environment "MyName" -PassThrough
Connect-RDEnvironment : Object reference not set to an instance of an object.
At line:1 char:1
+ Connect-RDEnvironment -Environment "MyName" -PassThrough
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Smile [Connect-RDEnvironment], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,CloudAdminPSModule.CmdLetEnvironment+RDBaseItemChildsGetCo
mmand

PS C:\> Connect-RDEnvironment -Environment MyName -PassThrough
Connect-RDEnvironment : Object reference not set to an instance of an object.
At line:1 char:1
+ Connect-RDEnvironment -Environment MyName -PassThrough
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Smile [Connect-RDEnvironment], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,CloudAdminPSModule.CmdLetEnvironment+RDBaseItemChildsGetCo
mmand

PS C:\> sl 'C:\users\hemiller\desktop\ASG Scripts\'
PS C:\users\hemiller\desktop\ASG Scripts> .\Connect-RDEnvironment.ps1
Connect-RDEnvironment : Object reference not set to an instance of an object.
At C:\users\hemiller\desktop\ASG Scripts\Connect-RDEnvironment.ps1:1 char:1
+ Connect-RDEnvironment -Environment MyName -PassThrough -Password ** ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Smile [Connect-RDEnvironment], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,CloudAdminPSModule.CmdLetEnvironment+RDBaseItemChildsGetCo
mmand
Reply
#19
We found an error on initializing in the Connect-CmdLet - we try to fix and will hopefully be able to provide a Patch this week. Sorry for the inconvenience
Regards/Gruss
Oliver
Reply
#20
 
(06-05-2019, 09:19 AM)DevOma Wrote: We found an error on initializing in the Connect-CmdLet - we try to fix and will hopefully be able to provide a Patch this week. Sorry for the inconvenience

Does this patch available in ASG Remote desktop 2020 or 2022 version? I am getting the same error.

Regards,
Vikram Rawat
Reply




Users browsing this thread: 1 Guest(s)