I have seen something similar with new installations.
The reason I had the issue was that it was the first time the user logged on the OS, and that had as an effect that the user profile was being created.
We bypassed the problem by first doing a kind of dummy Invoke-VMScript with the same account.
That way we were sure the user profile was created on the 2nd call to Invoke-VMScript.
Thanks for the quick reply. What is weird is that some of the Invoke-VMScript commands will work and then they randomly fail.
I will add a dummy Invoke-VMScript at the start of the configuration changes and see if that helps.
Did you put in a timer to give the profile more time to create?
No, no timer, but you could consider that.
First give it a try, do the dummy Invoke-VMScript, 'sleep' (the cmdlet I mean ) for a bit, then do the other Invoke-VMScript calls.
Repeat for a number of VMs and check if the intermittent issue goes away.
Unfortunately it is still happening. I still can't get it to fail in a consistent way. It just randomly fails as it runs each Invoke-VMScript command.
I'm going to try looking at my images and possibly rebuild them to see if they still have this issue.
Any ideas are appreciated.
Here is some examples that just happened:
Which PowerCLI version are you using?
Perhaps it is useful to try upgrading when you're not at the latest 10.1.0 version.
The Invoke-VMScript cmdlet stores the script that needs to be executed inside the guest OS in a temporary file.
For one reason or another in some cases this files seems to be removed (or not created).
If you're adventurous, you could try using Process Explorer to see who and when these temp file are created/removed.
But as a first measure I would upgrade to the latest PowerCLI version.
And perhaps also the latest PowerShell version (5.1)
I am using 10.1.0 build 8346946. I think I have resolved the issue by going at it from a different angle. Instead of using a domain credentialed account for the Invoke-VMScript, I am using the built-in Administrator account to perform the Invoke-VMScript commands. So far after 5 vm deployments it appears to have fixed the issue.
After you mentioned you had seen it before and a timer might work I tried that but it didn't seem to make a difference. I decided to just use the local administrator account since it wouldn't have the same issues as a newly created profile would.
Thanks so much for your help!
Glad you have a solution.