Write-host in a function, no newline

I'm trying to create a very basic function

function SQLquery ([string]$SQLserver,[string]$SQLCatalog,[string]
$SQLQuery)
{
write-host -fore yellow $SQLserver;
write-host -fore red $SQLCatalog;
write-host -fore cyan $SQLQuery;
write-host "test"
write-host "test2"
write-host "test3"
}
SQLquery('a','b','c')

the output is

a b c(everything in yellow)
blank line
blank line
test
test2
test3

I was expecting:

a (yellow)
b in red
c in cyan
test
test2
test3

What is going on ?
0
Personne
3/19/2010 10:21:28 PM
windows.powershell 690 articles. 0 followers. Follow

2 Replies
2223 Views

Similar Articles

[PageSpeed] 0

My mistake.

SQLquery('a','b','c')  needs to be SQLquery 'a' 'b' 'c'
no parentheses, no comma
0
Personne
3/19/2010 10:27:58 PM
You need to use spaces instead of commas as the argument separator

   SQLquery('a' 'b' 'c')

It's something yo just have to get used to.

With commas you were sending the function a single argument whose value was an 
array containing three strings.

  - Larry

Personne wrote:
> I'm trying to create a very basic function
> 
> function SQLquery ([string]$SQLserver,[string]$SQLCatalog,[string]
> $SQLQuery)
> {
> write-host -fore yellow $SQLserver;
> write-host -fore red $SQLCatalog;
> write-host -fore cyan $SQLQuery;
> write-host "test"
> write-host "test2"
> write-host "test3"
> }
> SQLquery('a','b','c')
> 
> the output is
> 
> a b c(everything in yellow)
> blank line
> blank line
> test
> test2
> test3
> 
> I was expecting:
> 
> a (yellow)
> b in red
> c in cyan
> test
> test2
> test3
> 
> What is going on ?
0
Larry__Weiss
3/19/2010 10:37:12 PM
Reply:

Similar Artilces:

Merge records function
Is it possible to reuse the record merge function in CRM. Fx to call the function with a valid Account GUID with a URL-call to mergerecords ? I want this to open the merge windows with the GUID as the master record. ...

Excel functions
Hi everyone, Hope somebody could help me with these problems. Problem #1. row 1 =DSUM(database,field,'$A4:$A5) where A4 = "destin"; A5 = "Consolidator 1" row 2 =DSUM(database,field,'$A6:$A7) where A6 = "destin"; A7 = "Consolidator 2" ..... row n =DSUM(database,field,'$An:$Am) where An = "destin"; Am = "Consolidator n" I waste a lot of rows for this criteria only because I do not know ho to create it another way, I mean (A4, A6 and so on) Problem #2 I have named several range of cells in workbook. I want to change...

writing meeting notes with DAte stamps
I am new to Outlook coming from ACT and trying to understand best way to take notes, attach to contacts and make sure the date is automatically input in notes. I would loveto use one program to manage my contacts, but Act has been very easy to use. -- Pete H what version of outlook? -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-request@lists.outlooktips.net EMO - a weekly newsletter about Outlook and Exchange: mailto:EMO-...

Writting Function using VBA
Hi I am trying to write a function to return an address but instead I get #VALUE!. Public Function fnd(a, b) fnd = Range(a).Find(b).Address End Function Please help. Thanks. ..Find won't work in UDF's called from the worksheet until xl2002. Depending on the range (a), you could use application.match() through each column. If the range is small, you could just loop through the values in that range, too. nc wrote: > > Hi > > I am trying to write a function to return an address but > instead I get #VALUE!. > > Public Function fnd(a, b) > >...

migrating newline
hi, i'm migrating some data from dynamics nav to crm. How do ik get <newlines> into the crm database via an import for example , i want to fill the multiline textbox "description" with This is the first line of the description. this is the second line of the description. this is the .... thx in advance On Nov 26, 7:51=A0pm, bgestel <bges...@discussions.microsoft.com> wrote: > hi, > > i'm migrating some data from dynamics nav to crm. > > How do ik get <newlines> into the crm database via an import > > for example , i want to fill th...

Writing XML from Dataset to Response Object as Binary File
I have looked fot his solution, but Im not sure what to search for. I have an asp.net based report. I need the user to be able to download an XML file of the results so they can use the data in Excel, etc. I do NOT want to write the file to the server first. I just want to be able to write the contents of the Dataset into a binary file and send it back out to the user as a download, but all in memory. Can you give me a boost in the right direction or an article that demonstrates this? Dan Hanover wrote: > I have an asp.net based report. I need the user to be able to download &g...

