?
Solved

PowerShell Function Output

Posted on 2013-12-16
2
Medium Priority
?
708 Views
Last Modified: 2013-12-17
I'm calling the attached module (found here: http://gallery.technet.microsoft.com/scriptcenter/Get-LockedOutLocation-b2fd0cab)  from the following PowerShell script:

$Identity = Read-Host 'Please enter the user name of the locked account (e.g. jdoe)'
Get-LockedOutLocation -Identity $Identity
Read-Host 'Press Enter to continue...' | Out-Null

Open in new window


The output I expect is:
PS C:\Users\pkrueger\Desktop> C:\Users\pkrueger\Desktop\test.ps1
Please enter the user name of the locked account (e.g. jdoe): pktesting

Name      LockedOut DomainController              BadPwdCount AccountLockoutTime    LastBadPasswordAttempt
----      --------- ----------------              ----------- ------------------    ----------------------
pktesting      True DC1.fubar.domain.com           		0 12/16/2013 3:08:28 PM 6/3/2013 2:16:53 PM   
pktesting      True	DC2.fubar.domain.com            	0 12/16/2013 3:08:28 PM 4/23/2013 9:48:48 AM  
pktesting      True	DC3.fubar.domain.com           		6 12/16/2013 3:08:28 PM 12/16/2013 3:08:28 PM 
pktesting      True	DC4.fubar.domain.com            	0 12/16/2013 3:08:28 PM 2/21/2013 10:25:01 AM 


User               : pktesting
DomainController   : DC1.fubar.domain.com
EventId            : 4740
LockedOutTimeStamp : 12/16/2013 3:08:28 PM
Message            : A user account was locked out.
LockedOutLocation  : DUMMYSTATION1

Press Enter to continue...: 

Open in new window


However, what I get is this:
PS C:\Users\pkrueger\Desktop> C:\Users\pkrueger\Desktop\test.ps1
Please enter the user name of the locked account (e.g. jdoe): pktesting

Name      LockedOut DomainController              BadPwdCount AccountLockoutTime    LastBadPasswordAttempt
----      --------- ----------------              ----------- ------------------    ----------------------
pktesting      True DC1.fubar.domain.com                    0 12/16/2013 3:08:28 PM 6/3/2013 2:16:53 PM   
pktesting      True DC2.fubar.domain.com                    0 12/16/2013 3:08:28 PM 4/23/2013 9:48:48 AM  
pktesting      True DC3.fubar.domain.com                    6 12/16/2013 3:08:28 PM 12/16/2013 3:08:28 PM 
pktesting      True DC4.fubar.domain.com                    0 12/16/2013 3:08:28 PM 2/21/2013 10:25:01 AM 



Press Enter to continue...: 

User               : pktesting
DomainController   : DC1.fubar.domain.com
EventId            : 4740
LockedOutTimeStamp : 12/16/2013 3:08:28 PM
Message            : A user account was locked out.
LockedOutLocation  : DUMMYSTATION1

Open in new window



How can I get the detailed lock information to show up before the "enter to continue" line. The function's done at that point, right?
0
Comment
Question by:PaulRKrueger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 39722843
Try if pushing the results out to the console explicitely will help:
$Identity = Read-Host 'Please enter the user name of the locked account (e.g. jdoe)'
Get-LockedOutLocation -Identity $Identity | Out-Host
Read-Host 'Press Enter to continue...' | Out-Null

Open in new window

0
 
LVL 4

Author Closing Comment

by:PaulRKrueger
ID: 39724822
Perfect answer.
0

Featured Post

Four New Appliances. Same Industry-leading Speeds.

But don't take it from us.  The Firebox M370 is Miercom tested and Miercom approved, outperforming its competitors for stateless and stateful traffic throughput scenarios.  Learn more about the M370, M470, M570 and M670 and find the right solution for your organization today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question