0

I have created a few powershells scripts that work from a variables.ps1. This variables needs to be changed for every install. The script starts by running a simple COPYOUT.PS1. This PS1 copies from an ISO file and places the files on the C:\PSscript. Once all the files are on the system it opens the variables.ps1. This is when I can edit the PS1 and save it.

The issue is that I am not able to save it once it is open. This script needs to be the same name, because I copy the variables.ps1 to other servers that use it to install other software programs. Once I close the variables.ps1 it needs to finish the COPYOUT.PS1 by sending the updated variables.ps1 to the remote servers.

NOTEPAD "C:\PSscript\variables.ps1" | OUT-NULL

What can I do to get around this?

I have looked into:

(Start-Process notepad "C:\PSscript\variables.ps1" -PassThru).WaitForExit() 

Hope that makes sense. Thank for you help.

Zach Olinske
  • 517
  • 2
  • 14
  • Let me see if I get this straight. So you edit the file in notepad while it is open... then close it and want the script to finish? – Matt Mar 22 '16 at 15:26
  • 1
    How about parameterizing the variables that change from time to time instead? – Mathias R. Jessen Mar 22 '16 at 15:47
  • `(Start-Process notepad "C:\PSscript\variables.ps1" -PassThru).WaitForExit() ` works just fine if i understand your intention correctly, an alternative would be to use the `-wait` parameter of start-process, does the same thing though – Paul Mar 22 '16 at 16:43
  • The issue is when the file is open it is not allowing me to save back to that file. Maybe I need to set the attributes different. The Variables.PS1 goes to multiple scripts that look at the variables.ps1. Sounds like I am on the correct path with using the Start-Process and the -wait command. I will have to look into the param function. – Zach Olinske Mar 24 '16 at 01:09

0 Answers0