I have a 3rd party app that up to now talked to quickbooks using a plug-in. That plug-in no longer works with the latest versions of the windows OS, so I am replacing it using PowerShell scripts. The plug-in would instanstiate the QBXMLRP.RequestProcessor com object then open a connection and begin a session with QuickBooks, process various requests from my app then close and disconnect the connection with quickbooks. While the connection is open, a ticket provided by QuickBooks is used to process any number of requests from my app.
Using PowerShell, I execute a command line prompt to "launch" PowerShell with a PowerShell .ps1 script file to run. As the plug-in did, the PS script instantiates the com object, opens a qb connection, begins a qb session, sends a qb Request, ends the qb session, closes the qb connection.
This works fine except that unlike with the plug-in I cannot send multiple requests from my app during a single open session with QuickBooks. Once I issue the command line prompt the PS script does it's thing and PS quits and the com object is lost. Is their anyway to preserve the live instance of the qb com object and reuse it in subsequent PowerShell sessions...
My app issues a command line prompt to run PowerShell that begins a qb session...
(.ps1 script)
$myqbxmrlp = New-Object -com QBXMLRP.RequestProcessor
$myqbxmrlp.OpenConnection(...)
$ticket = $myqbxmrlp.BeginSession(....)
$ticket | Export-CliXml $ticket (or set-content)
?? preserve the live $myqbxmrlp com object ??
My app issuse a command line call to open PS Session 2 send a request to qb...
(.ps1 script)
$myqbxmrlp = ?? get the live com object back ??
$ticket = Import-CliXml $ticket (or get-content)
$myqbxmrlp.ProcessRequest($ticket,....)
Command line call to open PS Session 3 with another request...
Command line call to open PS Session 4 with another request...
Command line call to open PS Session 5 and end the qb session and close the qb connection...
(.ps1 script)
$myqbxmrlp = ?? get the com object back ??
$ticket = Import-CliXml $ticket (or get-content)
myqbxmrlp.EndSession($ticket,....)
$myqbxmrlp.CloseConnection
Is there another way to approach this using powershell?