| Author |
Topic  |
|
|
tomo999
Here To Stay
 
United Kingdom
179 Posts
Status: offline |
Posted - 07/04/2012 : 10:31:43 AM
|
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
|
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" |
 |
|
|
tomo999
Here To Stay
 
United Kingdom
179 Posts
Status: offline |
Posted - 07/05/2012 : 09:50:01 AM
|
| 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. |
 |
|
|
JeffWouters
Here To Stay
 
Netherlands
147 Posts
Status: offline |
Posted - 07/05/2012 : 10:00:21 AM
|
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 |
 |
|
|
tomo999
Here To Stay
 
United Kingdom
179 Posts
Status: offline |
Posted - 07/05/2012 : 12:06:29 PM
|
| 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. |
 |
|
|
JeffWouters
Here To Stay
 
Netherlands
147 Posts
Status: offline |
Posted - 07/05/2012 : 4:48:33 PM
|
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. |
 |
|
|
tomo999
Here To Stay
 
United Kingdom
179 Posts
Status: offline |
Posted - 07/06/2012 : 05:07:34 AM
|
| That's the one! Thanks. |
Matt.
Failure is an indispensable prerequisite of success. It is how you learn the lessons you need. |
 |
|
| |
Topic  |
|