Hi There,
I've a question concerning the vicredentialstoreitem. At first a create a credential xml file with the new-vicredentialstoreitem cmdlet.
I use this script to use the credentials for viserver. I run this script in scheduled tasks.
$creds = Get-VICredentialStoreItem -file d:\credfile
Connect-VIServer -Server $creds.Host -user $creds.User -password $creds.Password
The account I use to login VIserver is Domain admin, and the same account I use for scheduling the script.
When scheduled tasks fires up the script I get this error message:
"Could not aquire access to credential file: d:\credfile . Another process/thread has locked the file"
When I run the script from PowerCli, no problem.
Ideas anyone?
Regards
Hi again,
I have a suggestion about what the problem is. Can you check the permissions of the
credentials file that you use? When you create the file with
New-VICredStoreItem it assigns read permissions only to the current user
that the process is running under. This makes sense, since you don't want someone else to read you passwords. Perhaps you've created the file with one user account and try to read it under another.
Let me know if this helped.
Regards,
-Angel
Could it be that your PowerCLI session has a lock open on the XML file ?
Try closing your PowerCLI session before you run the scheduled task.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the reply,
I killed the powershell.exe process and ran the script again.
No, still the same error message.
Still no solution for this?
Hi Heskez,
Can you check which process has locked the file? You can use some tool like Process Explorer. If the file is locked by the same PowerCLI session, please report back, since this would be a bug.
Regards,
-Angel
Thanks for the reply
This is the only handle I can find with psexplorer :
D:\Program Files\vmware\Infrastructure\vSphere PowerCLI\VMware.Security.CredentialStore.dll
Which is held by powershell.exe
De file with the credentials I call "credfile" isn't been found between the handles, weird huh?
I don't give an exit ps command in the script itself, only e "disconnect-viserver" at the end.
Is this required?
Regards,
Erik
Hi again,
I have a suggestion about what the problem is. Can you check the permissions of the
credentials file that you use? When you create the file with
New-VICredStoreItem it assigns read permissions only to the current user
that the process is running under. This makes sense, since you don't want someone else to read you passwords. Perhaps you've created the file with one user account and try to read it under another.
Let me know if this helped.
Regards,
-Angel
I've tested it and you're totally right! Points awarded!