Solved

PowerShell Function Output

Posted on 2013-12-16
2
676 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
2 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…

939 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

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now