Jump to content

Recommended Posts

Posted

Hi all,

 

I've created the following Powershell script

 

Restart-Service -Name NlaSvc -Force

 

to restart the Network Locations Services but can't get it to work via scheduled task. If I run the powershell command manually it works fine.

 

I'm wanting the command to run once the server is booted up. It doesn't have to be logged in.

 

Any help much appreciated.

 

Thanks.

Posted

Ah is this to do with the network profile not being set to domain after reboot?

 

Can you post a screenshot of what you have setup in the scheduled task for when you call the PS script?

Posted
Ah is this to do with the network profile not being set to domain after reboot?

 

Can you post a screenshot of what you have setup in the scheduled task for when you call the PS script?

 

Yes that is correct. I’ll post the screenshot up of the task scheduler.

 

Yes the network card shows Unidentified network. Two cards, teamed as one.

Posted
Ah is this to do with the network profile not being set to domain after reboot?

 

Can you post a screenshot of what you have setup in the scheduled task for when you call the PS script?

 

 

Hi,

 

Please see scheduled task screenshots. I've blacked out the irrelevant bits but the relevant settings in task scheduler can still be seen.

 

Many thanks

image1.jpg

Image2.jpg

Image3.jpg

Image4.jpg

Image5.jpg

Image6.jpg

Image7.jpg

Posted
Please see scheduled task screenshots.

Since you are only running a single command, try the following in the settings for the action.

 

Program/script

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

 

Arguments

-Command "Restart-Service -Name NlaSvc -Force"

  • Thanks 1
Posted

@Arthur ‘s idea is the easiest way.

 

If you did want to call a script I’d be looking at the event log to see what error is it’s throwing. I’m thinking that you might have an issue with option not to store password being ticked and with PS code execution level. I usually put in an argument to set code execution level to run unsigned code just to make sure.

Posted
Assuming the support account has administrator rights. I always find using a Start-Transcript and Stop-Transcript to a log is helpful when getting permissions correct. Also be aware of execution policy. You may need to sign your script or use the bypass switch. It depends on the environment.
Posted
I usually put in an argument to set code execution level to run unsigned code just to make sure.

If the task was ran using the "NT Authority\SYSTEM" account could the OP get away with the following arguments?

 

-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Restart-Service -Name NlaSvc -Force"

Posted
If the task was ran using the "NT Authority\SYSTEM" account could the OP get away with the following arguments?

 

-NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Restart-Service -Name NlaSvc -Force"

 

Off the top of my head yes that looks like it would work :)

Posted
Since you are only running a single command, try the following in the settings for the action.

 

Program/script

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

 

Arguments

-Command "Restart-Service -Name NlaSvc -Force"

 

 

 

That works. Thanks very much. Well done.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...