Results 1 to 4 of 4

Thread: Is it possible to return the results of a poweshell command from an rsp page?

  1. #1
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,242

    Is it possible to return the results of a poweshell command from an rsp page?

    Hi,

    I recently had a request to serve up results of a powershell command from an rsp page.
    I wasn't sure it its possible, so I thought I would ask if anyone had tried.

    First request is just a simple list of all services on a given server.

    Code:
    PowerShell.exe  Get-Service -ComputerName myserver
    Thanks.

    Herb

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,097
    Hi Herb,

    on way is to instantiate the PowerShell object as a .Net object -- check out Doug Hennigs article on using PowerShell in VFP, p.33: http://doughennig.com/papers/Pub/PowerShell.pdf.I don't know if wwDotNetBridge, which it uses, will work in Lianja, but there's a good chance it will. If it does, this would give you the opportunity to make a dynamic application with a list of the scripts or cmdlets or whatever.

    The alternative is to run with the run command in Lianja (in a VFP code section of the .rsp) and generate a log file output and use that to display or parse/display.

    Hank

  3. #3
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,242
    Hi Hank,

    My thought was something along the lines of

    Run "PowerShell.exe Get-Service | Export-Csv c:\psoutput\test.csv"
    - which works in the desktop.

    But I recall Barry telling us to create tempfile for rsp pages.


    Like in the image example:
    // Look up an employee
    seek "Smith"

    // Create a unique temporary name (guaranteed uniqueness across concurrent users in a network)
    m_tmpnam = tmpnam()

    // Extract the photo from the database and write it to the temporary file
    objectWrite(m_tmpnam,photo)

    // Generate the base64 encoded contents as an IMG tag and output into the HTML5
    base64_encode_file(m_tmpnam, objectType(photo), "100px", "100px")

    // Don't forget to remove the temporary file
    erase &m_tmpnam

    So - I'm thinking if I want to use an RSP page, I probably need to output the file to m_tmpnam.
    But I will play around with it.

    Thanks.

    Herb

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,350
    Hi Herb,

    Yes because multiple requests can be running concurrently.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us