RE: PS export question

2012-08-07 Thread Joseph L. Casale


>Format-Table doesn't play nice with the pipeline past itself.

Simply put, ft/fl are for viewing data.
http://technet.microsoft.com/en-us/library/dd347677.aspx

"Windows PowerShell has a set of cmdlets that allow you to control which 
properties are
displayed for particular objects. The names of all the cmdlets begin with the 
verb Format.
They let you select one or more properties to show."

Its not meant to format output for writing to a file, though some incarnations 
work, sort of...

jlc





~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~   ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin



RE: PS export question

2012-08-07 Thread Guyer, Don
Much appreciated!

Regards,

Don Guyer
Catholic Health East - Information Technology
Enterprise Directory & Messaging Services
3805 West Chester Pike, Suite 100, Newtown Square, Pa  19073
email: dgu...@che.org<mailto:dgu...@che.org>
Office:  610.550.3595 | Cell: 610.955.6528 | Fax: 610.271.9440
For immediate assistance, please open a Service Desk ticket or call the 
helpdesk @ 610-492-3839.
[cid:image001.jpg@01CD7479.AADF2CF0]

From: Steven Peck [mailto:sep...@gmail.com]
Sent: Monday, August 06, 2012 4:26 PM
To: NT System Admin Issues
Subject: Re: PS export question

Format-Table doesn't play nice with the pipeline past itself.  From your 
example I suspect you used Out-File instead of Export-CSV.  I just did as a 
quick test of both and the output is not nearly as pretty as Export-CSV

Using select-object you narow down which items get passed down the pipeline but 
you still preserve all the data, etc.  This will play nice with the various 
Export-* commands.  The various Format-* commands are realy for output to the 
screen as your end destination.  They dont seem to play nice with the pipeline 
past themselves.  The downside to select-object is that ONLY the items you 
select are passed along.  Everything else gets dropped.  For most basic 
scripts/cmdline uses this is fine. It only gets complicated if you wanted to do 
more stuff with other data in the object.

So, as a habit when playing with data, I would suggest using select-object as 
it plays nice with the pipelines which opens up a world of oportunity later.

You should definitly check out the 3 videos I suggested earlier.  I'm still 
learning stuff I missed myself and I posted some notes on what I learned in the 
last one. I need to go back over the remoting one so may post notes on that one 
as well.
http://www.blkmtn.org/PowerShell-neat_function_tricks_for_free

MBS or one of the others will point out if I don't have this quite right as he 
is way better at PowerShell than I am, but the PowerShell community as a 
practice tends to discourage Format-* as the output point in scripts. It tends 
to make it less useful in the long run for flexibility and re-use.

Steven Peck
http://www.blkmtn.org


On Mon, Aug 6, 2012 at 12:28 PM, Guyer, Don 
mailto:dgu...@che.org>> wrote:
That's interesting because I just used Format Table to export a list of 
addresses and SAM accounts for over 4k users, to an Excel file.

Keep in mind, I'm just now FINALLY getting to learn and use PS more.

Regards,

Don Guyer
Catholic Health East - Information Technology
Enterprise Directory & Messaging Services
3805 West Chester Pike, Suite 100, Newtown Square, Pa  19073
email: dgu...@che.org<mailto:dgu...@che.org>
Office:  610.550.3595 | Cell: 610.955.6528 
| Fax: 610.271.9440
For immediate assistance, please open a Service Desk ticket or call the 
helpdesk @ 610-492-3839.
[cid:image001.jpg@01CD7479.AADF2CF0]

From: Steven Peck [mailto:sep...@gmail.com<mailto:sep...@gmail.com>]
Sent: Monday, August 06, 2012 3:18 PM

To: NT System Admin Issues
Subject: Re: PS export question

oO
Ya, don't use Format-Table.  Format-Table will display to the screen but won't 
go to the file.  For this you can use Select-Object.  Select-Object has some 
other side effects that aren't important in this context.

I tested with
$user = Get-QADUser -sizelimit 0
$user | select displayname, name, passwordlastset -first 10 | Export-Csv 
./testFile.csv -NoTypeInformation

Once that worked, I removed the -first 10 from select
The -NoTypeInformation is to remove the annoying .NET type line that gets put 
on the first line of the CSV file.  The -sizelimit 0 will get you past the 
default query limit of AD.

$user | select displayname, name, passwordlastset | Export-Csv ./testFile.csv 
-NoTypeInformation

Side notes... When dealing with larger data, I tend to dump the query into a 
variable.  This way I am playing with the data locally and not waiting for the 
query to complete each time I test.

There are three nice powershell videos you may want to check out here:
http://www.blkmtn.org/TechEd-2012-Videos


