VMware

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
1 Replies Last post: Nov 5, 2009 1:25 PM by c_shanklin  

credentials not passed to script run as a scheduled task posted: Nov 5, 2009 9:48 AM

Click to view allencrawford's profile Enthusiast 75 posts since
Jan 7, 2005
I'm creating a new thread since I've not seen any action on the existing one where I posted (not sure if anyone saw it due to the age of the thread). For reference, see http://communities.vmware.com/message/1406190. But the gist of it is that running a script as a scheduled task is not properly passing the Windows service account credentials to the Connect-VIServer cmdlet. When that cmdlet is run it throws the following error:

Connect-VIServer : <SourcePath>\%APPDATA%\VMware\credstore
At <SourcePath>\scriptname.ps1:41 char:17


So anyway, rumor was that it was fixed in PowerCLI 4.0, but that does not appear to be the case as Alan Renouf (and now me) have reported. On to my original post in that thread...

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 month for Microsoft patches).

5) To fix it I can simply log in with 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


I'm not trying to save any credentials as pass-through should work fine and be somewhat more secure.
Click to view c_shanklin's profile Master 754 posts since
Dec 3, 2007
I asked the team to take a look at this. I thought it was fixed, and we haven't got any recent complaints, but maybe it's because everyone was using the workaround.

=====
Carter Shanklin
Read the PowerCLI Blog
Follow me on Twitter

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities