Hi,
I have been looking at at a problem which I am sure someone will know the answer to,
A customer of ours has created a GUI with PS 2012, they have added a .ps1 file to the project.
I guess when they package to exe the .ps1 file will also be included?
One of the requirements is that when a button is clicked within the .exe it saves the .ps1 added to the project to the local disk - is this possible?
Reason why this is a requirement is that the PS1 file contains alot of reporting functionality which they do not want to break up or change, basically all they want to do is have a copy of the ps1 file saved locally if the button is clicked. The end user will then be able to use that PS1 file manually
I hope I have explained this correctly
GUI save embedded ps1 file to disk
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- SAPIEN Support Forums
- Posts: 945
- Last visit: Thu Oct 22, 2015 1:10 pm
GUI save embedded ps1 file to disk
This is an automated post. A real person will respond soon.
Thank you for posting, jimbobukii.
Here are some hints to help you get an accurate and complete answer to your question.
Ask in the best forum:
Anticipate follow-up questions!
Did you remember to include the following?
*** Make sure you do not post any licensing information ***
Thank you for posting, jimbobukii.
Here are some hints to help you get an accurate and complete answer to your question.
Ask in the best forum:
- - Scripting question? For questions about Windows PowerShell or other scripting languages, use Scripting Answers.
- Software question? For questions about PowerShell Studio, PrimalScript, or other SAPIEN products, use Product Support Forums for Registered Customers.
- Trial question? For questions about trial versions of any SAPIEN product, use Trial Software Questions.
Anticipate follow-up questions!
Did you remember to include the following?
- 1. Product, version and build
2. 32 or 64 bit product
3. Operating system, e.g. Windows 7 64 bit.
4. Attach a screenshot, if applicable
5. Attach logs, crash reports, etc., in a ZIP file
*** Make sure you do not post any licensing information ***
- jimbobukii
- Posts: 52
- Last visit: Mon Dec 04, 2017 9:59 am
Re: GUI save embedded ps1 file to disk
Thank you for the response.jvierra wrote:In a project add it as a txt file resource and open and save it as a ps1 file in the button.
Would you kindly advise of the command?
- jimbobukii
- Posts: 52
- Last visit: Mon Dec 04, 2017 9:59 am
Re: GUI save embedded ps1 file to disk
I used the following which seemed to work
$file = Get-Content .\PS1inTextFileFormat.txt
$file | Out-File c:\testout.ps1
is this correct way to do it?
Thanks in advance
$file = Get-Content .\PS1inTextFileFormat.txt
$file | Out-File c:\testout.ps1
is this correct way to do it?
Thanks in advance
- jimbobukii
- Posts: 52
- Last visit: Mon Dec 04, 2017 9:59 am
Re: GUI save embedded ps1 file to disk
works with
Get-Content .\PS1inTextFileFormat.txt | Out-File c:\testout.ps1 -force
I guess this would be better
Get-Content .\PS1inTextFileFormat.txt | Out-File c:\testout.ps1 -force
I guess this would be better
- jimbobukii
- Posts: 52
- Last visit: Mon Dec 04, 2017 9:59 am
Re: GUI save embedded ps1 file to disk
You can also just store a short script internally as a strong
PowerShell Code
Double-click the code block to select all.$ps1=@' .... lines of script '@ $ps1|Out-File myscript.ps1