Steven Peck
http://www.blkmtn.org




On Mon, Aug 6, 2012 at 11:04 AM, Jimmy Tran 
mailto:jt...@teachtci.com>> wrote:
I'm trying to get a list of passwords last set from AD for my users.

I run:
add-PSSnapin quest.activeroles.admanagement
Get-QADUser |ft displayname,PasswordLastSet | export-csv -path 
c:\PasswordLastSet.csv

But the data doesn't come back as expected.  If I omit the export command, the 
results show fine in PS.  What am I doing wrong?

TIA,

Jimmy


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>

RE: PS export question

2012-08-06 Thread Jimmy Tran
Thank you. That worked like a charm.

 

From: Christopher Bodnar [mailto:christopher_bod...@glic.com] 
Sent: Monday, August 06, 2012 11:29 AM
To: NT System Admin Issues
Subject: Re: PS export question

 

Try this: 

get-qaduser |select displayname,PasswordLastSet|export-csv c:\temp\pw1.csv 




Christopher Bodnar 
Enterprise Achitect I, Corporate Office of Technology:Enterprise Architecture 
and Engineering Services 

Tel 610-807-6459  
3900 Burgess Place, Bethlehem, PA 18017 
christopher_bod...@glic.com   

 

The Guardian Life Insurance Company of America

www.guardianlife.com <http://www.guardianlife.com/>  








From:"Jimmy Tran"  
To:"NT System Admin Issues"  
Date:08/06/2012 02:19 PM 
Subject:PS export question 






I’m trying to get a list of passwords last set from AD for my users. 
  
I run: 
add-PSSnapin quest.activeroles.admanagement 
Get-QADUser |ft displayname,PasswordLastSet | export-csv -path 
c:\PasswordLastSet.csv 
  
But the data doesn’t come back as expected.  If I omit the export command, the 
results show fine in PS.  What am I doing wrong? 
  
TIA, 

Jimmy 
  

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin 

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin
<>

Re: PS export question

2012-08-06 Thread Steven Peck
Format-Table doesn't play nice with the pipeline past itself.  From your
example I suspect you used Out-File instead of Export-CSV.  I just did as a
quick test of both and the output is not nearly as pretty as Export-CSV

Using select-object you narow down which items get passed down the pipeline
but you still preserve all the data, etc.  This will play nice with the
various Export-* commands.  The various Format-* commands are realy for
output to the screen as your end destination.  They dont seem to play nice
with the pipeline past themselves.  The downside to select-object is that
ONLY the items you select are passed along.  Everything else gets dropped.
For most basic scripts/cmdline uses this is fine. It only gets complicated
if you wanted to do more stuff with other data in the object.

So, as a habit when playing with data, I would suggest using select-object
as it plays nice with the pipelines which opens up a world of oportunity
later.

You should definitly check out the 3 videos I suggested earlier.  I'm still
learning stuff I missed myself and I posted some notes on what I learned in
the last one. I need to go back over the remoting one so may post notes on
that one as well.
http://www.blkmtn.org/PowerShell-neat_function_tricks_for_free

MBS or one of the others will point out if I don't have this quite right as
he is way better at PowerShell than I am, but the PowerShell community as a
practice tends to discourage Format-* as the output point in scripts. It
tends to make it less useful in the long run for flexibility and re-use.

Steven Peck
http://www.blkmtn.org


On Mon, Aug 6, 2012 at 12:28 PM, Guyer, Don  wrote:

