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. Run desktop script in PowerShell

    in Windows 10 Network and Sharing
    Run desktop script in PowerShell: I have a script on my desktop that I need to run in PowerShell; how do I do that? https://answers.microsoft.com/en-us/windows/forum/all/run-desktop-script-in-powershell/666a7726-8cbd-42c7-ac2c-419229432252
  3. Run desktop script in PowerShell

    in Windows 10 Gaming
    Run desktop script in PowerShell: I have a script on my desktop that I need to run in PowerShell; how do I do that? https://answers.microsoft.com/en-us/windows/forum/all/run-desktop-script-in-powershell/666a7726-8cbd-42c7-ac2c-419229432252
  4. Run desktop script in PowerShell

    in Windows 10 Software and Apps
    Run desktop script in PowerShell: I have a script on my desktop that I need to run in PowerShell; how do I do that? https://answers.microsoft.com/en-us/windows/forum/all/run-desktop-script-in-powershell/666a7726-8cbd-42c7-ac2c-419229432252
  5. Issue in Powershell script

    in Windows 10 Gaming
    Issue in Powershell script: HI Team,We have a power shell script. It will check if the user is available in the ACL list of ADL. To get the ACL list, we are connecting to the Azure Datalake storage using Connect-AzAccount and authenticating with SPN. To get the group member details, we authenticate the...
  6. Issue in Powershell script

    in Windows 10 Software and Apps
    Issue in Powershell script: HI Team,We have a power shell script. It will check if the user is available in the ACL list of ADL. To get the ACL list, we are connecting to the Azure Datalake storage using Connect-AzAccount and authenticating with SPN. To get the group member details, we authenticate the...
  7. Issue while shutting down laptop

    in Windows 10 BSOD Crashes and Debugging
    Issue while shutting down laptop: Hello, I recently from past 4-5 day have started facing an issue with my laptop. When I shut down my laptop, it now stays on for over 10 minutes white light on the right side stays on. I mean that that the screen gets off but sometime i can hear the sound of the fans...
  8. 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...
  9. 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...
  10. PowerShell Scripting - Run a Script from Shortcut

    in Windows 10 Tutorials
    PowerShell Scripting - Run a Script from Shortcut: How to: PowerShell Scripting - Run a Script from Shortcut [img] Information One of many PowerShell security features is that you can't run a script simply by double clicking it's icon on desktop or in a folder. Doing so will by default open script in Notepad for editing...