Help with my PowerShell Form

Welcome Forums General PowerShell Q&A Help with my PowerShell Form

Viewing 6 reply threads
  • Author
    Posts
    • #246690
      Participant
      Topics: 1
      Replies: 3
      Points: 2
      Rank: Member

      I “created” a PowerShell form with several buttons that perform actions, I start out the script with “get-credential” and store it in a variable called $cred. The issue I am having is how to use the stored variable on the button. I would be glad if someone could provide assistance with this. Also the script below does not render when ran with PowerShell.exe it only runs when I run it from PowerShell_ISE.exe… Thank you in advance.

      [/crayon]

       

    • #246762
      Participant
      Topics: 8
      Replies: 568
      Points: 2,170
      Helping Hand
      Rank: Community Hero

      Hello Ogheneotsuko,

      First, you don’t want to run a form in a background job. The UI is the main thread intended for user interaction. This is likely why you are not seeing it in regular powershell. Powershell_ise.exe does some magic so always be sure to test in the real console.

      Second, if you are intending to use the credential on the start-process command, you’ll simply add the creds there. I’ve updated your script to remove the background job, create a small powershell script in $env:temp, and set Start-Process to run powershell.exe with the created script as an argument.

      Put in different valid credentials than the ones calling so you can see the output show you the credentials are passed along and being used.

      [/crayon]
    • #246891
      Participant
      Topics: 1
      Replies: 3
      Points: 2
      Rank: Member

      Thank you for the information so everything does render but the credentials stored in the $cred variable are not used. I need the entire form to open up with those credentials.

      All the individual buttons (8) require elevated privileges to access, so that is why I originally passed the credentials as part of a “job”.

       

      I thought of starting the small script in this fashion…

      $cred = Get-Credential
      Start-Process PowerShell.exe $env:temp\myscript.ps1 -Credential $cred

      My syntax is obviously incorrect (it fails miserably) but I think it carries the idea of what I am trying to accomplish.

    • #246894
      Participant
      Topics: 8
      Replies: 568
      Points: 2,170
      Helping Hand
      Rank: Community Hero

      So you’re trying to start the entire script with different credentials and then a third set of creds for the scripts the buttons invoke? May be a bit much for a forum. It seems like you’re on the right track so keep at it and come back if you hit another snag.

      Your syntax works fine. You should be able to start this script as you specified and then pass more credentials along. One correction, if it’s saved to $env:temp under the one user then it may not be accessible to the second user. Be sure to move it to a location that the users have access to. My apologies for overlooking that.

    • #246897
      Participant
      Topics: 1
      Replies: 3
      Points: 2
      Rank: Member

      No I simply want to start the main script with elevated privileges so two sets of credentials. The one am logged in on and the one to open the script. If you can provide the appropriate syntax I would be forever in your debt…

    • #246918
      Participant
      Topics: 0
      Replies: 1
      Points: 8
      Rank: Member

      Unlike most similar games, there is no gold in Path of Exile games. Instead, there are different Orbs, scrolls and POE Items. POE Currency has different purposes, including enhancing equipment, changing item modifiers, and forging new common, magic, rare and unique armor or weapons. Many currencies appear in the form of Orb, such as POE Exalted Orb and POE Chaos Orb. Other forms of currency include scrolls, coins, vials, and sextants.

      There are several ways to obtain currency in Path of Exile. Unfortunately, none of them are very fruitful, and it may take a while for them to find the valuables you are looking for, especially when they are rare. So what I recommend most is to buy products directly at IGGM. Their website has more than six years of operating experience and can provide in-game currency without putting your account at risk. At the same time, they provide safe transactions and convenient delivery methods.At https://www.iggm.com/poe-currency

    • #246927
      Participant
      Topics: 1
      Replies: 3
      Points: 2
      Rank: Member

      You sir solved my issues, I took your counsel and created a small script with the following line

       

      $cred = Get-Credential
      Start PowerShell.exe ‘\\myserver\myscript.ps1’ -Credential $cred

      And that works fine, I do have a follow on question that is purely cosmetic. The solution opens another powershell window with the words “GrowOnly” if there was a way to either hide the window or reduce its size while inserting the message “Do not close me” I would be content. But if this is the solution then it has to be the solution…

Viewing 6 reply threads
  • You must be logged in to reply to this topic.