Upload a file as iFile using iControl - powershell

Is there a way to update the contents of an existing iFile? I didn't see any way to update the contents. So, I started looking at deleting and creating a file by uploading a local file to the BigIP using the iControl. I understand there are two objects to use - iFileFile and then iFile in that order.
Can somebody please provide usage for this? Below is what I started with and get the error below. What would be the correct parameters for iFileFile.create() if I have a file named random_key_file1 in the same location as the powershell script? After creating the iFileFile object, how do I use the same in the iFile.create().
Below links have documentation but lack the ussage examples : https://devcentral.f5.com/wiki/iControl.LocalLB__iFile__create.ashx https://devcentral.f5.com/wiki/iControl.LocalLB__iFileFile__create.ashx
Appreciate the help.
Add-PSSnapIn iControlSnapIn
$conn = Initialize-F5.iControl -HostName $hostName -Username $username -Password $password
if($conn) {
Try
{
Write-Output "Connected to load balancer - $hostName"
$ic = Get-F5.iControl
$iFileFileObjectNames = #("file1")
$filePaths = #("random_key_file1")
$ic.LocalLBiFileFile.create($iFileFileObjectNames,$filePaths)
Write-Output ("file created")
}
Catch
{
Write-Output($error[0]|format-list -force)
}
}
else
{
Write-Error "Connection to loadbalancer failed"
}
ERROR
Exception : System.Management.Automation.MethodInvocationException: Exception calling "create" with "2"
argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/iFileFile::create()
Common::InvalidArgument
" ---> System.Web.Services.Protocols.SoapHeaderException: Exception caught in
LocalLB::urn:iControl:LocalLB/iFileFile::create()
Common::InvalidArgument
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[]
parameters)
at CallSite.Target(Closure , CallSite , Object , Object , Object )
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
frame)
at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
at
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame)
TargetObject :
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : SoapHeaderException
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, D:\test.ps1: line 35
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails :
Answer this Question 0

Related

TFS task Run Power shell on remote machine Error: System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployer'

