0

I am trying to have a power shell script resume after a reboot. (I am rebooting to "apply" registry changes I have made") I believe I can accomplish what I want by making a registry edit to the Run Once key. I have looked at this question, but I can't get my similar code to execute at boot. The registry edit is made and at boot something runs because it disappears but it is not finishing the install.

$part2 = Get-ChildItem C:\Windows\ccmcache\ -Recurse -Force -Filter Full_Druva_Reinstall_part2.ps1
$FullPath = $part2.FullName
$KeyPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce"

new-itemproperty -Path $KeyPath -Name !Install-Druva -propertytype String -value "Powershell -executionPolicy Unrestricted -File $FullPath"

Edit This scrpit is inside a SCCM Package and any solution needs to automatic and require no user input.

Community
  • 1
  • 1

2 Answers2

0

Open task scheduler on general give a name> run wheter user logged in or not> trigger at startup> action

program/script will be powershell.exe

arguments

-ExecutionPolicy Bypass -File "C:\myscripts.ps1"

enter image description here

DisplayName
  • 1,008
  • 10
  • 24
  • This isn't going to work for me. I am trying to make a Package for SCCM and I need it to be automated. I feel like I am really close to getting it to work with these Run Once regedits but I am doing something stupid. I may have to do something more like this http://stackoverflow.com/questions/31035899/unable-to-resume-a-workflow-via-task-scheduler/31100397#31100397 – NathanTheGr8 Jul 28 '16 at 21:25
0

I wasn't able to make the Run Once Registry work, plus it wouldn't tun with admin cred if a non admin logged in. I also wasn't able to make a schedule task in power shell because my environment is all Win7 and power shell v4.

The solution i used was making a task sequence in SCCM that ran part 1 of my script, restarted, and then ran part 2.