converting hand drawn sketches into Visio Cross Functional Horizon
Hi , I am new to Visio 2003 . Can anybody tell me how can one convert hand drawn sketches into Visio Cross Functional Horizontal diagrams? Thanks Harsha Are you asking about a way to scan images into Visio and transform them into drawings? Or are you asking how to assemble a Cross Functional diagram? To make a Cross Functional diagram, you first choose how many bands to create. Then you click on the headings for the bands to change the text to the names you want. Switch to the Basic Flowchart shapes in the Shapes Window and drag out the Process shapes to create the steps in you...

writing my first Macro
Hello, I am trying to write a macro for the first time in OUTLOOK 2000. I find this will help me cause I don't get around very well. But am having trouble to write one in the VBA. Can you show me how to simply write a few sentences that I can "automatically" include in an email reply to someone. Or if you can send me just a very simple sample or example of a macro that has a small paragraph email. that would be great. I have been looking on "google for hours" now, and all I could find was this sample below, but all it does is put in the "subject l...

Excel super slow on paste function in 2007
When you copy and paste one cell to another I get the circular waiting bar and after 4-5 seconds it pastes. If I'm doing a bunch of cells, it still takes 4-5 seconds per cell and the cells will appear right to left, 1 every 4-5 seconds until it's complete. If I hit ESC, everything copies and pastes right away. This started happening when we converted a 2003 file to 2007. It affects everyone so it's not my PC, it's the document. There are no active add-ons but I recently downloaded an add-in that I got from this discussion board to find hidden links (it's d...

Letter Writing Assistant Error #3
When we try and print a letter in the letter writing program we receive a Header Record Delimiters error. It is asking for a field delimiter and a record delimiter. How do we correct this error. This was working correctly a couple weeks ago, and it works correctly on other machine sin the office, any thoughts or suggestions on how to correct this issue? Anybody have any thoughts or suggestions? ...

Automatic Functions in Excel
Hi There I am developing a Time Sheet in Excel for Staff to record times worked on it. I am using the 1904 date system as occasionally a negative total will be displayed. I would like it if someone was on annual leave they would be able to record this by typing in "Annual Leave" or "A/L" or something similar then the total for that day to display as 7:00 (this is in hours). At present the "total" column runs a calculation of the time finished minus the time started. Is this possible? Regards Colin Hi Colin, StartTime in column A, end ti...

is there a baby-sitting function in Exchange
SBS2003 Premium. One user is not very diligent on reading and responding to emails. He is on the road quite a bit and when he gets back he will not remember that one important email that we needed to respond to. Is there a way that I can have other users have his mailbox open as well, so that they can monitor it and make sure things get replied to? There appears to be such functionality in OL2003, but it just doesn't open the mailbox. Plus his password changes every 30 days, as per the administrator settings, how do we deal with that? Thanks in advance, Robert Assign Full Mailbox ...

Exchange 2003 hosting or Microsoft Office Outlook Live?
Hi all, I'm starting on new business with a colleague. We will both have laptops and are likely to be in and out of the office and may need to work during the evening at home sometimes. We are both from a larger company with Office Exchange servers and are used to sharing calendars and contacts etc and accessing and using our office mail from home. Given that we are starting up we do not want to spend much of money on IT so we were looking at going for one of the online exchange hosting services such as Datagate's (in the UK). The other option is Microsoft Office Outlook Liv...

How to Declare Pointer to Member Function?
I have a thread that needs to make data visible to a function inside a separate class. In the past, I was using PostMessage to get my information to the class function, but occasionally a message gets lost this way. I could declare the class function as static, but then the function would not be able to interact with other parts of the class. The data is thread safe. // header: typedef void (*PtrToLpMsg)(LPTSTR lpMsg); PtrToLpMsg g_AddStatusMsgFn; // code: CMain::CMain() { g_AddStatusMsgFn = AddStatusMsgA; } void CMain::AddStatusMsgA(LPTSTR lpMsg) { // other code } On Mon, 16 ...

Function to control how data displayed
I have 2 columns that I exported from Access to Excel. In Access th columns were Yes or No. In excel they display as True or False. I wan them to show as Yes or No what is the function to make this happen? Thank you! -- LOgle531 ----------------------------------------------------------------------- LOgle5318's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2659 View this thread: http://www.excelforum.com/showthread.php?threadid=39860 LOgle5318, Assuming your True and False are in columns A & B then In C1 put =IF(A1="True","Yes") and...

XL2003: INDIRECT() function changes calling cell
Hello all, It appears that the INDIRECT() function changes the calling cell. Let me try to explain: I have a dynamic named range "NR6.PerMonth": - When "=NR6.PerMonth" is in cell C27 on the "Summary" sheet, it will refer to/return cell C982 on the "6" sheet. - When "=NR6.PerMonth" is in cell D27, it will refer to/return cell D982....and so on and so forth, going across. BUT!!! (A26 on the "Summary" sheet is a formula that returns the number 6...A982 on the "6" sheet is a label): - When '=I...

how to write value
Dear Sir/Madam i want to write entire row value while typing value in general sheet. in the general sheet i have three column name, id, and location. and i have three other sheet London, Newyork, Seattle. while i am entering value in general sheet like name id and location, if the location cell value is same as in the other sheet name london or newyork or seatlle, it should write the value in specific sheet if London it should write the value in London sheet Ryan 1811 is it possible in excel help me thanks and regards vincent yes, select all of the relevant sheet...

Average Function #2
Hi Everyone, I am using Excel 2003. I understand there is probably a very sophisticated way to get what I want but I need to learn the simple way first. I have a data sheet named "MICU". I inserted another sheet in the workbook called "Stats". I want to break down the data by month on my new Stats sheet. The MICU sheet has many columns of info. The 2 I think I need to use is a column for start date "ThpyStDtTm" (Date and Time field 3/14/09 18:41) and a column called "VentLOSDays" (Number format with 2 decimal places). Column A Column...

How to call a function from another workbook
Dear sir, how can i call a function or procedure that contained in another workbook ? thanks Joe Hi When you want to use an UDF or procedure in several workbooks, then save it into a module of Personal Macro Workbook (Personal.xls, it's created automatically, when you select Personal Macro Workbook as destination to save a newly-created macro, and later is loaded automatically whenever you start Excel). -- Arvi Laanemets (When sending e-mail, use address arvil<At>tarkon.ee) "Joe" <Joe@discussions.microsoft.com> wrote in message news:AF3EABAE-6751-4917-88F1-1A5...

Function Call Problem
Could anyone help me with this Dialog App (first visual app). I am writing a test program for using Tab Controls. However, I have found that I am not sure how to call a class member function from the main dialog class to another dialog class. The program compiles normally. But the function call is causing an "Assertion Failed" error message whenever the button is clicked. It is used to print a number in a dialog of a tab control, and it also prints the same number in the main dialog. Both of these numbers are printed in Static Text Controls. This is the code from the main Dial...

count function in pivot table
How to count the number of types under certain group in a pivot table: Such as one sku occurs twice under one customer, I only need 1 in pivot table, instead of count the numbers of occurrences: 2 A pivot table won't calculate a unique count. You could add a column to the list, then add that field to the pivot table. There's an example here: http://www.contextures.com/xlPivot07.html#Unique Holly wrote: > How to count the number of types under certain group in a pivot table: > > Such as one sku occurs twice under one customer, I only need 1 in pivot > table, inst...

Money Won't Function
Greetings, I'm using Money 2006 Standard Edition, and I wanted to try the latest version of Money Essentials. The FAQ said there were no problems installing the trial alongside your existing installation because it installs into a separate directory. Well, my trial just expired, and now that I removed Money Essentials, I now have two problems: 1. Money 2006 no longer plays sounds. 2. When I click the "download" button at my bank's web site, the information no longer gets downloaded into Money. Instead I get a file download box with a filename ending in either *.ofx o...

Sub not Function!
To make a comparison of two tests I want to put the values next to eac other on a sheet. To do that, I have two Combo Boxes with each the same 15 choises...yo have to choose two different tests. Now, I'm having a problem to make my code short: -Dim leftChoise As Integer leftChoise = Sheets("Keuze").Range("E1").Value Dim rightChoise As Integer rightChoise = Sheets("Keuze").Range("K1").Value Select Case leftChoise Case 1 PutLeftOnReport ("B7") Case 2 PutLeftOnReport ("B29") Case 3 PutLeftOnReport ("B51") Don't u...

Write to a New Spreadsheet
I have a workbook that the first worksheet has all the information needed to create a report. What I would like to do is use the SUBTOTAL function and place the totals on a different sheet. Is this possible? Thanks for any help in advance. It is easier to use Pivot Table. Otherwise you need to "SUMIF" function. to build up the next worksheet. "Daniell" wrote: > I have a workbook that the first worksheet has all the information needed to > create a report. What I would like to do is use the SUBTOTAL function and > place the totals on a different sheet....

PivotTable canned functions
I am using Excel 2000 (9.0.2720). In my work I often faced with the task of creating ratios of CurrentListValue / CurrentSaleValue then need to perform various calculations on those ratios to identify and conclude on Central Tendencies (among other things) within categories from a parent array. The list of functions available for PivotTable calculation (I am assuming under the hood these are Array Functions) is very narrow. Only providing for Average, Standard Deviation, Min, Max, etc. Is there a way to add to this list, such as but not limited to, Average Deviation, Median, Geometr...