![]() ![]() just adds to the complexity and efficiency, and reduces clarity. "" -f $Manufacturer,$Name,$Serial | Out-File $LogFileĪdding a "Decode" function in place of a copy/paste of the string ::ASCII.GetString($_. $Serial = ::ASCII.GetString($_.SerialNumberID).Trim(0x00) $Name = ::ASCII.GetString($_.UserFriendlyName).Trim(0x00) $Manufacturer = ::ASCII.GetString($_.ManufacturerName).Trim(0x00) Get-WmiObject WmiMonitorID -Namespace root\wmi | The whole set of code in the original poster's question can be replaced by this: $LogFile = "c:\Junk\monitors.txt" It will remove items within the byte array representation of the string that match the value of zero, not just the trailing items that match. The "-notmatch" operator is acting on the individual elements of the byte array, not on the entire value. It's an object of type byte (an array of bytes). The "SerialNumberID" property is not a string.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |