How to use two echo commands to print data on one line using PowerShell

前端 未结 3 1680
南方客
南方客 2021-01-23 18:18

Below is the code I\'m using to find users created date and last logon date which is then written to a .csv file.

$users=Get-ADuser -SearchBase \"OU=testou1,dc=U         


        
3条回答
  •  鱼传尺愫
    2021-01-23 18:53

    Just so you know echo in PowerShell is actually an alias for Write-Output.

    PS Z:\> get-alias echo
    
    CommandType     Name                                               ModuleName                                                                                
    -----------     ----                                               ----------                                                                                
    Alias           echo -> Write-Output   
    

    If you look at the TechNet article it does not natively support any append type parameter or newline suppression. That does not mean you can't do it. Just not without any help.

    echo/Write-Output would just be sending data to the output stream. Is there a reason you need your text to do that? Is there by chance a better example you can provide of what you are trying to accomplish? FYI there are other cmdlets at work behind the scenes that being used as well like Out-Default

    Write-Host is really what you want. Yes I am aware you said you didn't want it but I wanted you to see for sure.

    PS Z:\> Write-host "Hai" -NoNewline; Write-Host "Hello"
    HaiHello
    

提交回复
热议问题