Get-Hostname tested and functioning, PCMonitor now uses Output pipeline

This commit is contained in:
Zachary Gorman 2024-07-15 08:54:31 -07:00
parent f48cb0861d
commit 062f91059e
2 changed files with 5 additions and 10 deletions

View file

@ -1,4 +1,4 @@
function Get-Hostname ($name) {
function Get-Hostname ([string]$name) {
if ($name.Length -eq 5) {
$res = Get-AssetConversion $name
if ($res) { return $res }

View file

@ -27,11 +27,7 @@ function Invoke-PCMonitor {
if ($notify) {
$null = [System.Windows.MessageBox]::Show($msg)
}
<<<<<<< HEAD
Write-Host "$msg" -NoNewline
=======
Write-Output "$msg"
>>>>>>> HostnameRefactor
}
}
# Update date and time so user knows script hasn't frozen
@ -119,14 +115,13 @@ class WatchDog {
}
}
if ($old.LastUser -ne $this.LastUser) {
if ($old.LastUser -and $this.LastUser) {
$msg += "$date $($this.Hostname) | $($old.LastUser) logged off and $($this.LastUser) logged on`r`n"
} elseif ($old.LastUser -ne "") {
if ($old.LastUser -ne "") {
$msg += "$date $($this.Hostname) | $($old.LastUser) logged off`r`n"
} elseif ($this.LastUser -ne "") {
}
if ($this.LastUser -ne "") {
$msg += "$date $($this.Hostname) | $($this.LastUser) logged on`r`n"
}
}
return $msg
return $msg.Trim()
}
}