enable schedule task from windows 2008 - scheduled-tasks

I am trying to enable and disable a schedule task on windows server 2003 R2 from windows server 2008 R2 machine.
I am also using username and password. Error given Access is denied.
Following is the command
schtasks /change /disable /tn <taskname> /s <remoteserver 2003R2> /RU <username> /RP <password>

The issue was with user for running the schedule task. Added the user to the admin group. Issue resolved.

Related

How to run cmd or powershell command from golang as admin?

How can cmd and powershell commands be executed from Go with admin privilege (run as admin)?
Note that the execution of cmd and powershell with admin privilege is clear, but how to specify that the commands executed by them also have admin privilege is questionable.
For example how can we run this powershell command in go as administrative:
Stop-Process -ID 11111 -Force
or this command:
taskkill /IM example.exe /F

Is there any way to enter password for RunAs on psexec session?

I'm currently working on an installer script that uses remote sessions with Psexec.exe, I'm trying to run RunAs command on Psexec session and the session getting exit status 1 right after prompt the password.
Currently, the installer suppose to run on Windows Server 2012 r2 with PSv4.0
PS C:\> psexec \\Some IP -u <Username> -p <Password> cmd /c runas /user:Administrator "cmd.exe /k <Path for batch file>"
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Enter the password for Administrator:
cmd exited on 192.168.0.124 with error code 1.
For some reason, the Psexec doesn't wait for password type just throws the session and gives Error Code 1.
Help will be happily received

How can a PowerShell script be automatically run on startup?

I want to run my script at boot up time in windows 7
I tried
Setup a scheduled task to run at startup - it doesn't run until someone logs in.
Local GP to run script at startup - it doesn't run until someone logs in.
Adding the scheduled task from a command prompt with admin - some time work some time not
schtasks /create /tn "start" /sc onstart /delay 0000:30 /rl highest /ru system /tr "powershell.exe -file <>
any other method to this ?
you can make an bat file in your startup folder.
startup.bat whit this content
Powershell -command "& {c:\Temp\Test.ps1}"

Remote Schedule Windows Update and Shutdown with Powershell

I am currently trying to create an automation script with powershell.
The script I'm using is Force Install Updates on Remote Computer The script allows a remote computer to creates a scheduled task to perform a windows update on a host computer.
Question
How can I modify this script to shut down the remote computer after the scheduled task has updated the operating system?
Just add a new action to the scheduled task.
Action: Start a program
Program/script: shutdown
Add arguments: /p /f (to switch off)
Add arguments: /r /f /t 01 (to reboot)
Start in: <leave it empty>
A remote solution would be to start "shutdown.exe" with Powershell
Start-Process "shutdown.exe" -ArgumentList (" /s /f /t 01 /m \\{0}" -f $RemoteComputer) -NoNewWindow -Wait
Another one to use WMI, see Microsoft MSDN.
(Get-WmiObject -Class Win32_OperatingSystem -ComputerName $RemoteComputer -EnableAllPrivileges).Win32Shutdown(12)
Until Powershell 3 "Stop-Computer" is available, see Microsoft TechNet.
Stop-Computer -ComputerName $RemoteComputer

Access Certificate Store from LocalService Account

Is there any way to access and view the certificate store of the LocalService account?
I would like to add and delete certificates. (Using Windows Server 2008 R2)
I tried:
runas /user:"NT AUTHORITY\LocalService" mmc.exe
Also:
schtasks /create /sc once /st 09:36 /f /tr mmc.exe /tn taskname /ru LOCALSERVICE
schtasks /run /TN "taskname"
Without luck :(
Someone here suggested using PsExec for running commands with a service account.
Run psexec as administrator:
psexec -i -u "nt authority\local service" cmd.exe
In the new command window run:
certmgr.msc
I do not know if this will solve you problem, it is just a suggestion...