Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Reading WMI (Serialnumber) before windeploy.exe

$
0
0

I have written a Powershell script to read the Serialnumber of a device, and then use this to name the device. 

The line of code is :

$strSerial = gwmi Win32_BIOS | ForEach {$_.SerialNumber}

The script then looks up the serial in a file, finds a matching computer name, and rewrites the unattend.xml file with the new name.  This is set in the registry to run before Windeploy.exe in the registry.  Once complete, the script starts Windeploy.exe.

When I test the script in a normal Windows 8 session, it works fine, finding the serial, looking up the correct name, and editing the unattend.xml file.  However, when I fully run it before the Windeploy.exe, it fails when trying to access WMI, at the line above.

(This is a simple, standalone machine, no Group Policies, AD, etc.)

Is there a reason I am unable to get this code to work?

Thanks.

Edit: Here is the error in the "Administrator: Windows Powershell" Box

-------------------

gwmi : Critical error

At C:\Windows\Setup\Scripts\PreDeploy.ps1:87 char:14

+$strSerial = gwmi Win32_BIOS | ForEach {$_.SerialNumber}

+                   ~~~~~~~~~~~~

+CategoryInfo :InvalidOperation: (:) [Get-WmiObject], ManagementExecption+FullyQualifiedErrorId : GetWMIManagementException, Microsoft.Powershell.Commands.GetWmiObjectCommand

-------------------



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>