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 . 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.