research Question

Function of Pauses in a PS Start Script

Avatar of hypercube
hypercubeFlag for United States of America asked on
PowershellWindows Batch* Script Task
9 Comments1 Solution26 ViewsLast Modified:
I wrote this long ago and am trying to maintain it now.  While this seems rather obvious, I'm sure that it isn't:
# Start_Script_08.ps1
#Has been run for this script: Set-ExecutionPolicy Unrestricted
# Copies WMI_08.ps1 into Env:
Copy "\\fileserver\Scanner\0 AA Scanner\Scripts\WMI_08.ps1" "$($Env:Temp)"
pause
Import-Module "$($Env:Temp)\WMI_08.ps1"
pause
So, why would those pauses be there?  If I comment them out the process never seems to run.
The objective here is to run a script (WMI_08.ps1) on a workstation where the script resides on a file server.
The process flow here is:
- Run a .bat file, residing on the file server, as administrator: WMI_08.bat
This runs a Powershell executionpolicy bypass command for the Start_Script_08.ps1
- The .bat file launches Start_Script_08.ps1 which also resides on the file server.
- This copies the main script WMI_08.ps1 onto the workstation into Env and runs it.
The script can be manually copied onto a workstation and run.
But, the idea is to avoid manual operations by executing the preliminary scripts as above.

For now, I'd be happy to know what those pauses do and don't do.
Questions like: Should one or both be commented out?  That seems to not work.


ASKER CERTIFIED SOLUTION
ste5an
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros