Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get-RDBaseItem : Object reference not set to an instance of an object.
#1
I'm facing an error when retrieving based on GUID.  However successful via ItemPath.


PS C:\Program Files\ASG-Remote Desktop 2018> Get-RDBaseItem -ItemId d000ddfa-8c92-4634-ad9d-a993b4fac68a
Get-RDBaseItem : Object reference not set to an instance of an object.
At line:1 char:1
+ Get-RDBaseItem -ItemId d000ddfa-8c92-4634-ad9d-a993b4fac68a
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Smile [Get-RDBaseItem], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,CloudAdminPSModule.CmdLetBaseItem+RDBaseItemGetCommand

PS C:\Program Files\ASG-Remote Desktop 2018>  Get-RDBaseItemId -ItemPath "Connections\TEST_VADE\ASP"

Guid
----
d000ddfa-8c92-4634-ad9d-a993b4fac68a


ASG version used : 14.0.7220.1
Reply
#2
I checked with latest version - and it runs successfully - you are using version 2018? Is the Guid correct?
Regards/Gruss
Oliver
Reply
#3
(22-03-2022, 01:14 PM)DevOma Wrote: I checked with latest version - and it runs successfully - you are using version 2018? Is the Guid correct?

I use "C:\Program Files\ASG-Remote Desktop 2018"

The GUID is correct as the second command : Get-RDBaseItemId -ItemPath  is listing the GUID


ASG version used : 14.0.7220.1
Reply
#4
File or database mode? Could you try any other items? Just open Properties of any object and you can copy and paste the GUID of the object
Regards/Gruss
Oliver
Reply
#5
(22-03-2022, 01:29 PM)DevOma Wrote: File or database mode? Could you try any other items? Just open Properties of any object and you can copy and paste the GUID of the object

Our ASG Remote Desktop data is stored in a Sql Server database.

Another example based on a object  at random:

PS C:\Program Files\ASG-Remote Desktop 2018>  Get-RDBaseItemId -ItemPath "Connections\DB\ORA\milesoradb1"

Guid
----
87bc2f32-a795-4310-aa8f-3a6645e18a18


PS C:\Program Files\ASG-Remote Desktop 2018>  Get-RDBaseItem -ItemId  87bc2f32-a795-4310-aa8f-3a6645e18a18
Get-RDBaseItem : Object reference not set to an instance of an object.
At line:1 char:2
+  Get-RDBaseItem -ItemId  87bc2f32-a795-4310-aa8f-3a6645e18a18
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Smile [Get-RDBaseItem], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,CloudAdminPSModule.CmdLetBaseItem+RDBaseItemGetCommand
Reply
#6
(22-03-2022, 01:29 PM)DevOma Wrote: File or database mode? Could you try any other items? Just open Properties of any object and you can copy and paste the GUID of the object

I'm wondering if my $workingdir = "C:\Program Files\ASG-Remote Desktop 2018" should still be used.

I also have "C:\Program Files\ASG-Remote Desktop 2021 (X64)" and be aware of the version of ASG-RD we are using, which is, if I'm correct a 64 bit version.

I think the 2018 folder is holding 64 bit software, but no idea if its compatible ?
(besides, if I use the ASGRD.exe from the 2018 folder, I can not connect to the existing environment.)
Reply
#7
That was why I asked you if you are using version 2018?

You need to ensure that if you have installed 2021 x64 that you are also running Powershell in x64 mode - and you should try to set the working dir to the latest version - I guess that's the problem...
Regards/Gruss
Oliver
Reply
#8
(22-03-2022, 02:31 PM)DevOma Wrote: That was why I asked you if you are using version 2018?

You need to ensure that if you have installed 2021 x64 that you are also running Powershell in x64 mode - and you should try to set the working dir to the latest version - I guess that's the problem...

Okay, I re-tried by setting my workingdir = "C:\Program Files\ASG-Remote Desktop 2021 (X64)", however, no struggling with the Add-Type -path $path

PS C:\Temp> if ([Environment]::Is64BitProcess -eq [Environment]::Is64BitOperatingSystem)
>> {
>> "PowerShell process does run 64 bit binaries. Which is needed as ASGRD is alos 64 bit"
>> }
PowerShell process does run 64 bit binaries. Which is needed as ASGRD is alos 64 bit
PS C:\Temp> $workingdir = "C:\Program Files\ASG-Remote Desktop 2021 (X64)"
PS C:\Temp>  Set-Location $workingdir
PS C:\Program Files\ASG-Remote Desktop 2021 (X64)> [Environment]::CurrentDirectory = Get-Location -PSProvider FileSystem
PS C:\Program Files\ASG-Remote Desktop 2021 (X64)>
PS C:\Program Files\ASG-Remote Desktop 2021 (X64)> $path = $workingdir + "\" + "ASGRD-PSAPI.dll"
PS C:\Program Files\ASG-Remote Desktop 2021 (X64)>  Add-Type -path $path
Add-Type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
At line:1 char:2
+  Add-Type -path $path
+  ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Smile [Add-Type], ReflectionTypeLoadException
    + FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