In my TFS 2018 CD, i have a task `Run PowerShell on remote Machine' and it failed with error as follows
System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployer
Find the task config as below
Find the complete error log as follows
2020-05-05T06:49:22.4862201Z Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information."
2020-05-05T06:49:22.4862692Z CategoryInfo :NotSpecified: (:) [], MethodInvocationException
2020-05-05T06:49:22.4862987Z FullyQualifiedErrorId :Exception
2020-05-05T06:49:22.4863348Z ---> System.Management.Automation.RemoteException: Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information."
2020-05-05T06:49:22.4863751Z --- End of inner exception stack trace ---
2020-05-05T06:49:22.4864154Z at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.PowershellExecutor.Invoke(String errorContextMessage, Boolean writeResultToLog, Boolean isCancellable)
2020-05-05T06:49:22.4864655Z at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.RemoteDeploymentHelper.InstallServiceInternal(String serviceSourcePath, String serviceName, String destinationFileName)
2020-05-05T06:49:22.4865266Z at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.RemoteDeploymentHelper.InstallService(String serviceSourcePath, String serviceName, String destinationFileName)
2020-05-05T06:49:22.4865783Z at Microsoft.VisualStudio.Services.DevTestLabs.Deployment.Deployment.DeploymentClient.<RunAsync>d__24.MoveNext()
2020-05-05T06:49:22.4866260Z ---> (Inner Exception #0) System.Management.Automation.RemoteException: Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information."<---
2020-05-05T06:49:22.4866523Z
2020-05-05T06:49:22.4866665Z
2020-05-05T06:49:22.5010643Z Deployment status for machine 'XXXXX:5985' : 'Failed'
2020-05-05T06:49:22.5565354Z ##[error], MethodInvocationException\r\n FullyQualifiedErrorId :Exception\r\n"}};]
2020-05-05T06:49:22.5588511Z
2020-05-05T06:49:22.5588871Z
2020-05-05T06:49:22.5951437Z ##[error]System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployerc87a55d0-555b-426c-b80f-1cf90ad0bf1c' from service executable path VisualStudioRemoteDeployer.exe . Consult the logs below:
2020-05-05T06:49:22.5952932Z Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information."
2020-05-05T06:49:22.5953641Z CategoryInfo :NotSpecified: (:) [], MethodInvocationException
2020-05-05T06:49:22.5954109Z FullyQualifiedErrorId :Exception
2020-05-05T06:49:22.5954536Z ---> System.Management.Automation.RuntimeException: Failed to install 'VisualStudioRemoteDeployerc87a55d0-555b-426c-b80f-1cf90ad0bf1c' from service executable path VisualStudioRemoteDeployer.exe . Consult the logs below:
2020-05-05T06:49:22.5955018Z Exception calling "SetRight" with "2" argument(s): "Could not obtain the user information."
2020-05-05T06:49:22.5955350Z CategoryInfo :NotSpecified: (:) [], MethodInvocationException
2020-05-05T06:49:22.5955636Z FullyQualifiedErrorId :Exception
2020-05-05T06:49:22.5955873Z
2020-05-05T06:49:22.5956133Z --- End of inner exception stack trace ---
2020-05-05T06:49:22.5956455Z at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
2020-05-05T06:49:22.5959512Z at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
2020-05-05T06:49:22.5959955Z at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
2020-05-05T06:49:22.5960388Z at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings)
2020-05-05T06:49:22.5960842Z at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings)
2020-05-05T06:49:22.5961295Z at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)
2020-05-05T06:49:22.6472008Z ##[error]LegacyVSTSPowerShellHost.exe completed with return code: -1.
This looks pretty related to this question. Root cause should be related to user access.
Ensure that user credentials provided in config has admin privileges over target machine and TFS. This would unblock the VisualStudioRemoteDeployer to run and eradicate SetRight" with "2" argument(s): "Could not obtain the user information issue.

Service Fabric - Deploy new version of app without code changes

is there a way in Service Fabric to deploy a new version of an app even though the code hasn't changed?
SF is constantly complaining about this whenever the devs rebuild the repo because something outside of the package changed but don't change the actual code of the app, and the version of the application gets bumped up by the build pipeline.
SF then says "you're trying to deploy a newer version of an application that already exists even though there are no code changes" and then fails.
Any way to change this behaviour?
Edit:
Here's a trace of the actual deployment error:
2018-11-07T06:07:23.1289545Z ##[debug]Processed: ##vso[telemetry.publish
area=TaskHub;feature=ServiceFabricDeploy]{"OperationId":"GetApplicationType","ExceptionData":"System.Management.Automation.MethodInvocationException;System.Management.Automation.RuntimeException;System.Management.Automation.RuntimeException;|D:\\a\\_tasks\\ServiceFabricDeploy_c6650aa0-185b-11e6-a47d-df93e7a34c64\\1.7.27\\ServiceFabricSDK\\Utilities.ps1|597","JobId":"ae65e85b-a04b-4de4-ac32-c9a821fba222","SDKVersion":"3.2.176.9494"}
2018-11-07T06:07:23.5491048Z ##[debug]Leaving D:\a\_tasks\ServiceFabricDeploy_c6650aa0-185b-11e6-a47d-df93e7a34c64\1.7.27\deploy.ps1.
2018-11-07T06:07:23.5537752Z ##[debug]Caught exception from task script.
2018-11-07T06:07:23.5570190Z ##[debug]Error record:
2018-11-07T06:07:23.6347435Z ##[debug]Invoke-ActionWithRetries : Exception calling "Invoke" with "1" argument(s): "Failed to register application type. Status: Failed. Details: FABRIC_E_IMAGEBUILDER_VALIDATION_ERROR: The content in CodePackage Name:Code and Version:1.0.0.18275.02 in Service Manifest 'App.ApiGateway.WebApiPkg' has changed, but the version number is the same.."
2018-11-07T06:07:23.6359357Z ##[debug]At D:\a\_tasks\ServiceFabricDeploy_c6650aa0-185b-11e6-a47d-df93e7a34c64\1.7.27\ServiceFabricSDK\Utilities.ps1:597 char:12
2018-11-07T06:07:23.6371643Z ##[debug]+ return Invoke-ActionWithRetries -Action $getAppTypeAction `
2018-11-07T06:07:23.6383668Z ##[debug]+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-11-07T06:07:23.6395763Z ##[debug] + CategoryInfo : NotSpecified: (:) [Invoke-ActionWithRetries], MethodInvocationException
2018-11-07T06:07:23.6408095Z ##[debug] + FullyQualifiedErrorId : RuntimeException,Invoke-ActionWithRetries
2018-11-07T06:07:23.6420176Z ##[debug]
2018-11-07T06:07:23.6439430Z ##[debug]Script stack trace:
2018-11-07T06:07:23.6475478Z ##[debug]at Invoke-ActionWithRetries, D:\a\_tasks\ServiceFabricDeploy_c6650aa0-185b-11e6-a47d-df93e7a34c64\1.7.27\ps_modules\PowershellHelpers\Helpers.ps1: line 61
2018-11-07T06:07:23.6487812Z ##[debug]at Wait-ServiceFabricApplicationTypeRegistrationStatus, D:\a\_tasks\ServiceFabricDeploy_c6650aa0-185b-11e6-a47d-df93e7a34c64\1.7.27\ServiceFabricSDK\Utilities.ps1: line 597
2018-11-07T06:07:23.6500061Z ##[debug]at Register-ServiceFabricApplicationTypeAction, D:\a\_tasks\ServiceFabricDeploy_c6650aa0-185b-11e6-a47d-df93e7a34c64\1.7.27\ServiceFabricSDK\Utilities.ps1: line 516
2018-11-07T06:07:23.6512541Z ##[debug]at Publish-NewServiceFabricApplication, D:\a\_tasks\ServiceFabricDeploy_c6650aa0-185b-11e6-a47d-df93e7a34c64\1.7.27\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1: line 296
2018-11-07T06:07:23.6524254Z ##[debug]at <ScriptBlock>, D:\a\_tasks\ServiceFabricDeploy_c6650aa0-185b-11e6-a47d-df93e7a34c64\1.7.27\deploy.ps1: line 194
2018-11-07T06:07:23.6536298Z ##[debug]at <ScriptBlock>, <No file>: line 1
2018-11-07T06:07:23.6548158Z ##[debug]at <ScriptBlock>, <No file>: line 22
2018-11-07T06:07:23.6559801Z ##[debug]at <ScriptBlock>, <No file>: line 18
2018-11-07T06:07:23.6572215Z ##[debug]at <ScriptBlock>, <No file>: line 1
2018-11-07T06:07:23.6591191Z ##[debug]Exception:
2018-11-07T06:07:23.6634400Z ##[debug]System.Management.Automation.MethodInvocationException: Exception calling "Invoke" with "1" argument(s): "Failed to register application type. Status: Failed. Details: FABRIC_E_IMAGEBUILDER_VALIDATION_ERROR: The content in CodePackage Name:Code and Version:1.0.0.18275.02 in Service Manifest 'App.ApiGateway.WebApiPkg' has changed, but the version number is the same.." ---> System.Management.Automation.RuntimeException: Failed to register application type. Status: Failed. Details: FABRIC_E_IMAGEBUILDER_VALIDATION_ERROR: The content in CodePackage Name:Code and Version:1.0.0.18275.02 in Service Manifest 'App.ApiGateway.WebApiPkg' has changed, but the version number is the same.. ---> System.Management.Automation.RuntimeException: Failed to register application type. Status: Failed. Details: FABRIC_E_IMAGEBUILDER_VALIDATION_ERROR: The content in CodePackage Name:Code and Version:1.0.0.18275.02 in Service Manifest 'App.ApiGateway.WebApiPkg' has changed, but the version number is the same..
2018-11-07T06:07:23.6646133Z ##[debug] --- End of inner exception stack trace ---
2018-11-07T06:07:23.6657929Z ##[debug] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2018-11-07T06:07:23.6670688Z ##[debug] at <ScriptBlock>(Closure , FunctionContext )
2018-11-07T06:07:23.6683139Z ##[debug] at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
2018-11-07T06:07:23.6694796Z ##[debug] at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
2018-11-07T06:07:23.6707020Z ##[debug] at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
2018-11-07T06:07:23.6719153Z ##[debug] at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
2018-11-07T06:07:23.6731325Z ##[debug] at System.Management.Automation.ScriptBlock.DoInvoke(Object dollarUnder, Object input, Object[] args)
2018-11-07T06:07:23.6742915Z ##[debug] at CallSite.Target(Closure , CallSite , ScriptBlock , Object )
2018-11-07T06:07:23.6754590Z ##[debug] --- End of inner exception stack trace ---
2018-11-07T06:07:23.6766838Z ##[debug] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2018-11-07T06:07:23.6778543Z ##[debug] at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2018-11-07T06:07:23.6791071Z ##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2018-11-07T06:07:23.6802711Z ##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2018-11-07T06:07:23.6814797Z ##[debug] at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
2018-11-07T06:07:23.6826406Z ##[debug] at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
2018-11-07T06:07:23.6838645Z ##[debug] at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
2018-11-07T06:07:23.6850253Z ##[debug] at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
2018-11-07T06:07:23.6862534Z ##[debug] at System.Management.Automation.CommandProcessorBase.Complete()
2018-11-07T06:07:23.6921240Z ##[error]Exception calling "Invoke" with "1" argument(s): "Failed to register application type. Status: Failed. Details: FABRIC_E_IMAGEBUILDER_VALIDATION_ERROR: The content in CodePackage Name:Code and Version:1.0.0.18275.02 in Service Manifest 'App.ApiGateway.WebApiPkg' has changed, but the version number is the same.."
In AzDo / VSTS the option "Use Diff Package" on the "Service Fabric Application Deployment" task is set.
This has been already answered here and here
You should make differencial packaging instead, or update the version of all services.
Answering the main question:
No, it's not possible to change this behaviour, you have to update the versions or do differential packaging.

