Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

PowerShell with WMI Set ?

$
0
0

From PowerShell of “Get-WmiObject –List “ previous builds have “MOE” with the below 4 Attributes which is later referred in another PowerShell script in my Task Sequence.

MOE                         {}                  {BuildName, BuildTimestamp, BuildVersion, InstanceKey...}

In my Task Sequence the PowerShell Script Includes the following ;

# Read the MOE Version from the [QSMOEVersion] task sequence var

$MOEVer = $tsenv.Value("QSMOEVersion")

Write-Log "Property QSMOEVersion is now = $MOEVer" $global:LogTypeInfo

# Get the Windows version number

$OSVer = get-wmiobject -class "Win32_OperatingSystem" -namespace "root\CIMV2" -computername "." -Property Version

Write-Log "OS Version read from WMI = $OSVer.Version" $global:LogTypeInfo

# Construct the MOE version

$BuildVersion = $OSVer.Version + "." + $MOEVer

Write-Log "Writing Buildversion into MOE instance (WMI) = $BuildVersion" $global:LogTypeInfo

# Issue Here as Object does nto exist I need to create in TS earlier step perhaps.

# Write the MOE information into WMI and registry

$MOEInstance = Get-WmiObject -Class "MOE" -Namespace "root\CIMV2"

$MOEInstance.BuildVersion = $BuildVersion

$MOEInstance.BuildTimestamp = Get-Date

$MOEInstance.Put()

Get-ExecutionPolicy

<#

   @@@--- END: Write MOE version information to WMI and registry ---@@@

However in my new Build Capture it appears from Version 14 and higher the WMI “ MOE ” with sub keys is missing and I have confirmed this will WMI Viewer. Can Anyone assist in writing the “ MOE “ Key to Root WMI with 4 Subkeys , BuildName, BuildTimeStamp, BuildVersion, InstanceKey. I cannot find how this was completed as part of the build and possibly a manual task done prior to capture undocumented in my environment.

Could anyone direct me on how to write to WMI the above setting in a Task Sequence Variable. I set the QSMOEVersion in the Task Sequence as a variable which works, fails in logs as missing WMI root Key “ MOE “.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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