Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3968408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:50:20+00:00 2026-05-20T03:50:20+00:00

I’m not sure if I am completely mad or missing something but I am

  • 0

I’m not sure if I am completely mad or missing something but I am trying to do something very simple which is pipe separate a load of variables in a function and write them out.

“Easy” you say? I would have thought so. But here is a wee extract of my attempts to write a powehell function to make the rest of my code a little easier on the eye.

$logtoFile=$false
function logEntry($entryType, $section, $message)
{

    #The way I assumed woudl work
    $logString1 = $(get-Date -format "yyyy-MM-dd hh:mm:ss") + "|" + $entryType + "|" + $section + "|" + $message
    #Another way which should also work
    $logString2 = "$(get-Date -format "yyyy-MM-dd hh:mm:ss")|$entryType|$section|$message"
    #Proof that it is not the pipes causing issues
    $logString3 = "$(get-Date -format "yyyy-MM-dd hh:mm:ss"),$entryType,$section,$message"
    #another method I found. Not sure what the issue is there
    $logString4 = $(get-Date -format "yyyy-MM-dd hh:mm:ss"), $entryType, $section, $message -join "|"
    $WhatIwant = $(get-Date -format "yyyy-MM-dd hh:mm:ss") + "|0|moonin|plimsole"

    if($script:logtoFile)
    {
        Add-Content $logFile $logString
    }
    else
    {
        write-host $logString1
        write-host $logString2
        write-host $logString3
        write-host $logString4
        write-host $whatIwant
    }
}
logEntry(0,"moomin","plimsole")

Output:

2011-02-17 11:22:59|System.Object[]||
2011-02-17 11:22:59|0 moomin plimsole||
2011-02-17 11:22:59,0 moomin plimsole,,
2011-02-17 11:22:59|0 moomin plimsole||
2011-02-17 11:22:59|0|moonin|plimsole

Searching around I found several alternatives, none of which seem to produce the right results. I’m not sure what the whole “lump all of the variables together space separated” thing as all about in the first place.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:50:21+00:00Added an answer on May 20, 2026 at 3:50 am

    You’re calling the function incorrectly. You are putting 0, mommin, and plimsole into the first variable, and nothing for the second and third variables. Hence, the output you are getting.

    Instead of calling the function like this

    logEntry(0,"moomin","plimsole")
    

    You need to call the function like this

    logEntry 0 "moomin" "plimsole"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to select an H1 element which is the second-child in its group
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.