0

So I am creating a basic HTML report for a System Server Audit, some extracts which are relevant:

$system = Get-WmiObject -ComputerName $cmpSys Win32_ComputerSystem 

$body = $null
$body += @"
<font color="red">Hostname: </font>$cmpSys
<br>
<font color="red">Domain: </font>($system.Domain)
<br>
"@

Now, Hostname: $cmpSys - correctly produces Hostname in red and the hostname in black

However, I am calling $system.Domain in the format later on, which produces in my report:

Domain: (\\W7WKS01\root\cimv2:Win32_ComputerSystem.Name="W7WKS01".Domain) 

But it should just display W7WKS01

Any ideas?

1 Answer 1

1

You need $($system.Domain), not just ($system.Domain). Without the leading $ the parentheses are just literal parentheses inside a string, and $system.Domain is expanded to the default attribute of $system (__PATH) followed by a literal ".Domain".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.