Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - uploading script results to a csv file

Reply
 
Old 12-19-2007   #1 (permalink)
Shay Levi


 
 

Re: uploading script results to a csv file


You can try Export-Csv:

Get-QADGroupMember Get-QADGroupMember 'domain\group name' | Export-Csv -path
pathToFilename.csv



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> Hi guys .
>
> when i use the powershell to extract the active directory users of a
> certain group i use the command
>
> Get-QADGroupMember Get-QADGroupMember 'domain\group name '
>
> my question is how do i upload the results on a csv file (excel
> format) from within the script
>
> is there a line i can add into this script to export it directly to a
> csv file ?
>
> tnx in advance
>


My System SpecsSystem Spec
Old 12-19-2007   #2 (permalink)
don5


 
 

uploading script results to a csv file

Hi guys .

when i use the powershell to extract the active directory users of a certain
group i use the command

Get-QADGroupMember Get-QADGroupMember 'domain\group name '

my question is how do i upload the results on a csv file (excel format) from
within the script

is there a line i can add into this script to export it directly to a csv
file ?

tnx in advance
My System SpecsSystem Spec
Old 12-19-2007   #3 (permalink)
Jacob Saaby Nielsen


 
 

Re: uploading script results to a csv file

Hey don5,

my guess (without having tested it) would be:

Get-QADGroupMember 'domain\group name ' | Export-CSV 'c:\test\adusers.csv'

Best Regards,
Jacob Saaby Nielsen
mailto:jacob.saaby@xxxxxx
Quote:

> Hi guys .
>
> when i use the powershell to extract the active directory users of a
> certain group i use the command
>
> Get-QADGroupMember Get-QADGroupMember 'domain\group name '
>
> my question is how do i upload the results on a csv file (excel
> format) from within the script
>
> is there a line i can add into this script to export it directly to a
> csv file ?
>
> tnx in advance
>

My System SpecsSystem Spec
Old 12-19-2007   #4 (permalink)
Jacob Saaby Nielsen


 
 

Re: uploading script results to a csv file

Hey don5,

oh yeah - I forgot the -path parameter, so use Shay's example instead

Best Regards,
Jacob Saaby Nielsen

http://www.pipforhelvede.net
jacob DOT saaby AT gmail (same at hotmail for IM)
Quote:

> You can try Export-Csv:
>
> Get-QADGroupMember Get-QADGroupMember 'domain\group name' | Export-Csv
> -path pathToFilename.csv
>
> -----
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
Quote:

>> Hi guys .
>>
>> when i use the powershell to extract the active directory users of a
>> certain group i use the command
>>
>> Get-QADGroupMember Get-QADGroupMember 'domain\group name '
>>
>> my question is how do i upload the results on a csv file (excel
>> format) from within the script
>>
>> is there a line i can add into this script to export it directly to a
>> csv file ?
>>
>> tnx in advance
>>

My System SpecsSystem Spec
Old 12-20-2007   #5 (permalink)
don5


 
 

RE: uploading script results to a csv file

hi shay , i tried the "export-csv" and the problem is that i get a list of
numbers in the csv file rather then the names that were supposed to be . what
i used was like this :

function get-members{
param($groupName)

Get-QADGroupMember -Identity $groupName | foreach {
if($_.type -eq "user") {$_.name}
elseif($_.type -eq "group") {$_.name; get-members -groupName
$_.CanonicalName}

}
}


get-members "rwn\Retalix Raanana (Tia)" |export-csv c:\msh\users.csv

"don5" wrote:
Quote:

> Hi guys .
>
> when i use the powershell to extract the active directory users of a certain
> group i use the command
>
> Get-QADGroupMember Get-QADGroupMember 'domain\group name '
>
> my question is how do i upload the results on a csv file (excel format) from
> within the script
>
> is there a line i can add into this script to export it directly to a csv
> file ?
>
> tnx in advance
My System SpecsSystem Spec
Old 12-20-2007   #6 (permalink)
Shay Levi


 
 

RE: uploading script results to a csv file

OK Raanana ;-)

For some reason, still need to figure out why, the output numbers you see
are the length of each name..
To overcome it, use a calculated property (on select-string) to rebuild the
name column:

# the full syntax is @{name="stringName";expression={<expression>}}
# it can be shortend to @{n="...";e={...}}
# the -NoTypeInformation Omits the #TYPE header from the CSV file

get-members "rwn\Retalix Raanana (Tia)" | select @{n="name";e={$_}} | Export-Csv
..\users.csv -NoTypeInformation


In addition, be aware that nested groups can cause your script to (e.g group
A contains group B contains group C contains group A)
as Kirk warned.


-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> hi shay , i tried the "export-csv" and the problem is that i get a
> list of numbers in the csv file rather then the names that were
> supposed to be . what i used was like this :
>
> function get-members{ param($groupName)
>
> Get-QADGroupMember -Identity $groupName | foreach { if($_.type -eq
> "user") {$_.name} elseif($_.type -eq "group") {$_.name; get-members
> -groupName $_.CanonicalName}
>
> } }
>
> get-members "rwn\Retalix Raanana (Tia)" |export-csv c:\msh\users.csv
>
> "don5" wrote:
>
Quote:

>> Hi guys .
>>
>> when i use the powershell to extract the active directory users of a
>> certain group i use the command
>>
>> Get-QADGroupMember Get-QADGroupMember 'domain\group name '
>>
>> my question is how do i upload the results on a csv file (excel
>> format) from within the script
>>
>> is there a line i can add into this script to export it directly to a
>> csv file ?
>>
>> tnx in advance
>>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Export results of script with cmd command to csv PowerShell
Echo results of script to file PowerShell
exporting results/text of powershell script to a file as it is run PowerShell
Re: checking for results when executing a script PowerShell
Need help in uploading audio file to WMM/legitimately purchased mu Vista music pictures video


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46