Exception calling "Put" with "0" argument(s): "" on Win32_TerminalServiceSetting

I have created a Powershell function to enable or disable session logons remotely on a server. It is basically the Powershell equivalent of "change logon /enable".
It works on most machines, but for some reason I don't understand, for some it returns the following error :
Exception : System.Management.Automation.MethodInvocationException: Exception calling "Put" with "0" argument(s): "" ---> System.IO.FileNotFoundException
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Management.ManagementObject.Put(PutOptions options)
at System.Management.ManagementObject.Put()
at Put(Object , Object[] )
at System.Management.Automation.MethodInformation.Invoke(Object target, Object[] arguments)
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[]
originalArguments)
--- End of inner exception stack trace ---
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[]
originalArguments)
at System.Management.Automation.DotNetAdapter.MethodInvokeDotNet(String methodName, Object target, MethodInformation[] methodInformation,
PSMethodInvocationConstraints invocationConstraints, Object[] arguments)
at System.Management.Automation.DotNetAdapter.MethodInvoke(PSMethod method, PSMethodInvocationConstraints invocationConstraints, Object[] arguments)
at System.Management.Automation.Adapter.BaseMethodInvoke(PSMethod method, PSMethodInvocationConstraints invocationConstraints, Object[] arguments)
at System.Management.Automation.PSMethod.Invoke(PSMethodInvocationConstraints invocationConstraints, Object[] arguments)
at System.Management.Automation.PSMethod.Invoke(Object[] arguments)
at System.Management.Automation.Language.PSInvokeMemberBinder.InvokeAdaptedMember(Object obj, String methodName, Object[] args)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject :
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : DotNetMethodException
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
The error stack trace doesn't help me.
I'm running the same code with the same local admin user on all machines.
Here is the actual code snippet :
$TSConnector = Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace "root/cimv2/terminalservices" -Authentication PacketPrivacy
$TSConnector.Logons = 0
$TSConnector.Put()
Any idea ?
So it turns out that, on Windows Server 2008R2, if the Remote Desktop Session Host role is not installed, the server is configured for "Remote Desktop for Administration".
As explained on this technet article :
The following are limitations of Remote Desktop for Administration:
The default connection (RDP-Tcp) only allows a maximum of two simultaneous remote connections.
Licensing settings cannot be configured.
RD Connection Broker settings cannot be configured.
User logon mode cannot be configured.
So in the end I had to catch that exception and revert back to using change logon /disable in that particular case.
Kudos to #GrigorySergeev for pointing me in the right direction!

