VMware Cloud Community
RobMokkink
Expert
Expert

scheduled tasks + credentials not passed to script

I opened another thread, because if accidentaly set the other thread to solved.

I am still having issues with scheduled tasks and credentials. I created a new lab (on my laptop) to test the issue.

But still i am having issues, i keep on getting this error:

Connect-VIServer : C:\WINDOWS\system32\windowspowershell\v1.0\%APPDATA%\VMware\

credstore

When i installed the previous version everything works oke. When i hard code the username and password in the script, it works oke

Who has the answer to my problem, i can't seem to find the problem.

.

0 Kudos
23 Replies
LucD
Leadership
Leadership

That's what I understood as well Rob and I even think I ran this at one point with PowerCLI without your fix.

But I could be taking my wishes for reality of course Smiley Wink


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
alanrenouf
VMware Employee
VMware Employee

This was a fresh machine with a download of the official release of V4 as of yesterday, scheduled task didnt work this morning and my transcript was as below, this lead me to this post:

Transcript started, output file is c:\dailyreport.txt

Connect-VIServer : C:\Windows\System32\%APPDATA%\VMware\credstore

At C:\Scripts\VMware\DailyReport.ps1:416 char:29

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
0 Kudos
R0Ge
Contributor
Contributor

<code>if (! (Test-Path [string]$env:APPDATA) ) {$env:APPDATA = $env:USERPROFILE + "\Application Data"}  
{font:Arial}In the profile.ps1 works great.{font}</code>

and solved my following batch scheduleproblem. scheduling a windows batch with user who has alo rights in VC, when logged on the batch wordked and schedule with same batch not.Now it worked Thanks

Windows 2003 server-powershell v1- vitools1.5 - esx 3.5 update2

Regards, Robert

0 Kudos
allencrawford
Enthusiast
Enthusiast

My two cents to Rob, Luc, and Alan. I have had this problem with PowerCLI 4 as well. However, I think maybe it is sort of fixed. Here's my situation:

1) I have an AD service account that has the appropriate vCenter permissions.

2) I run the scheduled PShell task with this AD service account while logged into the server and it of course works fine.

3) I log out.

4) Script continues to run fine until the server is rebooted (which of course happens each months for Microsoft patches).

5) To fix it I can simply log in as my service account and just log right back out--I don't even have to interactively run the script to fix it.

So it seems to me that logging in must create the %APPDATA% environment variable and apparently logging out doesn't clear the variable properly or something.

My main question is, why is "Connect-VIServer" even trying to make a call to this path? Shouldn't it only do that when I call "Get-VICredentialStoreItem"? My script is simply doing:

[string]$strVCServer = "servername.domain"
Connect-VIServer -Server $strVCServer

Also, sorry for the late post to this old thread, if it should be a new one I can create a new one. This is the first I've seen of this thread today and figured I'd keep it in one place.

0 Kudos