Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to create a txt file with specific info

$
0
0

Hi,

I'm back...

I'm trying to create one pure text file with this info:

<samaccountname> <name> \n

What I'm doing to get to it:

Import-Module ActiveDirectory

$users = Get-ADUser -Filter *

$users | ForEach-Object {$account = $_.SamAccountName;$name = $_.Name + " \n";write-host $account $name}

I get the info on the screen just the way I wanted with no headers... but using:

> C:\Test.txt

or

| Out-File C:\Test.txt

No luck... I get an empty txt file.... any help?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>