Hello,
I am capturing the output of Get-WMI and applying REGex
$OS=Get-WmiObject -ComputerName $Computer.DNSHostname -Class Win32_OperatingSystem -ErrorAction Stop | Select Name
$OS=[regex]::match($OS.name,'[^|]+').value
Original value before RegEx above looks like this:
Microsoft Windows Server 2008 R2 Enterprise |C:\Windows|\Device\Harddisk0\Partition3
This perfectly extracts the Operating system information for all windows servers and looks like this:
Microsoft Windows Server 2008 R2 Enterprise
Microsoft Windows 2000 Server
Microsoft Windows Server 2003 R2 Standard Edition
Microsoft Windows Server 2003 R2 Standard Edition
Microsoft Windows Server 2003 R2 Standard Edition
Microsoft Windows Server 2008 R2 Enterprise
Microsoft Windows Server 2008 R2 Enterprise
Microsoftr Windows Serverr 2008 Standard
Microsoft Windows Server 2003 R2 Standard Edition
Microsoft Windows Server 2003 Standard Edition
However, I can't figure out how to modify the RegEx to drop that last "r"s in the bold line if they appear.
Thank you