Get-Hostname tested and functioning, PCMonitor now uses Output pipeline
This commit is contained in:
parent
f48cb0861d
commit
062f91059e
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue