New Question

wmi fails to run in powershell LocalScripts

asked 2016-06-10 20:05:44 +0300

trodemaster gravatar image

I have written a powershell script that runs with the LocalScripts plugin. It's using the #ps1sysnativ lin and most of the code runs as expected. However anything that calls wmi like (gwmi win32operatingsystem).OperatingSystemSKU fails with a generic error. Has anybody ran into this?

powershell transcript of the code failing.

Thanks, Blake

edit retag flag offensive close merge delete


From further investigation is seems the point in the sysprep process that cloudbase-init runs user scripts is to early. WMI is not available. I have attempted to use the exit codes to have the script re-run later but didn't help. Now I'm looking at using setupcomplete.cmd instead.

trodemaster gravatar imagetrodemaster ( 2016-06-13 21:49:20 +0300 )edit

2 answers

Sort by » oldest newest most voted

answered 2016-06-15 19:34:23 +0300

avladu gravatar image


make sure you add the localscripts plugin execution to the non-unattend cloudbase-init configuration file, as the first cloudbase-init run is started by setupcomplete.cmd .



edit flag offensive delete link more


I have moved the localScripts plugin execution to the non sysprep executed cloudbase-init run with some success. Looking like some plugins need to run in each pass.

trodemaster gravatar imagetrodemaster ( 2016-06-15 21:33:16 +0300 )edit

answered 2016-06-23 13:37:39 +0300


Could you please provide the cloudbase-init log regarding this problem?



edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-06-10 20:05:44 +0300

Seen: 1,010 times

Last updated: Jun 23 '16