VMware Cloud Community
allencrawford
Enthusiast
Enthusiast
Jump to solution

credentials not passed to script run as a scheduled task

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.

0 Kudos
1 Solution

Accepted Solutions
aevrov
VMware Employee
VMware Employee
Jump to solution

Hi Allen,

Yes, the problem is fixed in U1. It is not related to PS 2.

Regards,

-Angel

View solution in original post

0 Kudos
4 Replies
admin
Immortal
Immortal
Jump to solution

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|http://twitter.com/cshanklin]

allencrawford
Enthusiast
Enthusiast
Jump to solution

Was this fixed in the recent update 1 release? I've retested and it seems to be, but I also upgraded to PowerShell 2.0 so I want to make sure that had nothing to do with it.

0 Kudos
jalrogers
Contributor
Contributor
Jump to solution

I'm having this problem as well although I'm not running the scripts in a scheduled task. I'm running a script via Altiris Deployment Solution server side job. I want to use the single sign on features of PowerCLI, but it's not working correctly. Any advice would be great. Why does it even need access to the credstore?

Edit: I just downloaded the newest version of PowerCLI 4 Update 1 and it appears to be working now. Problem solved I suppose.

Message was edited by: jalrogers

0 Kudos
aevrov
VMware Employee
VMware Employee
Jump to solution

Hi Allen,

Yes, the problem is fixed in U1. It is not related to PS 2.

Regards,

-Angel

0 Kudos