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?)
Error encountered when a scheduled task created to run PowerShell script :
Furthermore, this error reported on Task Scheduler.
Troubleshooting
Resolution :
There are 2 methods to solve this :-
Method 01 - Using Registry Editor :
Method 02 - Using GUI :
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
- Go to Start > Run, and type regedit. Press Enter
- Registry Editor launched. Browse to My Computer > HKEY_CURRENT_USER, and look for for Environment folder. It is not there.
- Next, go to My Computer > right click and choose Properties
- Go to Advanced tab, and click at Environment Variables...
- You won't see any entry on variable, as below :
There are 2 methods to solve this :-
Method 01 - Using Registry Editor :
- Launch REGEDIT. Browse to My Computer > right click at HKEY_CURRENT USER > hover at New > Choose Key
- Change the new Key name to Environment
- Now, lets refresh Registry Editor by pressing View > Refresh
- We can see the new key is arranged accordingly.
- Next, rignt click at Environment key > go to New > choose Expandable String Value
- Right click at newly created strign entry, and choose Rename and name it as TMP
- Right click at TMP string, and choose Modify
- Configure below string to Value data box :
String : %USERPROFILE%\Local Settings\Temp - Perform step 5 until 8 with below info :
String Name : TEMP
Value Data : %USERPROFILE%\Local Settings\Temp
Method 02 - Using GUI :
- Right Click at My Computer > choose Properties > click at Advanced Tab > Click at Environment Variables
- We will add the strings from here. Choose New
- 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 - This is the outcome. Press OK, and launch the PowerShell script to test.
Thank you! Worked Perfectly!
ReplyDeleteGreat to hear that!
DeleteHi Heiry,
ReplyDeleteAll the image links were broken. Could you please help to fix it?
Thanks
Hi there,
DeleteSure thing! I accidentally deleted those pictures in Google Photos but worry not, I am pretty sure I have another copy in Word documents, so it is doable!