PS C:\Program Files\ASG-Remote Desktop 2021 (X64)>




-------------------------  The ps script
if ([Environment]::Is64BitProcess -eq [Environment]::Is64BitOperatingSystem)
{
"PowerShell process does run 64 bit binaries. Which is needed as ASGRD is alos 64 bit"
}

$workingdir = "C:\Program Files\ASG-Remote Desktop 2021 (X64)"
Set-Location $workingdir
[Environment]::CurrentDirectory = Get-Location -PSProvider FileSystem

$path = $workingdir + "\" + "ASGRD-PSAPI.dll"


Add-Type -path $path

[reflection.assembly]::LoadFrom($path) | Import-Module

# neglect the warning: WARNING: Environment could not be connected.
Connect-RDEnvironment -Environment ASGRD -PassThrough


Write-Host "Connected to ASGRD ?"
Get-RDEnvironmentConnected
Reply
#9
And some evidence about the existence of the dll file:

PS C:\Program Files\ASG-Remote Desktop 2021 (X64)> $path
C:\Program Files\ASG-Remote Desktop 2021 (X64)\ASGRD-PSAPI.dll
PS C:\Program Files\ASG-Remote Desktop 2021 (X64)> dir $path


Directory: C:\Program Files\ASG-Remote Desktop 2021 (X64)


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 8/19/2021 12:17 AM 46592 ASGRD-PSAPI.dll
Reply
#10
PS C:\Program Files\ASG-Remote Desktop 2021 (X64)> [reflection.assembly]::LoadFrom($path) | Import-Module
Import-Module : Could not load file or assembly 'CloudAdminAPI, Version=14.0.7170.1, Culture=neutral, PublicKeyToken=8dc24a72506dc878' or one of its dependencies. The system cannot find the file specified.
At line:1 char:43
+ [reflection.assembly]::LoadFrom($path) | Import-Module
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Smile [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
Reply
#11
It seems to search for another version ??

Remember, my ASG-RD version : 14.0.7220.1 (as to the help/about)
Reply
#12
S C:\Program Files\ASG-Remote Desktop 2021 (X64)> dir cloudadminapi.dll


Directory: C:\Program Files\ASG-Remote Desktop 2021 (X64)


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 10/8/2021 8:47 AM 68608 cloudadminapi.dll
Reply
#13
Really strange - did you restart your machine to be sure nothing is cached in Powershell?!?

I run the following script - point to the same object and both are returned successfully - ensure in your working dir, that PS-API-dll and other dll's have the same version number


Code:
$workingdir = "C:\Program Files\ASG-Remote Desktop 2021 (X64)\"

Set-Location $workingdir
[Environment]::CurrentDirectory = Get-Location -PSProvider FileSystem

$path = $workingdir + "ASGRD-PSAPI.dll"

Add-Type -path $path
[reflection.assembly]::LoadFrom($path) | Import-Module

Connect-RDEnvironment -Environment TestOmaLocal1 -PassThrough

Get-RDBaseItemId -ItemPath Connections\AZURE\aaa

Get-RDBaseItem -ItemId 15975f93-0d16-45d5-913b-bb2bcab153c3
Regards/Gruss
Oliver
Reply
#14
Hi,

Well, they don't have the same version.
ASGRD-PSAPI.dll has version 14.0.7170.1
cloudadminapi.dll has version 14.0.7220.1

how to fix this ?
Reply
#15
I don't know why - but just install your latest version again - it should override all files with the correct version
Regards/Gruss
Oliver
Reply
#16
Uninstall and reinstall did solve the issue.

PS C:\Program Files\ASG-Remote Desktop 2021 (X64)> Get-RDBaseItem -ItemId d000ddfa-8c92-4634-ad9d-a993b4fac68a


ItemId : d000ddfa-8c92-4634-ad9d-a993b4fac68a
ParentItemId : b49704c3-6c95-4928-b2fa-0e72f1a94f3d
UserId : 00000000-0000-0000-0000-000000000000
ItemTypeId : 09edda48-3dd6-42d6-861c-9d34ed72497d
ItemType : Folder
ImageId : d00a394f-d3e9-4349-8277-ea68de7c57ab
Text : ASP
Description :
Sort : True
Sequence : 0
Private : False
ExternalId :
Reply
#17
Thanks for your support
Reply




Users browsing this thread: 1 Guest(s)