Showing posts with label Scheduled Task. Show all posts
Showing posts with label Scheduled Task. Show all posts

Thursday 17 July 2014

Error on Powershell - 0xffff0000

I am not very familiar with PowerShell, yet... really. Currently, my main scripting language is VBScript. However, I am truly believe the needs to learn PowerShell is keep increasing every single day. Server 2008 and Server 2012 are equiped with PowerShell, some advanced managements in XenDesktop 7.5 are using PowerShell, it is fun to learn PowerShell (they said), and a few other points mentioned by my colleagues (Wow, what on earth Heiry, why your introduction is longer than an episode of Dads?)

Issues :

Error encountered when a scheduled task created to run PowerShell script :


The shell cannot be started. A failure occurred during initialization: Object reference not set to an instance of an object.


Furthermore, this error reported on Task Scheduler.






Troubleshooting 
  1.  Go to Start > Run, and type regedit. Press Enter

  2.  Registry Editor launched. Browse to My Computer > HKEY_CURRENT_USER, and look for for Environment folder. It is not there.

  3.  Next, go to My Computer > right click and choose Properties

  4.  Go to Advanced tab, and click at Environment Variables...

  5.  You won't see any entry on variable, as below :


Resolution :

There are 2 methods to solve this :-


Method 01 - Using Registry Editor :

  1.  Launch REGEDIT. Browse to My Computer > right click at HKEY_CURRENT USER > hover at New > Choose Key

  2.  Change the new Key name to Environment

  3.  Now, lets refresh Registry Editor by pressing View > Refresh

  4.  We can see the new key is arranged accordingly.

  5.  Next, rignt click at Environment key > go to New > choose Expandable String Value

  6.  Right click at newly created strign entry, and choose Rename and name it as TMP

  7.  Right click at TMP string, and choose Modify

  8.  Configure below string to Value data box :
    String :
    %USERPROFILE%\Local Settings\Temp
                   
  9. Perform step 5 until 8 with below info : 
String Name : TEMP
Value Data : %USERPROFILE%\Local Settings\Temp




Method 02 - Using GUI :

  1. Right Click at My Computer > choose Properties > click at Advanced Tab > Click at Environment Variables

  2.  We will add the strings from here. Choose New

  3.  Configure the variable names and variable values accordingly, then press OK
     Variable name :
    TMP
     Variable Value : %USERPROFILE%\Local Settings\Temp

     Variable name : TEMP
     Variable Value : %USERPROFILE%\Local Settings\Temp
                                                                     
  4. This is the outcome. Press OK, and launch the PowerShell script to test.
Share:

Thursday 10 July 2014

Task Scheduler Error - An Error has occurred for task . The following error was reported: A specific logon session does not exist. It may already have been terminated.

A few days ago I created a script to do some little, tiny checking on my servers. My plan was to create a Task Scheduler so that script can be executed periodically. But (yeah, there is always a but), I encountered an error. If we look carefully at the error, it did not mentioned about Securty or policy setting, but I know it must related to UAC.



Issues :

Receive error when configuring Task Scheduler :


An Error has occurred for task <Task Name>. The following error was reported: A specific logon session does not exist. It may already have been terminated.





Troubleshooting 
  1.  Go to Start > Administrative Tools > Click at Task Scheduler

  2.  Browse to Task Scheduler (local) > Task Scheduler Library

  3.  Right click at the specific Task Scheduler > choose Properties

  4.  At General tab, the radio box " Run whether user is logged on or not " is enabled. Which means, the setting is okay.

  5.  Further checking, go to Start > Run, type secpol.msc and press Enter.

  6.  Browse to Security Settings > Local Policies > Security Options

  7.  Check on this setting, it is Enabled.




Resolution :
  1.  Right click at the above mentioned setting, and choose Properties

  2.  Click at Disabled, press Apply and OK.


  3.  Perform gpupdate /force to refresh policy update.
Share: