Windows 10: Issues while running PowerShell Scripts when shutting down the PC

Discus and support Issues while running PowerShell Scripts when shutting down the PC in Windows 10 Performance & Maintenance to solve the problem; Hi all, I try to run a Powershell Script (*.ps1) when i shut down my PC. I created the script and it is working fine when i run it. However if i want... Discussion in 'Windows 10 Performance & Maintenance' started by Michael__89, Jul 29, 2019.

  1. Issues while running PowerShell Scripts when shutting down the PC


    Hi all,

    I try to run a Powershell Script (*.ps1) when i shut down my PC. I created the script and it is working fine when i run it. However if i want to run it on a regular Shutdown it seems like it does not start or is not finished, before Windows is killing every running process.


    I tried several things:

    1) Adding the script to C:\Windows\System32\GroupPolicy\Machine\Scripts\Shutdown

    2) added the Script to gpedit.msc in the Shutdown section

    3) Creating a scheduled Task which triggers on System User32 EventID 1074


    Ether the Script is not triggering at all or Windows will kill everything before anything happens.


    ***Original title: Powershell Script on Shutdown***

    :)
     
    Michael__89, Jul 29, 2019
    #1
  2. EckiS Win User

    PowerShell script run - Cmdlets

    As SQL-IP and Cosmos are still internal to Microsoft, I wonder why you are not simply contacting the person who provided you with the scripts.

    For point 1: see PowerShell: Bypass ExecutionPolicy to run downloaded scripts

    For point2: this is specific to the script: "Cosmos.Document" is probably in a module which is not found.
     
    EckiS, Jul 29, 2019
    #2
  3. PowerShell script run - Cmdlets

    Greetings - in the last month my role (support for Microsoft) has begun running database searches using PowerShell ISE - the procedure and software I was given by Microsoft to follow specified PowerShell ISE, not PowerShell. The first week or so the searches
    seemed to run fine and I got good results returned. Then the searches stopped successfully executing. I got various error messages, or just illogical results, and so I tried reinstalling PowerShell a couple of times, with no success. On Friday 8/12 I upgraded
    to Win10 Anniversary Ed. I still can't successfully run a PowerShell ISE search request. So, I'm hoping the Forum can help:

    1. When I Run a request I get this pop-up: "Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your computer. If you trust this script, use the Unbock-File cmdlet to allow the script to run without
    this warning message. Do you want to run ...". I then get 3 options 1) Do not run, 2) Run Once, 3) Suspend.

    My understanding is that the "Unbock-File cmdlet" is a single-feature command that manipulates objects in Windows PowerShell. Where should I insert the "Unbock-File cmdlet" ? I trust the script because it was provided to me by Microsoft.

    2. I've been selecting option 2) Run Once. The script will then run for a while, and then I get this error message "[Expression Error] The import Cosmos.Document matches no exports. Did you miss a module reference?"

    How do resolve this issue? Reinstalling PowerShell has not seemed to help.

    Any help much appreciated!
     
    Jacqui Schultz, Jul 29, 2019
    #3
  4. Issues while running PowerShell Scripts when shutting down the PC

    Powershell scripts not running on windows 10

    I have powershell scripts already created. I used to be able to run them on my previous pc which had windows 7 but now I am using a pc with windows 10 and I am unable to run the same scripts on windows 10 environment.

    Please help
     
    Mzwandile Ngubane, Jul 29, 2019
    #4
Thema:

Issues while running PowerShell Scripts when shutting down the PC

Loading...
  1. Issues while running PowerShell Scripts when shutting down the PC - Similar Threads - Issues while running

  2. Issue when I shut down.

    in Windows 10 Performance & Maintenance
    Issue when I shut down.: Hi, I am facing an issue with my desktop, When i click on shut it down its not shutting down. the screen will be turn black but my desktop is still running. Please do suggest me on this. I am facing this issue from past 2 months....
  3. Microsoft PowerShell Ghost Error Messages when Running Script

    in Windows 10 BSOD Crashes and Debugging
    Microsoft PowerShell Ghost Error Messages when Running Script: The Windows Topics selected after this box does not contain a selection for PowerShell run script When I run my script, every step of the script completes satisfactory. The following script is the one I've been testing. My original PowerShell coding example:...
  4. Shut Down Issue

    in Windows 10 Support
    Shut Down Issue: Hi I have just upgraded my Pavilion DV6 laptop from a standard HDD with windows 7 to a Crucial MX500 SSD and windows 10 (clean install). The installation went smoothly and all the required drivers seems to have installed automatically.The only thing that seems to be a...
  5. pc shutting down

    in Windows 10 Drivers and Hardware
    pc shutting down: so my pc has been shutting down randomly no error codes or anything straight to black that made me think it was the psu well i replaced it and still persists and the only thing event viewer is showing is this 9 - <Event...
  6. Running PowerShell script as a batch file

    in Windows 10 Network and Sharing
    Running PowerShell script as a batch file: Can I run the Power Shell line: "C:\Windows\System32>get-appxpackage *3dbuilder* | remove-appxpackage" from a .Bat file? ***Original title: Removing bloatware***...
  7. Run PowerShell Script As An Administrator

    in Windows 10 Support
    Run PowerShell Script As An Administrator: Hi. So I've been searching online on a way to do this yet I cannot find a way to do it. _______________________________________ I need this in specific: I want to double click a PowerShell script file (which will run as an administrator) from Windows Explorer that has...
  8. BSOD while shutting down...?

    in Windows 10 BSOD Crashes and Debugging
    BSOD while shutting down...?: hey..I was shutting down my pc, when suddenly a Blue Screen Of Death appears after the "Shutting Down" screen...resource_not_owned please help 40742
  9. Issues booting the PC and shutting it down.

    in Windows 10 Performance & Maintenance
    Issues booting the PC and shutting it down.: Hello TenForums members! I'm having some issues with my PC I have never had before. The computer is a personal rig I have personally worked on, but these last weeks some problems started appearing. Problem 1) {Had this problem for months, I think this problem also...
  10. Shutdown script (gpedit) runs with 'Restart' but not with 'Shut down'

    in Windows 10 Support
    Shutdown script (gpedit) runs with 'Restart' but not with 'Shut down': Dear all, I have an issue with a shutdown script that I don't manage to resolve: I wrote a .bat file script that works fine when it is clicked on. Through gpedit.msc, I added it as a shutdown script. When the computer is restarted (Power -> Restart), it works fine as well...