• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 131
  • Last Modified:

Pre-backup command, powershell will not exit from memory after script is finished

Hi,

In my backup program I want to run a pre-backup command that does a backup of my sharepoint site collection. The pre-command runs fine. However, powershell stays in memory after the script is finished.

Because of that, my backup program does not know that it is finished, and will not continue. (If I kill powershell.exe with task manager, the backup continues).

I use the following command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NonInteractive -File "C:\backupAllSiteCollections.ps1"

The scipt is this one: https://gallery.technet.microsoft.com/scriptcenter/Backup-all-collections-in-726514cb


If don't want to run the script with the task scheduler (which works fine for the script), because if I use my backup program, I can track errors in the script.

I also have tried as a pre-backup command: schtasks /Run /TN "task name". This does start the task, but does not wait for it to finish.

Does anyone know how I can start the script as a pre-backup command, so that when it is finished, powershell.exe is unloaded from memory (exits)?

Thank you,
Raymond
0
Raymond Jansen
Asked:
Raymond Jansen
  • 2
  • 2
1 Solution
 
MaheshArchitectCommented:
Try below.
At the end of script type exit on new line

This should force server to close PowerShell from memory and continue backup software
0
 
Raymond JansenAuthor Commented:
Hi,

Does not work unfortunately.

Still in memory. Backup will still not continue.
0
 
MaheshArchitectCommented:
OK
Try below
at end of script type:
stop-process -Id $PID

This should kill PowerShell process from memory
0
 
Raymond JansenAuthor Commented:
Thanks, works fine like this!
0

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now