Keeping output on the same lineParsing variables into Get-ADUser CMDLT - Error parsing queryGet-ADuser : The search filter cannot be recognizedPOWERSHELL - Using an array with a Foreach look, looking at users in an OU -Get-AdUsers in a for-each loop with appended characters in powershellCombine powershell outputHow to display “Description” attribute in any user's account?How use “Where-Object” condition with '[PScustomobject]'?issues getting output from powershellGet-ADUser syntax error when searching against GivenName and SurnameDisable users from valid list
Word to describe someone doing something even though told not to
What is the reason behind water not falling from a bucket at the top of loop?
How to trick a fairly simplistic kill-counter?
Who's behind community AMIs on Amazon EC2?
How do I respond appropriately to an overseas company that obtained a visa for me without hiring me?
Can living where rare earth magnetic ore is abundant provide any protection from cosmic radiation?
How long should I wait to plug in my refrigerator after unplugging it?
Is Norway in the Single Market?
Checking whether the win-loss standings of a league are possible
Protect a 6 inch air hose from physical damage
Feedback diagram
Move label of an angle in Tikz
Flat maps and Zariski tangent spaces
Does KNN have a loss function?
How to get rid of leading zeros in a number?
How does Asimov's second law deal with contradictory orders from different people?
A way of getting tenure for a non-creative person
Is Illustrator accurate for business card sizes?
Backpacking with incontinence
Can birds evolve without trees?
How to structure presentation to avoid getting questions that will be answered later in the presentation?
How is Sword Coast North governed?
How did Biff return to 2015 from 1955 without a lightning strike?
Using Python in a Bash Script
Keeping output on the same line
Parsing variables into Get-ADUser CMDLT - Error parsing queryGet-ADuser : The search filter cannot be recognizedPOWERSHELL - Using an array with a Foreach look, looking at users in an OU -Get-AdUsers in a for-each loop with appended characters in powershellCombine powershell outputHow to display “Description” attribute in any user's account?How use “Where-Object” condition with '[PScustomobject]'?issues getting output from powershellGet-ADUser syntax error when searching against GivenName and SurnameDisable users from valid list
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to keep the output of this command on the same line:
((Get-ADUser -filter employeetype -eq "Employee").SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object $_.Name,$_.Department,$_mail
Currently the output shows up like this:
James Roberts
Accounting
jroberts@email.tld
But, I need to have it show up like:
James Roberts Accounting jroberts@email.tld
I've also tried using (based on a suggestion I found):
((Get-ADUser -filter employeetype -eq "Employee").SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object $_.Name;$_.Department;$_mail
but, I get the same three lines of output and not one line.
powershell
add a comment |
I want to keep the output of this command on the same line:
((Get-ADUser -filter employeetype -eq "Employee").SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object $_.Name,$_.Department,$_mail
Currently the output shows up like this:
James Roberts
Accounting
jroberts@email.tld
But, I need to have it show up like:
James Roberts Accounting jroberts@email.tld
I've also tried using (based on a suggestion I found):
((Get-ADUser -filter employeetype -eq "Employee").SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object $_.Name;$_.Department;$_mail
but, I get the same three lines of output and not one line.
powershell
2
Instead ofForeach-Objectyou should useSelect-Object -Property
– Olaf
Mar 27 at 0:54
to get those items on the same line, you can use-joinwith whatever delimiter you want. [grin] take a look atGet-Help about_Joinfor some useful examples.
– Lee_Dailey
Mar 27 at 1:02
add a comment |
I want to keep the output of this command on the same line:
((Get-ADUser -filter employeetype -eq "Employee").SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object $_.Name,$_.Department,$_mail
Currently the output shows up like this:
James Roberts
Accounting
jroberts@email.tld
But, I need to have it show up like:
James Roberts Accounting jroberts@email.tld
I've also tried using (based on a suggestion I found):
((Get-ADUser -filter employeetype -eq "Employee").SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object $_.Name;$_.Department;$_mail
but, I get the same three lines of output and not one line.
powershell
I want to keep the output of this command on the same line:
((Get-ADUser -filter employeetype -eq "Employee").SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object $_.Name,$_.Department,$_mail
Currently the output shows up like this:
James Roberts
Accounting
jroberts@email.tld
But, I need to have it show up like:
James Roberts Accounting jroberts@email.tld
I've also tried using (based on a suggestion I found):
((Get-ADUser -filter employeetype -eq "Employee").SamAccountName) | Sort-Object | Get-ADUser | ForEach-Object $_.Name;$_.Department;$_mail
but, I get the same three lines of output and not one line.
powershell
powershell
asked Mar 27 at 0:22
lutevaluteva
132 bronze badges
132 bronze badges
2
Instead ofForeach-Objectyou should useSelect-Object -Property
– Olaf
Mar 27 at 0:54
to get those items on the same line, you can use-joinwith whatever delimiter you want. [grin] take a look atGet-Help about_Joinfor some useful examples.
– Lee_Dailey
Mar 27 at 1:02
add a comment |
2
Instead ofForeach-Objectyou should useSelect-Object -Property
– Olaf
Mar 27 at 0:54
to get those items on the same line, you can use-joinwith whatever delimiter you want. [grin] take a look atGet-Help about_Joinfor some useful examples.
– Lee_Dailey
Mar 27 at 1:02
2
2
Instead of
Foreach-Object you should use Select-Object -Property– Olaf
Mar 27 at 0:54
Instead of
Foreach-Object you should use Select-Object -Property– Olaf
Mar 27 at 0:54
to get those items on the same line, you can use
-join with whatever delimiter you want. [grin] take a look at Get-Help about_Join for some useful examples.– Lee_Dailey
Mar 27 at 1:02
to get those items on the same line, you can use
-join with whatever delimiter you want. [grin] take a look at Get-Help about_Join for some useful examples.– Lee_Dailey
Mar 27 at 1:02
add a comment |
1 Answer
1
active
oldest
votes
If you want to create customized objects:
… | Select-Object -Property Name,Department,Mail
If you want to make strings:
… | ForEach-Object $_.Name,$_.Department,$_.Mail -join " "
If you just want to display the table nicely (not going to use this output afterwards):
… | Format-Table -Property Name,Department,Mail -AutoSize
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368043%2fkeeping-output-on-the-same-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to create customized objects:
… | Select-Object -Property Name,Department,Mail
If you want to make strings:
… | ForEach-Object $_.Name,$_.Department,$_.Mail -join " "
If you just want to display the table nicely (not going to use this output afterwards):
… | Format-Table -Property Name,Department,Mail -AutoSize
add a comment |
If you want to create customized objects:
… | Select-Object -Property Name,Department,Mail
If you want to make strings:
… | ForEach-Object $_.Name,$_.Department,$_.Mail -join " "
If you just want to display the table nicely (not going to use this output afterwards):
… | Format-Table -Property Name,Department,Mail -AutoSize
add a comment |
If you want to create customized objects:
… | Select-Object -Property Name,Department,Mail
If you want to make strings:
… | ForEach-Object $_.Name,$_.Department,$_.Mail -join " "
If you just want to display the table nicely (not going to use this output afterwards):
… | Format-Table -Property Name,Department,Mail -AutoSize
If you want to create customized objects:
… | Select-Object -Property Name,Department,Mail
If you want to make strings:
… | ForEach-Object $_.Name,$_.Department,$_.Mail -join " "
If you just want to display the table nicely (not going to use this output afterwards):
… | Format-Table -Property Name,Department,Mail -AutoSize
edited Mar 27 at 1:41
mklement0
151k25 gold badges272 silver badges313 bronze badges
151k25 gold badges272 silver badges313 bronze badges
answered Mar 27 at 1:17
rokumarurokumaru
8581 gold badge3 silver badges9 bronze badges
8581 gold badge3 silver badges9 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368043%2fkeeping-output-on-the-same-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Instead of
Foreach-Objectyou should useSelect-Object -Property– Olaf
Mar 27 at 0:54
to get those items on the same line, you can use
-joinwith whatever delimiter you want. [grin] take a look atGet-Help about_Joinfor some useful examples.– Lee_Dailey
Mar 27 at 1:02