?
Solved

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

Posted on 2015-02-11
4
Medium Priority
?
127 Views
Last Modified: 2015-02-11
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
Comment
Question by:Raymond Jansen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 37

Expert Comment

by:Mahesh
ID: 40602678
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
 
LVL 7

Author Comment

by:Raymond Jansen
ID: 40602689
Hi,

Does not work unfortunately.

Still in memory. Backup will still not continue.
0
 
LVL 37

Accepted Solution

by:
Mahesh earned 2000 total points
ID: 40602772
OK
Try below
at end of script type:
stop-process -Id $PID

This should kill PowerShell process from memory
0
 
LVL 7

Author Closing Comment

by:Raymond Jansen
ID: 40602863
Thanks, works fine like this!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question