Retrieving session ID from COM method

I have a method named GoLogon in a COM object named BS.Logon which requires 5 parameters:
Username
Password
ApplicationID
XMLRoot
IPAddress
This method logins to the web server with the username, password, and other details, and returns the session ID.
I have written the Powershell script to call the method GoLogon as below.
$obj=New-Object -ComObject BS.Logon
$sessionid=$obj.GoLogon([ref]$bUsername,$bPassword,$appid,$xmlroot,[ref]$ipad)
Write-Host $sessionid
When the script is executed, the method makes successful login. I can see the session ID details in the database, but I am not able to get the session ID details through script. The variable $sessionid returns null. Also the script throws exception as
Exception calling "GoLogon" with "5" argument(s): "Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))"
At E:\Logon.ps1:18 char:1
+ $obj.Login([ref]$bUsername,$bPassword,$appid,$xmlroot,[ref]$ipad)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation`
The stacktrace is:
Exception : System.Management.Automation.MethodInvocationException: Exception calling "GoLogon" with "5" argument(s): "Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))" ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Management.Automation.ComMethod.InvokeMethod(PSMethod method, Object[] arguments)
--- End of inner exception stack trace ---
at System.Management.Automation.ComMethod.InvokeMethod(PSMethod method, Object[] arguments)
at System.Management.Automation.Adapter.BaseMethodInvoke(PSMethod method, PSMethodInvocationConstraints invocationConstraints, Object[] arguments)
at System.Dynamic.UpdateDelegates.UpdateAndExecute6[T0,T1,T2,T3,T4,T5,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
at System.Management.Automation.Interpreter.DynamicInstruction 7.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject :
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : ComMethodTargetInvocation
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, E:\Logon.ps1: line 18
PipelineIterationInfo : {}
PSMessageDetails :
Please suggest me how to get the session ID value from the method.
PowerShell seems to have a problem with COM parameters defined as VARIANT.
This is the case here, as the C++ signature of GoLogon suggests.
STDMETHODIMP CLOG::GOLogon(VARIANT *pvEmailId, BSTR bsPassword, BSTR bsIPAddress, BSTR bsSoloBuildVer, VARIANT *pvXML, BSTR *bsSessionId)
The answer suggested in this post "Invalid callee" calling a com object is to use a VariantWrapper.
In you case this should do the trick.
#define VariantWrapper for variables to be passesed as VARIANT
$wrapbUservame = New-Object Runtime.InteropServices.VariantWrapper($bUsername)
$wrappvXML = New-Object Runtime.InteropServices.VariantWrapper($pvXML)
#pass a [ref]VariantWrapper to .COM method
$sessionid=$obj.GoLogon([ref]$wrapbUservame,$bPassword,$appid,[ref]$wrappvXML,$ipad)

Powershell and BizTalk

I've tried the scripts which hugh posted here: PowerShell BizTalk scripts WITHOUT using BizTalk provider for PowerShell
It almost worked perfectly... Except for the Create-BTS-SendHandler-part...
I keep getting a strange error:
Exception calling "Invoke" with "2" argument(s): "Failed during call to one of administration components."
At line:22 char:23
+ $methodInfo.Invoke <<<< ($objSendHandler, $putOptions)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodTargetInvocation
$error[0]|Format-List -Force gives this:
System.Management.Automation.MethodInvocationException: Exception calling "Invoke" with "2" argument(s): "Failed during call to one of administration components." ---> System.Runtime.InteropServices.COMExcep tion (0xC0C02306): Failed during call to one of administration components.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Management.ManagementObject.Put(PutOptions options)
--- End of inner exception stack trace ---
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
at System.Management.Automation.DotNetAdapter.MethodInvokeDotNet(String methodName, Object target, MethodInformation[] methodInformation, Object[] arguments)
at System.Management.Automation.DotNetAdapter.MethodInvoke(PSMethod method, Object[] arguments)
at System.Management.Automation.Adapter.BaseMethodInvoke(PSMethod method, Object[] arguments)
at System.Management.Automation.PSMethod.Invoke(Object[] arguments)
at System.Management.Automation.ParserOps.CallMethod(Token token, Object target, String methodName, Object[] paramArray, Boolean callStatic, Object valueToSet)
at System.Management.Automation.MethodCallNode.InvokeMethod(Object target, Object[] arguments, Object value)
at System.Management.Automation.MethodCallNode.Execute(Array input, Pipe outputPipe, ExecutionContext context)
at System.Management.Automation.ParseTreeNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
TargetObject :
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : DotNetMethodTargetInvocation
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {}
PSMessageDetails :
I have tried to use both x86 and normal ISE to make sure it is not related to 32-bit. I've also checked that I have the rights to create Send-Handlers.
Any one who has an idea?
/Joakim
You need to use the proper names for BizTalk adapters, as specified in the
Platform Settings -> Adapters
list in BizTalk administrator. These are case sensitive.