Modifying my script to list all folders and their lastwritetime on remote computers

Hello,
I've got the following script that is trying to report on a list of computers (in computerlist.txt) the contents of the C:\Users folder and list in the resulting CSV File the Name of the computer, the Folder Name and the Date it was last changed (sort by
most recent first).
$servers = GC C:\Powershell_Scripts\computerlist.txt
ForEach($server in $servers) {
If (Test-Connection -comp $server -count 1 -quiet) {
Get-Childitem ("\\$server\c$\Users") | Where-Object { $_.mode -like 'd*' } | Select-Object $server, Name, LastWriteTime | Export-Csv C:\Apps\Powershell_Scripts\LastLogin\Reports\directoryFile.csv
I'm part way there but my script is not showing each computer..only the last computer in the list.
Please assist with making the necessary changes to this script.
Thank you.

Thanks for the reply Mike.
I am running version 3.  I've added the -Append to my script but it doesn't seem to like it.  Here's the error I get:
Export-Csv : Cannot append CSV content to the following file: C:\Powershell_Scripts\Reports\directoryFile.csv. The appended object does not have a property that corresponds to the following column: ServerABC. To proceed with mismatched
properties, add the -Force switch and retry.
Where ServerABC is the name of the first server in computerlist.txt. 
Here is how I added the -Append:
$servers = GC C:\Powershell_Scripts\computerlist.txt
ForEach($server in $servers) {
If (Test-Connection -comp $server -count 1 -quiet) {
Get-Childitem ("\\$server\c$\Users") | Where-Object { $_.mode -like 'd*' } | Select-Object $server, Name, LastWriteTime | Export-Csv -Append C:\Apps\Powershell_Scripts\LastLogin\Reports\directoryFile.csv
The report being written out also isn't in the format I need.
ServerABC Name LastWriteTime
User1 5/12/2014 16:11
ADMINI~1 7/30/2012 13:37
User2 4/1/2014 18:23
How do I modify this to show the following output instead:
Computer Name LastWriteTime
ServerABC User1 5/12/2014 16:11
ADMINI~1 7/30/2012 13:37
User2 4/1/2014 18:23
ServerDEF User1 6/14/2014 14:12
ADMINI~1 6/24/2012 15:38
User2 5/1/2014 20:25
Thank you.

Similar Messages

  • List all folders, and subfolders, in a directory

    I'm trying to find a way to list all folders, and subfolders, in a directory.  I ran the code below and got a message that says 'Access is Denied'.  There is no way access is denied to that folder. How can I list all folders, and subfolders, in
    a directory?
    --'C:\Users\Ryan\Desktop\Coding\';
    set nocount on
    declare @curdir nvarchar(400)
    declare @line varchar(400)
    declare @command varchar(400)
    declare @counter int
    If (select count (*) from sys.objects where name='Output') <> 0 DROP TABLE output
    If (select count (*) from tempdb.sys.objects where name like '%#Tempoutput%') <> 0 DROP TABLE #Tempoutput  
    If (select count (*) from tempdb.sys.objects where name like '%#dirs%') <> 0 DROP TABLE #dirs  
    create table #dirs (DIRID int identity(1,1), directory varchar(400))
      Set @command = 'dir "C:\Users\Ryan\Desktop\Coding\Microsoft Access\" /S/O/B/A:D'
     insert into #dirs exec xp_cmdshell @command
      set @counter = (select count(*) from #dirs)
    create table #tempoutput (line varchar(400))
    create table output (Directory varchar(400), FileSize varchar(400))
        While @Counter <> 0
          Begin
            Declare @filesize int
            set @curdir = (select directory from #dirs where DIRID = @counter)
            set @command = 'dir "' + @curdir +'"'
            insert into #tempoutput
            exec master.dbo.xp_cmdshell @command
               select @line = ltrim(replace(substring(line, charindex(')', line)+1,len(line)), ',', ''))
               from #tempoutput where line like '%File(s)%bytes'
               Set @filesize  = Replace(@line, ' bytes', '')
            Insert into output (directory, Filesize) values (@curdir, @filesize)
            Set @counter = @counter -1
           End
           Delete from output where Directory is null
    select * from output
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Can you tell us how you're executing this code? Is it called from sql agent job or are you executing it by calling code directly?
    Did you try creating a proxy for xp_cmdshell and then executing it?
    http://www.mssqltips.com/sqlservertip/2143/creating-a-sql-server-proxy-account-to-run-xpcmdshell/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How can I list all users and their DEFAULT tablespace?

    How can I list all users and their DEFAULT tablespace?
    Peter

    Peter, the following short article that lists the most heavily used Oracle rdbms dictionay views might be of interest based on your question:
    How do I find information about a database object: table, index, constraint, view, etc… in Oracle ? http://www.jlcomp.demon.co.uk/faq/object_info.html
    HTH -- Mark D Powell --

  • Would like to create a script for list all elements and structure of an indesign document

    Hello everybody,
    I'm a very beginner in indesign scripting.
    I would like to create a script in order to list all elements and the inner structure of a n indesign document.
    The aim for me is to understand how elements are sorted and arranged into indesign, and be able to find an specific element by its item name.
    The output document could be an xml or txt document with a treeview structure.
    I would like have a rough idea of which kind of javascript code I should use for that.
    Thanks for answers.

    Hi Ossydoc,
    You can use Muse to create such a website. All you need to do is, create links in Muse for the sermons and select  " link to File " in the hyperlink option and link to those Mp3 files.
    Please refer to this screenshot :- http://prntscr.com/4xvdup
    Now, when you publish your site,  Muse would automatically upload those files onto the server and the users would then be able to listen as well as download those sermons using the links on your site.
    Hope this helps
    Regards,
    Rohit Nair 

  • Script to list the users and their privileges in a database

    Hi Team,
    Can someone provide me a script that list all the users and their privileges in a database?
    DB version:11.2.0.2
    OS:AIX

    Osama_mustafa wrote:
    Why you create your own script
    SELECT * FROM USER_SYS_PRIVS;
    SELECT * FROM USER_TAB_PRIVS;
    SELECT * FROM USER_ROLE_PRIVS;
    That won't tell him what privileges a user has via a role. It will only tell him what privilges were granted directly, and what roles were granted directly. But those roles have privileges, and may have other roles, which have still more roles and privs, etc. It's a recursive issue and a simple select from user__privs won't get it.
    Pete Finnigan has a good script for reporting the entire picture. I leave it as an exercise for the student to use google to find it. I have already given all the information needed to complete that exercise.

  • BI Report - List all users and their assigned roles

    Hello,
    i need a report, which lists me all users and their roles.
    Which table stores this membership information about the users?
    USR or UGP does not have any values

    Hi Reynaldo,
    You can go to SE16 -> table name "AGR_USERS" and see the records for all users. Arrange them in ascending order by name and you will get the report what you have mention above.
    Download it and put it in EXCEL.
    Best Wishes.
    Kumar

  • Power shell script to list all files and folder permissions recursively

    Hi All,
    I am looking for a powershell script to perform the following operations.
    1) To list the folder and file permissions(Allow,Deny both) recursively in a given folder.
    2) List out all the files and folders which are having the deny permission or having only the read access (or) only the write access. Basically the folder should have Read,Execute,Write permissions. Else we have to flag that file/folder name.
    I had written a batch script for the same which does this task using icacls.exe output, but this script takes lot of time to recursively parse all the files ( ~1 lakh files).
    Please help me with the powershell script for the same.
    Thanks
    Sambasiva

    Try this module: http://gallery.technet.microsoft.com/scriptcenter/PowerShellAccessControl-d3be7b83
    After importing the module, you can run something like this:
    dir c:\folder -recurse | Get-AccessControlEntry
    That output can be exported to a CSV for later viewing. You can also provide some parameters to Get-AccessControlEntry to limit the results:
    dir c:\folder -recurse | Get-AccessControlEntry -FileRights Write
    dir c:\folder -recurse | Get-AccessControlEntry -AceType AccessDenied
    dir c:\folder -recurse | Get-AccessControlEntry -AceType AccessAllowed -FileRights Write

  • List all users and their OUs they belong to

    Hi,
    I would like to list all users with the OU they belong to and furthermore add an specific attribute that was added...
    I can get both information separately:
    get-aduser -SearchBase 'OU=DOMAIN,DC=mygroup,DC=re,DC=lan' | FT name
    and
    Get-ADOrganizationalUnit -SearchBase 'OU=DOMAIN,DC=mygroup,DC=re,DC=lan' -properties name,budgetanalytics | FT name,budgetanalytics
    but I'd like to get the list containing user1, its OU, its budgetanalytics
    Thanking you in advance,
    Cédric

    Thanks for your reply!
    I tried the following:
    $Users = get-aduser -SearchBase 'OU=Mes Utilisateurs,DC=itced,DC=lan' -filter '*'
    $OU = $User.distinguishedname -split ',',2 | select -last 1
    $output = @()
    Foreach($User in $Users){
    $budgetanalytics = Get-ADOrganizationalUnit -SearchBase $OU -Properties objectGUID
    $Object = New-Object PSObject                                       
    $Object | add-member Noteproperty user $user.name         
    $Object | add-member Noteproperty OU $OU                       
    $Object | add-member Noteproperty objectGUID $objectGUID       
    $output += $Object
    $output
    but I get the following
    user                                             
    OU                                              
    objectGUID                                      
    User1                                            
    OU=Mon OU,OU=Mes Utilisateurs,DC=itced,DC=lan    {Microsoft.PowerShell.Commands.Internal.Forma...
    User2                                            
    OU=Mon OU,OU=Mes Utilisateurs,DC=itced,DC=lan    {Microsoft.PowerShell.Commands.Internal.Forma...
    Why do I get "Microsoft.PowerShell.Commands.Internal.Forma..." instead of the actual objectGUID of the Organizational Unit
    Thanking you in advance

  • List all users and their own roles.

    Hi everybody!
    I have to make a list of all sap users and their own separated roles by user. There are any transaction to do it? The SUIM transaction gives me a sap user and their own roles, but if I try with a lot users It gives me all the roles that are using those users but don't give me the roles for each one.
    Thanks a lot.
    Best regards.

    Hi Reynaldo,
    You can go to SE16 -> table name "AGR_USERS" and see the records for all users. Arrange them in ascending order by name and you will get the report what you have mention above.
    Download it and put it in EXCEL.
    Best Wishes.
    Kumar

  • Query to get a listing of all folders and joins in EUL

    If anybody has a query that provides a listing of all folders and joins between those folders in a Discoverer EUL, can you please share it.
    Any help would be greatly appreciated.

    Hi
    As Rod commented you won't get an accurate listing going through XREFS. You need to look in the statistics table, EUL5_QPP_STATS where you will find a history of all worksheets that have been executed. Unfortunately the item columns in EUL5_QPP_STATS are encoded so you will need some special SQL to uncode them.
    First of all you will need to have installed the EUL extensions which can be found in the script called EUL5.SQL (located in the Discoverer\Util folder where Admin is installed) when logged in as the owner of the EUL. Theh try running this script, altering the data switch to a suitable date:
    SELECT
    QS.QS_DOC_OWNER    USER_NAME,
    QS.QS_DOC_NAME     WORKBOOK,
    QS.QS_DOC_DETAILS  WORKSHEET,
    TRUNC(QS.QS_CREATED_DATE) EXECUTION_DATE,
    *(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 ITEMS,*
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),1,  6)) ITEM1,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),10, 6)) ITEM2,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),19, 6)) ITEM3,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),28, 6)) ITEM4,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),37, 6)) ITEM5,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),46, 6)) ITEM6,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),55, 6)) ITEM7,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),64, 6)) ITEM8,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),73, 6)) ITEM9,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),82, 6)) ITEM10,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),91, 6)) ITEM11,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),100,6)) ITEM12,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),109,6)) ITEM13,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),118,6)) ITEM14,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),127,6)) ITEM15,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),136,6)) ITEM16,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),145,6)) ITEM17,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),154,6)) ITEM18,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),163,6)) ITEM19,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),172,6)) ITEM20
    FROM
    EUL5_QPP_STATS QS
    WHERE
    *(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 < 21*
    AND QS.QS_CREATED_DATE > '01-JAN-2009'
    Best wishes
    Michael

  • Command to  provide list of all objects and their scripts from database

    Hi,
    How do i get the list of all objects and their scripts/source from database?
    I guess using dbms_metadata package or Toad tool we can achieve the above task
    But i do not know the steps to get the objects and their scripts.
    Im using oracle database 11g R2 11.2.0.2
    Kindly ge me the advice
    Thanks in Advance

    How do i get the list of all objects and their scripts/source from database?
    I guess using dbms_metadata package or Toad tool we can achieve the above task
    But i do not know the steps to get the objects and their scripts.
    Im using oracle database 11g R2 11.2.0.2If you want the all the metadata of whole database, then it is quiet difficult to get from DBMS_METADATA, as it is very complex because you need to gather for each object of each schema in whole database and to spool.
    http://www.orafaq.com/node/57
    I want to know, what is the use of entire database metadata, Certainly need of objects of metadata.
    or if you want to whole database, then i suggest you go for export full backup and import as impdp sqlfile option,

  • Mac does not list all folders in a SMB share

    Hi guys, this is a bit of a weird one and I've tried everything I can think of.
    In our house we have a media centre running Windows 7. It has several shares, one of which we'll call folder "X". Folder X opens correctly on the media centre, and any other Windows machine perfectly. Almost every other machine in the house is running OS X 10.6, and one of my housemates today noted that some of the folders inside of folder X were not listed on a Mac. So far we've tested it on 2 Macs and 2 Windows machines, and everytime the Windows machine lists all folders inside of X, where the Mac does not. The weird thing is, it's cutting them out alphabetically, so it's basically from D through to I that are missing, all in all there are 30 (out of 160) folders missing inside of Folder X...here's what I've tried.
    On the Windows 7 machine:
    -Restarted server service
    -Removed Share X and re-added
    -Checked share permissions on folder X
    -Checked permissions on folder X, propagated to all child folders just in case.
    -Restarted machine after every change.
    On the Macs we haven't really tried much as there's not much we can think to change. We've tried Finder, Path Finder (which I'm guessing will be exactly the same), restarting, removing from workgroup and re-adding...I can't think what would cause such a weird problem.
    To make things harder we don't know exactly when it started happening but the OSX machines definitely used to list the folders and it happens on more than one mac. which I guess makes me think it's something on the Windows client. The 30 folders are not using any nonstandard characters, some are only a few letters long.
    Ideas on a postcard!?

    Reporting the same problem.
    1. Have Windows 7 MediaCenter with file sharing set up properly (LM+NTLM Authentication allowed and 128-bit encryption disabled in security policies).
    2. Test folder ("C:\income") and all the subfolders' owner is 'Guest', full access is granted for everyone.
    3. Connecting to MediaCenter from MacBook with Finder by pressing Cmd+K and typing smb://ip-addr/income
    4. Finder connects successfully, but some sub-folders and files are not being listed.
    Workaround:
    5. You can open a not-listed folder directly by pressing Cmd+K and typing smb://ip-addr/income/some-invisible-folder
    6. Voila! You're inside invisible folder.
    In the meantime, i can see all the sub-folders on a Windows XP client machine, so i can make a conclusion that all of these 'invisible' sub-folders are actually accessible by Finder, but in some reason are just not being listed on Mac.

  • Closing all folders and subfolders within a window with one command

    In list view, is there a way to close all folders and subfolders within a window with one command, instead of having to close each individually?
    Thanks!

    Thanks, all, for your feedback, but no cigar, yet:
    - opening folders with "option" is possible but problematic
    - none of this solves the question of closing all the folders and subfolders within a window in one shot.
    Any better solution would be appreciated.
    Thanks!

  • PowerShell script to list ALL documents bigger than 10MB - in list attachments/libraries all over my site?

    Hi there,
    Just wondering if someone can give me the PowerShell script to list ALL documents bigger than 10MB - in list attachments/libraries all over my site?
    Really appreciated.
    Thank you.

    Hello,
    here you can find sample to help you create yoru script :
    http://sharepointpromag.com/sharepoint/windows-powershell-scripts-sharepoint-info-files-pagesweb-parts
    see this sample extract from this site
    Get-SPWeb http://sharepoint/sites/training |
                                     Select -ExpandProperty Lists |
                                     Where { $_.GetType().Name -eq "SPDocumentLibrary" -and
                                             -not $_.Hidden }
    |
                                     Select -ExpandProperty Items |
                                     Where { $_.File.Length -gt 5000 } |
                                     Select Name, {$_.File.Length},
                                            @{Name="URL";
                                            Expression={$_.ParentList.ParentWeb.Url
    + "/" + $_.Url}}
    this can help too :
    https://gallery.technet.microsoft.com/office/Get-detail-report-of-all-b29ea8e2
    Best regards, Christopher.
    Blog |
    Mail
    Please remember to click "Mark As Answer" if a post solves your problem or
    "Vote As Helpful" if it was useful.
    Why mark as answer?

  • List of users and their decimal notation settings in SAP system

    Hi all, i'm looking to get my hands on a list of all users in our SAP system and their respective decimal notation settings? I know that these can be mass changed using SU10 however I am unable to determine how to view a list of users and their settings.
    Thanks,
    James

    Hi James,
    You can find many useful reports, in SUIM transaction to see user details, but not decimal notation field. I don't know a report to show decimal notations, but as a workaround, in order to see the decimal notation, you can check "USR01-DCPFM" by using "SE16".
    Best regards,
    Orkun Gedik

Maybe you are looking for

  • I think it's a kernel panic

    I have been having serious trouble with beach balls (blue and variegated), very loud whirring noises (like a fan is working too hard), and system crashes over the last few months. I have sent error reports to Apple but of course that tells me nothing

  • Change the field description in the query report

    Dear All, I have created a querry using SQVI,It is working fine Now i want to change the field description in the querry report,Please suggest on this.

  • How can I do a batch rename of the version info?

    I've looked online and then on this forum for a while now and have not found anything that addresses this question, although, it may have been touched upon already somewhere on here. Basically what I want to do is be able to rename numerous versions

  • Making a Video

    I want to make a welcome/introduction video of myself for my business website. Can I use my WebCam to record audio and video and then down load that to a website who can put it into my website? If yes, can someone give detailed instructions? Thanks!

  • Migration to SAP

    Hello Experts, We have a Non SAP system as well as a SAP system. For a particular Co Cd, we enter transactions at both the Co Cds - Now the mgmt has decided to end up with the Non SAP system as it's too much of maintainence. As of now, this is how it