Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PS API | Orchestrator
#1
Has anyone been able to get the powershell to work with Microsoft Orchestrator? We automate our VM creating process and one of the steps we have been waiting to complete is creating an object in ASG for the new VM's created. No matter which way we try we keep getting errors.

Error
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Program Files (x86)\ASG-Remote Desktop 2016\ASGRD-PSAPI.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."

Script:
[reflection.assembly]::loadFrom( 'C:\Program Files (x86)\ASG-Remote Desktop 2016\ASGRD-PSAPI.dll' ) | import-module

Connect-RDEnvironment -Environment "ASG" -PassThrough

New-RDBaseItem -ParentItemId 097b0ae5-84f7-4561-a3f1-126d9e9ca15c -ItemType Connection -Text test98899 -Description "description"
Reply
#2
Try to set the working folder first - because the API needs to load some referenced dll's the working directory must be the same as the location of the installed dll's
Regards/Gruss
Oliver
Reply
#3
When I do a set-location to that path we get the same error. When i run from C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe, set the location and then import your module i get the following error.

PS C:\Program Files (x86)\ASG-Remote Desktop 2016> [reflection.assembly]::loadFrom( 'C:\Program Files (x86)\ASG-Remote Desktop 2016\ASGRD-PSAPI.dll' ) | import-module
PS C:\Program Files (x86)\ASG-Remote Desktop 2016> Connect-RDEnvironment -Environment asg
Connect-RDEnvironment : Object reference not set to an instance of an object.
At line:1 char:1
+ Connect-RDEnvironment -Environment asg
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Smile [Connect-RDEnvironment], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,CloudAdminPSModule.CmdLetEnvironment+RDBaseItemChildsGetCo
mmand
Reply
#4
Did you try to use the shortcut that is created on your Desktop? Is that working?
Regards/Gruss
Oliver
Reply
#5
Yes that works just fine.
Reply
#6
Ok, I think the "Set-Location" command is not really the same as setting the working dir for Powershell - if you use "Set-Location" and try to load the assembly without path it is not found - but if you set working folder when starting PowerShell you can do so...
Regards/Gruss
Oliver
Reply
#7
Perhaps we should read the "Powershell Location" and use this path to load referenced dll's... I will put this on the feature list...
Regards/Gruss
Oliver
Reply
#8
(20-06-2016, 02:57 PM)DevOma Wrote: Perhaps we should read the "Powershell Location" and use this path to load referenced dll's... I will put this on the feature list...

Is there any news on this ?

I can only get this to work using the ASG Powershell shortcut, which is not really helpful when trying to automate this stuff.

I have the same issue when trying to use the Powershell ISE Editor or using the module in an SMA Runbook.

Thanks !
Reply
#9
It's still on the todo list - we will check for the next release...
Regards/Gruss
Oliver
Reply
#10
Here is a working example that should help


$workingdir = "Program Files (x86)\ASG-Remote Desktop 2016\"

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 Test -PassThrough
Regards/Gruss
Oliver
Reply
#11
(13-03-2017, 10:10 AM)DevOma Wrote: Here is a working example that should help


$workingdir = "Program Files (x86)\ASG-Remote Desktop 2016\"

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 Test -PassThrough

Hi
Running this example code on ASG remote desktop 2018 (patch 3 - 11.0.5924.0) does not work for me. I get the following error:
Add-Type : Could not load file or assembly 'file:///C:\Program Files\ASG-Remote Desktop 2018 (X64)\ASGRD-PSAPI.dll' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
At D:\ASG\powershell\ASGremote.ps1:8 char:10
+  Add-Type <<<<  -path $path
    + CategoryInfo          : NotSpecified: (Smile [Add-Type], BadImageFormatException
    + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.AddTypeCommand
 
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Program Files\ASG-Remote Desktop 2018 (X64)\ASGR
D-PSAPI.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."
At D:\ASG\powershell\ASGremote.ps1:9 char:33
+  [reflection.assembly]::LoadFrom <<<< ($path) | Import-Module
    + CategoryInfo          : NotSpecified: (Smile [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
 
The term 'Connect-RDEnvironment' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of th
e name, or if a path was included, verify that the path is correct and try again.
At D:\ASG\powershell\ASGremote.ps1:11 char:23
+  Connect-RDEnvironment <<<<  -Environment Test -PassThrough
    + CategoryInfo          : ObjectNotFound: (Connect-RDEnvironment:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException





Any suggestions why so? I have run this through both the 64 bit and 32 bit session of powershell. same result for both.
Reply
#12
I found the following link - seems that your Powershell loads by default an older .NET version - current used .NET version is 4.6.2

https://tfl09.blogspot.de/2010/08/using-...-with.html
Regards/Gruss
Oliver
Reply
#13
(18-05-2018, 10:14 AM)DevOma Wrote: I found the following link - seems that your Powershell loads by default an older .NET version - current used .NET version is 4.6.2

https://tfl09.blogspot.de/2010/08/using-...-with.html

hmm, ok. Thanks for quick response
Which version is needed for this to work then.. in other words: which version (up to and including 4.7.2, which is newest today) is required for powershell functionality to work?

The reason for me asking is the response around the .net version needed for the patch 3 (11.0.5924.0 - for ASG remote desktop 2018 ), see attachment.

I am a bit confused now. is it 4.6.2, which is stated in the message I attach (seems not), or if this is not the case for powershell, please indicat the minimum version level required for powershell.

regards
Crybs


PS: I am running .net 4.6.2 on this server, as per specified by the patch notes.. and the asg remote desktop runs fine on this server...with official 4.6.2 release from microsoft.. what I am asking is if I need a newer version than this for some reason that I am missing. ASG remote desktop 2018patch3 is running fine...powershell via script is not.


Attached Files
.jpg   ASG-NETversioning.JPG (Size: 94.13 KB / Downloads: 1)
Reply
#14
We only reference the .NET 4.6.2 framework!!! So it should also work for Powershell - and I have never seen this type of error before - perhaps you can try on a different system? Or try to "update Powershell"? Sometimes Windows Server version are not up-to-date on all components...
Regards/Gruss
Oliver
Reply
#15
(18-05-2018, 01:27 PM)DevOma Wrote: We only reference the .NET 4.6.2 framework!!! So it should also work for Powershell - and I have never seen this type of error before - perhaps you can try on a different system? Or try to "update Powershell"? Sometimes Windows Server version are not up-to-date on all components...

I already tried on several servers, same result.
Am I to understand that when I verify that the .NET version framework version IS 4.6.2 (as per listed in the patch menu), you are confident this is not a .NET issue but something else?

Can you please tell me which (full) version of powershell you are using, and getting this to work on? this will give me some comparative basis to see if my powershell is "propperly updated".

What other Windows Server components are you needing me to check if "is updated", and to what version?
Windows does have a quite large set of components, so "Sometimes Windows Server versions are not up-to'date" is quite vague in this context.

Best regards
Crybs
Reply
#16
On my client (Win10) I have version 5.1 - but I can run the Powershell API on all my machines
Regards/Gruss
Oliver
Reply
#17
We are seeing the *exact* same issue as crybs. Was a solution ever identified? We are using the 2018 Patch 4 x64 version of ASG RD.
Reply




Users browsing this thread: 1 Guest(s)