NOOB Question - Cannot seem to get the output in a text or CSV file - Please help!!

I was able to put together a script which finds members of a certain AD group, filters down the users, and then calculates the number of days till a password reset is needed.  I am able to get on screen exactly what i am looking for, but cannot seem
to figure out how to get the same data to a file.  What i am doing wrong?  two goals here:
1.  Create a spreadsheet with a list of users whose password is about to expire.
2.  Down the line automate an email to users whose password is about to expire. 
Here is my code:
## Get List Of Users in Password Change Lockout that do not have an expired password or a password that never expires
$Names = (Get-ADGroupMember -Identity "Password Change Lockout" -Recursive |`
Get-ADUser -Properties * |`
Where-Object {$_.PasswordNeverExpires -eq $False -and $_.PasswordExpired -eq $False} |`
Sort-Object name |Select-Object -ExpandProperty SamAccountName)
## Get Password last Set values for all
Foreach ($Name in $Names)
$VAR1 = (Get-ADUserResultantPasswordPolicy -Identity $Name).MaxPasswordAge
$VAR2 = (Get-ADUser $Name -Properties *).passwordlastset
$VAR3 = (Get-ADUser $Name -Properties *).name
$DTPC = (New-TimeSpan -Start (Get-Date) -End ($VAR2 + $VAR1) | Select-Object -ExpandProperty Days)
Filter users to those who need to change thier password in 15 days.
If ($DTPC -lt 15)
No matter what i try between the {} after the If statement, I cannot get the output to a file.  However, if I use a Write-Output I get exactly what i looking for.  I feel like i am forgetting some basic concept and could really use some help.  Thanks.
Matt 
Matt Dillon

Hi Matt,
I generally create an empty array (something like $out = @()) at the top of the script and then use $out += $desiredOutput inside of the foreach loop.
Outside of the loop, you can then pipe $out to Out-File or Export-Csv, depending on your needs.
Don't retire TechNet! -
(Don't give up yet - 12,830+ strong and growing)

Similar Messages

  • I am trying to sync my music library to my new iPhone 5C and cannote seem to get the music to sync.  It is in the library but isn't going over to my phone.

    I am trying to sync my music library to my new iPhone 5C and cannot seem to get the music to sync.  It is in the library but isn't going over to my phone.
    I must be doing something wrong during the sync (something checked when it should not bet, etc)  Need some help.  Thanks!!

    Manually manage music is NOT checked.  I backed up all my phone information from my old 3GS phone to my computer, then connected my new phone to sync.  Everything else seems ok but music won't transfer.  It is set to automatically sync when connected.

  • TS1702 My iPad dies, it has been replaced by Apple. However, I cannot seem to get the apps back that I paid for. I "may" have had an account balance as well. How or where do I find this info?

    My iPad died, it has been replaced by Apple. However, I cannot seem to get the apps back that I paid for. I "may" have had an account balance as well. How or where do I find this info?

    http://support.apple.com/kb/HT2519

  • I cannot seem to get the 'text' I am using to add an effect, help please

    I cannot seem to get the 'text' to be able to add an effect, it will only add the effect to the box the text is in

    Use system font, or al least one blank in system font. In this case you can use effects, because systemfonts are rendered as an image.
    Using web or web safe fonts it is momentarily impossible to use effects on text.

  • I cannot seem to get the tools button to come up on the firefox box, what do I need to do?

    I cannot seem to get the tools button in firefox, where can I find it or what do I need to do. I am trying to set a couple of home pages and the help section says to select the tool option and it is not there.

    First, please update to Firefox 18.0.2 [[Update Firefox to the latest version]]
    Then, you should be able to click the orange Firefox button in the upper left corner, then options. Set your home page there. [[How to set the home page]]

  • I cannot seem to get the app to download and install.  I get the spinning progress wheel.

    I cannot seem to get the app to download and install.  I get the spinning progress wheel.

    Hi profoto3,
    Are you trying to download and install the Creative Cloud apps? Which operating system are you using?
    Here is a helpful network troubleshooting doc. Go thru the steps in this doc to ensure that you can download.
    http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    Free Creative Cloud | Download Adobe Creative Cloud free trial
    Thanks
    Scott

  • I have LINUX and I cannot seem to get the browser to download on the computer, I have extracted the files from the download & then all I get is a folder

    The browser I have for Linux is SeaMonkey or some other annoying thing and I wanted FF because it actually has compatible add-ons but I cannot seem to get the browser to actually run on the computer. I click the download button and get the files but once I extract them nothing happens. I extracted them to the desktop, perhaps there is somewhere else in this system that they need to go to make them work?

    Ok...I should have also mentioned that I absolutely hate having Linux b/c I have no idea how to use it. If u could explain that in simpler terms I'd appreciate it.
    Also, I was able to get the browser to open once but then when I dragged the icon from the folder on the desktop & tried opening it [I wanted to make it a sort of desktop icon] it stopped working...
    EDIT: Ok so I re-extracted the downloaded file & clicked on the icon that said Firefox & I got the browser. My problem now it seems is the fact that I do not have a desktop shortcut, how would I go about making that happen?

  • I get the "Your purchase could not be completed" message, please help to verify

    I get the "Your purchase could not be completed" message, please help to verify

    If you haven't already done so, to contact iTunes Support (these are user-to-user forums) :
    - go to http://www.apple.com/support/itunes/ww
    - click on your country's flag
    - click on the Contact Support at the bottom of the left-hand column
    - click on Contact iTunes Store Support on the right-hand side of the page
    - then Purchases, Billing & Redemption

  • Is it possible to get the output of a text container into Spool..?

    Hi
    I am trying to write a report for a standard transaction(SM65) in BDC and run thru background job so as to get the output in to Spool. Right now I am facing an issue to get the SM65(text container) tcode output into spool.
    FYI..I am using "CALL TRANSACTION 'SM65' USING BDCDATA MODE 'E'."
    Please provide tour valuable inputs.
    Thanks!
    Shiv

    Hi Shiv,
    Instead of writing BDC for T-code SM65 I would suggest you to use following function module to get the required data.
          CALL FUNCTION 'BPT_ANALYSE_START'
            EXPORTING
              server_name            = servername_tmp
              check_all_btc_servers  = sbpt1020-allsrvchk
              profile_check          = sbpt1020-profilechk
              xpgm_environment_check = sbpt1020-xpgmcheck
            TABLES
              protocol_tbl           = global_protocol_tbl
            EXCEPTIONS
              OTHERS                 = 99.
    Once you got the data into "global_protocol_tbl " you can create spool of it.

  • When I plug my i pod in to down load music a screen pops up and says. this i pod cannot be used because the apple mobile device service is not started. please help

    when I plug my I pod in to download music a screen pops and says. this i pod cannot be used because the apple mobile device service is not started. please help

    See:
    How to restart the Apple Mobile Device Service (AMDS) on Windows

  • I am trying to recover or change my security question responses as i cannot get the ones i originally put in correct.  PLease help.

    Please help me to figure out how to recover the answer (or change) to my security question in order to make purchases using my itunes account through a new computer.

    Do any of these discussions, from the More Like This section on the right, address your problem?
    I forgot My security question
    Help please! How will I reset or change the answers to my security questions? Thanks
    Password Security
    How i can recover the password of my iPhone´s security copy?
    i can't change the security question, and i don't remember answer for this question

  • Can't get the external speakers to work!!! PLEASE HELP!

    The external speakers attached to my Macbook Pro (plugged into the headphone jack) aren't working...the output is set properly and the mute is not checked off - it worked last night and then this morning suddenly it didn't - what do I do?? I can still hear the sound faintly from the speakers but I cannot control the volume from the speakers and it is very quiet. Sooo frustrated!!!

    Because your speakers need a 5.1-channel surround-sound signal input, they can't use a standard 2-channel analog stereo headphone plug to connect to the signal's source. I assume therefore that they must have a mini-TOSLink plug, which carries a 5.1-channel optical digital signal. When such a plug is connected to the MacBook Pro's headphone port, the volume coming from the speakers is not controlled by the computer — it's controlled by the amplifier that powers the speakers (and that amplifier is usually built into the subwoofer of the speaker system). So find the volume control knob or buttons for the speakers and you should be able to get a louder output from them — and presumably from all of them.
    If in doubt, consult the instructions for the speaker system.

  • I got a new e-mail address and I reset my iPod so it already has the new email address. I can't seem to change the address on my iPad or iPhone. Please help me change the address on all my devices!

    I got a new email address and I reset the iPod so it already has the new address. I can't seem to change the address on my iPhone5 or iPad. So please help! How do I change the address for my apple ID and icloud on all my devices? I don't want to reset my iPad and phone just to set new email address I can't do updates without the password and I have forgotten my password for my old email address. Please Help! Getting frustarted!

    If the old ID ("email address") is yours, and if your current ID was created by editing the details of this old ID (rather than being an entirely new ID), go to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iDevice, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll.  When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • How can i get the code html and css of my form please help me

    how can i get the code html and css of my form

    HI,
    If you like to embed the HTML form in your web page then you will need to obtain the form code from the Distribite/Embed tab. Additional information can be found here: http://forums.adobe.com/docs/DOC-1991
    You will not be able to access/modify the css code or the rest of the form html code.  If you like to view the source of of a HTML page, please use your browser 'view source code' functionality.
    I hope this answer your question,
    Thanks,
    Lucia

  • My iphone fell and now shows USB on screen saying to connect with itunes but when connected i get the message from itunes tha its damaged..please help me somebody

    my iphone 4s fell and display went blank,and when i restarted it shows a USB on display asking to connect with itunes,instead i went to a phone repair shop where they service iphones too.First they said that they have to install the IOS4 again in it but they could not do so due to an error so later they asked me whether they should install IOS5 i agreed but it only happened after a long struggle yet the phone remains in the same state with the display showing USB asking to connect with itunes..they could not fix it..please help me..:(

    What's there to help?  You dropped your phone and now it's broken.  You'll have to bring your phone into Apple for an out of warranty exchange.  If you purchased Apple Care+ is will cost $49.00, if not, it will be $199.00

Maybe you are looking for

  • Syntax to print out variable

    I need to know the syntax to print out bind variable to xterm. ( :import.out := outdir ). I believe forms doesn't have the dbms package but does have the text_io. I would like to know the syntax for both as I want to monitor a variable's contents fro

  • How to use bind variables using in  clause in SQL

    Hi Can any one help me in regards Bind variables usage using in clause in sql for String data? thans

  • File upload hanging when called from another form

    Hi I have created a file upload form from the documentation I found on metalink and the form works fine on its own. I have then implemented the form into a multi form application and when the file upload form is called from another form it hangs tryi

  • AE Keeps refusing connections (still no answer??)

    So, we have an AE and when I plug it in, it works fine. Users can connect and all is well. After a little while (sometimes a few hours, sometimes days, sometimes minutes) users are not able to connect to the base station. When trying to connect from

  • PROGRESS BAR ERRRR

    I am trying to get a progress bar working along side a large process that take a while. I first tried to make the progress bar its own thread but when I ran the large process (which spawns off the progress bar thread) the progress bar froze and waite