Mark Minasi's Reader Forum
Mark Minasi's Reader Forum
Home | Profile | Register | Active Topics | Active Polls | Members | Search | FAQ | Minasi Forum RSS Feed
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 HALP! Questions on Windows and Windows Server
 PowerShell
 Output To File
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tomo999
Here To Stay

United Kingdom
179 Posts
Status: offline

Posted - 07/04/2012 :  10:31:43 AM  Show Profile  Reply with Quote
Hi everyone,

Ok, this has me tearing my hair out... I want to run the following command against our domain;

Get-CsAdUser -Filter {windowsemailaddress -like '*@emailaddress.com'} -OU "ou=OrgUnit,DC=domain,DC=internal" | Enable-CsUser -RegistrarPool "lync.domain.internal" -SIPAddressType FirstLastName -SipDomain "domain.internal" -WhatIf

However, I want the output of this command to go to a text file rather than the Powershell window. I've tried using the following;

Get-CsAdUser -Filter {windowsemailaddress -like '*@emailaddress.com'} -OU "ou=OrgUnit,DC=domain,DC=internal" | Enable-CsUser -RegistrarPool "lync.domain.internal" -SIPAddressType FirstLastName -SipDomain "domain.internal" -WhatIf | Export-Csv "c:\output.txt"

Get-CsAdUser -Filter {windowsemailaddress -like '*@emailaddress.com'} -OU "ou=OrgUnit,DC=domain,DC=internal" | Enable-CsUser -RegistrarPool "lync.domain.internal" -SIPAddressType FirstLastName -SipDomain "domain.internal" -WhatIf | Out-File "c:\output.txt"

I even tried saving the command into a ps1 file and trying to export this information from there. However, no matter what I try to do it always sends the output to the screen!!

Can anyone help?

Matt.

Failure is an indispensable prerequisite of success. It is how you learn the lessons you need.

JSCLMEDAVE
Administrator

USA
6116 Posts
Status: online

Posted - 07/04/2012 :  10:44:49 AM  Show Profile  Visit JSCLMEDAVE's Homepage  Click to see JSCLMEDAVE's MSN Messenger address  Reply with Quote
Try taking off the " " on your file path.

Although I have never seen anyone do a -whatif | I am sure its not going to be piped.

You "may" try

Get-CsAdUser -Filter {windowsemailaddress -like '*@emailaddress.com'} -OU "ou=OrgUnit,DC=domain,DC=internal" | Enable-CsUser -RegistrarPool "lync.domain.internal" -SIPAddressType FirstLastName -SipDomain "domain.internal" -WhatIf > c:\output.txt


Tim-

“This too shall pass"
Go to Top of Page

tomo999
Here To Stay

United Kingdom
179 Posts
Status: offline

Posted - 07/05/2012 :  09:50:01 AM  Show Profile  Reply with Quote
Hmmm, neither of those worked. The reason why I want to output the -whatif output is because I could be running this command against hundreds of users, and I want to check the errors before I run the command for real.

Matt.

Failure is an indispensable prerequisite of success. It is how you learn the lessons you need.
Go to Top of Page

JeffWouters
Here To Stay

Netherlands
147 Posts
Status: offline

Posted - 07/05/2012 :  10:00:21 AM  Show Profile  Visit JeffWouters's Homepage  Click to see JeffWouters's MSN Messenger address  Look at the Skype address for JeffWouters  Reply with Quote
Take out the "-WhatIf"... I encountered this last week :-)
Be aware that this will execute the task, and pipe the output to a file... so you may want to run it with -whatif but without the redirection to the file first just to see that you're not doing something you don't want...

Greetsz,
Jeff.

Edited by - JeffWouters on 07/05/2012 10:02:27 AM
Go to Top of Page

tomo999
Here To Stay

United Kingdom
179 Posts
Status: offline

Posted - 07/05/2012 :  12:06:29 PM  Show Profile  Reply with Quote
Yeah that was kind of the point. With the -WhatIf command it works for most users, but I can see some red text whizz up the screen as the task executes. Ideally I need to check which accounts are going to error before I run the command against live accounts...

Matt.

Failure is an indispensable prerequisite of success. It is how you learn the lessons you need.
Go to Top of Page

JeffWouters
Here To Stay

Netherlands
147 Posts
Status: offline

Posted - 07/05/2012 :  4:48:33 PM  Show Profile  Visit JeffWouters's Homepage  Click to see JeffWouters's MSN Messenger address  Look at the Skype address for JeffWouters  Reply with Quote
So, you want to use the -WhatIf parameter to do an inventory of the issues you may encounter while executing the command?
Workaround: Use th Start-Transcript and Stop-Transcript cmdlets :-)

Greetsz,
Jeff.
Go to Top of Page

tomo999
Here To Stay

United Kingdom
179 Posts
Status: offline

Posted - 07/06/2012 :  05:07:34 AM  Show Profile  Reply with Quote
That's the one! Thanks.

Matt.

Failure is an indispensable prerequisite of success. It is how you learn the lessons you need.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Mark Minasi's Reader Forum © 2002-2011 Mark Minasi Go To Top Of Page
This page was generated in 0.11 seconds. Snitz Forums 2000