> That’s interesting because I just used Format Table to export a list of
> addresses and SAM accounts for over 4k users, to an Excel file.
>
> ** **
>
> Keep in mind, I’m just now FINALLY getting to learn and use PS more.
>
> ** **
>
> Regards,
>
> * *
>
> *Don Guyer**
> **Catholic Health East - Information Technology*
>
> Enterprise Directory & Messaging Services
> 3805 West Chester Pike, Suite 100, Newtown Square, Pa  19073
>
> email: *dgu...@che.org*
>
> Office:  610.550.3595 | Cell: 610.955.6528 | Fax: 610.271.9440
>
> *For immediate assistance, please open a Service Desk ticket or call the
> helpdesk @ 610-492-3839.*
>
> [image: Description: Description: Description: InfoService-Logo240]
>
> ** **
>
> *From:* Steven Peck [mailto:sep...@gmail.com]
> *Sent:* Monday, August 06, 2012 3:18 PM
>
> *To:* NT System Admin Issues
> *Subject:* Re: PS export question
>
> ** **
>
> oO 
>
> Ya, don't use Format-Table.  Format-Table will display to the screen but
> won't go to the file.  For this you can use Select-Object.  Select-Object
> has some other side effects that aren't important in this context.
>
>  
>
> I tested with
>
> $user = Get-QADUser -sizelimit 0
>
> $user | select displayname, name, passwordlastset -first 10 | Export-Csv
> ./testFile.csv -NoTypeInformation
>
>  
>
> Once that worked, I removed the -first 10 from select
>
> The -NoTypeInformation is to remove the annoying .NET type line that gets
> put on the first line of the CSV file.  The -sizelimit 0 will get you past
> the default query limit of AD.
>
>  
>
> $user | select displayname, name, passwordlastset | Export-Csv
> ./testFile.csv -NoTypeInformation
>
>  
>
> Side notes... When dealing with larger data, I tend to dump the query into
> a variable.  This way I am playing with the data locally and not waiting
> for the query to complete each time I test.
>
>  
>
> There are three nice powershell videos you may want to check out here:
>
> http://www.blkmtn.org/TechEd-2012-Videos
>
>  
>
>  
>
> Steven Peck
>
> http://www.blkmtn.org
>
>  
>
>
>
>  
>
> On Mon, Aug 6, 2012 at 11:04 AM, Jimmy Tran  wrote:***
> *
>
> I’m trying to get a list of passwords last set from AD for my users.
>
>  
>
> I run: 
>
> add-PSSnapin quest.activeroles.admanagement
>
> Get-QADUser |ft displayname,PasswordLastSet | export-csv -path
> c:\PasswordLastSet.csv
>
>  
>
> But the data doesn’t come back as expected.  If I omit the export command,
> the results show fine in PS.  What am I doing wrong?
>
>  
>
> TIA,
>
>
> Jimmy
>
>  
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/re

RE: PS export question

2012-08-06 Thread Guyer, Don
That's interesting because I just used Format Table to export a list of 
addresses and SAM accounts for over 4k users, to an Excel file.

Keep in mind, I'm just now FINALLY getting to learn and use PS more.

Regards,

Don Guyer
Catholic Health East - Information Technology
Enterprise Directory & Messaging Services
3805 West Chester Pike, Suite 100, Newtown Square, Pa  19073
email: dgu...@che.org<mailto:dgu...@che.org>
Office:  610.550.3595 | Cell: 610.955.6528 | Fax: 610.271.9440
For immediate assistance, please open a Service Desk ticket or call the 
helpdesk @ 610-492-3839.
[cid:image001.jpg@01CD73E8.2568BB40]

From: Steven Peck [mailto:sep...@gmail.com]
Sent: Monday, August 06, 2012 3:18 PM
To: NT System Admin Issues
Subject: Re: PS export question

oO
Ya, don't use Format-Table.  Format-Table will display to the screen but won't 
go to the file.  For this you can use Select-Object.  Select-Object has some 
other side effects that aren't important in this context.

I tested with
$user = Get-QADUser -sizelimit 0
$user | select displayname, name, passwordlastset -first 10 | Export-Csv 
./testFile.csv -NoTypeInformation

Once that worked, I removed the -first 10 from select
The -NoTypeInformation is to remove the annoying .NET type line that gets put 
on the first line of the CSV file.  The -sizelimit 0 will get you past the 
default query limit of AD.

$user | select displayname, name, passwordlastset | Export-Csv ./testFile.csv 
-NoTypeInformation

Side notes... When dealing with larger data, I tend to dump the query into a 
variable.  This way I am playing with the data locally and not waiting for the 
query to complete each time I test.

There are three nice powershell videos you may want to check out here:
http://www.blkmtn.org/TechEd-2012-Videos


Steven Peck
http://www.blkmtn.org




On Mon, Aug 6, 2012 at 11:04 AM, Jimmy Tran 
mailto:jt...@teachtci.com>> wrote:
I'm trying to get a list of passwords last set from AD for my users.

I run:
add-PSSnapin quest.activeroles.admanagement
Get-QADUser |ft displayname,PasswordLastSet | export-csv -path 
c:\PasswordLastSet.csv

But the data doesn't come back as expected.  If I omit the export command, the 
results show fine in PS.  What am I doing wrong?

TIA,

Jimmy


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe ntsysadmin
Confidentiality Notice:
This e-mail, including any attachments is the 
property of Catholic Health East and is intended 
for the sole use of the intended recipient(s).  
It may contain information that is privileged and 
confidential.  Any unauthorized review, use,
disclosure, or distribution is prohibited. If you are 
not the intended recipient, please delete this message, and 
reply to the sender regarding the error in a separate email.

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin<>

Re: PS export question

2012-08-06 Thread Steven Peck
oO
Ya, don't use Format-Table.  Format-Table will display to the screen but
won't go to the file.  For this you can use Select-Object.  Select-Object
has some other side effects that aren't important in this context.

