Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
function log-file {
  param($message)
  Add-Content -path $logfile -Value "$(Get-Date) $message"
}

function ping-server {
  param($server)
  $ping = New-Object System.Net.NetworkInformation.Ping
  $ping.Send("$server")
}

log-file "Pinging server = " + (ping-server $server).status

How can I get the above to work with one line rather than doing this:

$pingable = (ping-server $server).status
log-file "Pinging server = $pingable"
share|improve this question

1 Answer 1

Try making this modification to the log-file function call

log-file $("Pinging server = " + (ping-server $server).status)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.