I tested with
$user = Get-QADUser -sizelimit 0
$user | select displayname, name, passwordlastset -first 10 | Export-Csv
./testFile.csv -NoTypeInformation

Once that worked, I removed the -first 10 from select
The -NoTypeInformation is to remove the annoying .NET type line that gets
put on the first line of the CSV file.  The -sizelimit 0 will get you past
the default query limit of AD.

$user | select displayname, name, passwordlastset | Export-Csv
./testFile.csv -NoTypeInformation

Side notes... When dealing with larger data, I tend to dump the query into
a variable.  This way I am playing with the data locally and not waiting
for the query to complete each time I test.

There are three nice powershell videos you may want to check out here:
http://www.blkmtn.org/TechEd-2012-Videos


Steven Peck
http://www.blkmtn.org




On Mon, Aug 6, 2012 at 11:04 AM, Jimmy Tran  wrote:

> I’m trying to get a list of passwords last set from AD for my users.
>
> ** **
>
> I run: 
>
> add-PSSnapin quest.activeroles.admanagement
>
> Get-QADUser |ft displayname,PasswordLastSet | export-csv -path
> c:\PasswordLastSet.csv
>
> ** **
>
> But the data doesn’t come back as expected.  If I omit the export command,
> the results show fine in PS.  What am I doing wrong?
>
> ** **
>
> TIA,
>
>
> Jimmy
>
> ** **
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~   ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to listmana...@lyris.sunbeltsoftware.com
> with the body: unsubscribe ntsysadmin
>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~   ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

RE: PS export question

2012-08-06 Thread Guyer, Don
How about:

Get-QADuser| Format-Table displayname, passwordlastset | Out-File 
C:\PasswordLastSet.Csv

Regards,

Don Guyer
Catholic Health East - Information Technology
Enterprise Directory & Messaging Services
3805 West Chester Pike, Suite 100, Newtown Square, Pa  19073
email: dgu...@che.org
Office:  610.550.3595 | Cell: 610.955.6528 | Fax: 610.271.9440
For immediate assistance, please open a Service Desk ticket or call the 
helpdesk @ 610-492-3839.
[cid:image001.jpg@01CD73E1.7CE68390]

From: Jimmy Tran [mailto:jt...@teachtci.com]
Sent: Monday, August 06, 2012 2:04 PM
To: NT System Admin Issues
Subject: PS export question

I'm trying to get a list of passwords last set from AD for my users.

I run:
add-PSSnapin quest.activeroles.admanagement
Get-QADUser |ft displayname,PasswordLastSet | export-csv -path 
c:\PasswordLastSet.csv

But the data doesn't come back as expected.  If I omit the export command, the 
results show fine in PS.  What am I doing wrong?

TIA,

Jimmy


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~   ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin
Confidentiality Notice:
This e-mail, including any attachments is the 
property of Catholic Health East and is intended 
for the sole use of the intended recipient(s).  
It may contain information that is privileged and 
confidential.  Any unauthorized review, use,
disclosure, or distribution is prohibited. If you are 
not the intended recipient, please delete this message, and 
reply to the sender regarding the error in a separate email.

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~   ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin<>

Re: PS export question

2012-08-06 Thread Christopher Bodnar
Try this:

get-qaduser |select displayname,PasswordLastSet|export-csv c:\temp\pw1.csv




Christopher Bodnar 
Enterprise Achitect I, Corporate Office of Technology:Enterprise 
Architecture and Engineering Services 
Tel 610-807-6459 
3900 Burgess Place, Bethlehem, PA 18017 
christopher_bod...@glic.com 




The Guardian Life Insurance Company of America

www.guardianlife.com 







From:   "Jimmy Tran" 
To: "NT System Admin Issues" 
Date:   08/06/2012 02:19 PM
Subject:PS export question



I’m trying to get a list of passwords last set from AD for my users.
 
I run: 
add-PSSnapin quest.activeroles.admanagement
Get-QADUser |ft displayname,PasswordLastSet | export-csv -path 
c:\PasswordLastSet.csv
 
But the data doesn’t come back as expected.  If I omit the export command, 
the results show fine in PS.  What am I doing wrong?
 
TIA,

Jimmy
 
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~   ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin


-
This message, and any attachments to it, may contain information
that is privileged, confidential, and exempt from disclosure under
applicable law.  If the reader of this message is not the intended
recipient, you are notified that any use, dissemination,
distribution, copying, or communication of this message is strictly
prohibited.  If you have received this message in error, please
notify the sender immediately by return e-mail and delete the
message and any attachments.  Thank you.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~   ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin
<>