File Server - File size\type search and save results to file

I already have a vb script to do what I want on our file server, but it is very inefficient and slow.  I was thinking that a powershell script may be more suitable now but I don't know anything about scripting in PS.  So far the vb code that I
have works, and I am not the one who wrote it but I can manipulate it to do what I want it to.  The only problem is, when I scan the shared network locations it stops on some files that are password protected and I don't know how to get around it.  If
someone else knows of a PS script to go through the file system and get all files of a certain type or size (right now, preferably size) and save the file name, size, path, owner and dates created\modified please point me to it and I can work with that.  If
not, could I get some help with the current script that I have to somehow get around the password protected files?  They belong in a users' HOME directory so I can't do anything with them.  Here is my code:   
'Script for scanning file folders for certain types of files and those of a certain size of larger'
'Note: Script must be placed locally on whichever machine the script is running on'
'***********VARIABLES FOR USE IN SCRIPT***********'
'objStartFolder - notes the location of the folder you wish to begin your scan in'
objStartFolder = "\\FileServer\DriveLetter\SharedFolder"
'excelFileName - notes the location where you want the output spreadsheet to be saved to'
excelFileName = "c:\temp\Results_Shared.xls"
'**********END OF VARIABLES**********'
Set objFSO = CreateObject("Scripting.FileSystemObject")
fileName = objFSO.GetFileName(path)
'beginning row and column for actual data (not headers)'
excelRow = 3
excelCol = 1
'Create Excel Spreadsheet'
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Add()
CreateExcelHeaders()
'Loop to go through original folder'
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
Call Output(excelRow) 'If a subfolder is met, output procedure recursively called'
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
'Autofit the spreadsheet columns'
ExcelAutofit()
'Save Spreadsheet'
objWorkbook.SaveAs(excelFileName)
objExcel.Quit
'*****END OF MAIN SCRIPT*****'
'*****BEGIN PROCEDURES*****'
Sub ShowSubFolders(Folder)
'Loop to go through each subfolder'
For Each Subfolder in Folder.SubFolders
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
Call Output(excelRow)
Next
ShowSubFolders Subfolder
Next
End Sub
Sub Output(excelRow)
'convert filesize to readable format (MB)'
fileSize = objFile.Size/1048576
fileSize = FormatNumber(fileSize, 2)
'list of file extensions currently automatically included in spreadsheet report:'
'.wav, .mp3, .mpeg, .avi, .aac, .m4a, .m4p, .mov, .qt, .qtm'
If fileSize > 100 then'OR objFile.Type="Movie Clip" OR objFile.Type="MP3 Format Sound" _ '
'OR objFile.Type="MOV File" OR objFile.Type="M4P File" _'
'OR objFile.Type="M4A File" OR objFile.Type="Video Clip" _'
'OR objFile.Type="AAC File" OR objFile.Type="Wave Sound" _'
'OR objFile.Type="QT File" OR objFile.Type="QTM File"'
'export data to Excel'
objExcel.Visible = True
objExcel.Cells(excelRow,1).Value = objFile.Name
objExcel.Cells(excelRow,2).Value = objFile.Type
objExcel.Cells(excelRow,3).Value = fileSize & " MB"
objExcel.Cells(excelRow,4).Value = FindOwner(objFile.Path)
objExcel.Cells(excelRow,5).Value = objFile.Path
objExcel.Cells(excelRow,6).Value = objFile.DateCreated
objExcel.Cells(excelRow,7).Value = objFile.DateLastAccessed
excelRow = excelRow + 1 'Used to move active cell for data input'
end if
End Sub
'Procedure used to find the owner of a file'
Function FindOwner(FName)
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & FName & "'}" _
& " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")
For Each objItem in colItems
FindOwner = objItem.AccountName
Next
End Function
Sub CreateExcelHeaders
'create headers for spreadsheet'
Set objRange = objExcel.Range("A1","G1")
objRange.Font.Bold = true
objExcel.Cells(1, 1).Value = "File Name"
objExcel.Cells(1, 2).Value = "File Type"
objExcel.Cells(1, 3).Value = "Size"
objExcel.Cells(1, 4).Value = "Owner"
objExcel.Cells(1, 5).Value = "Path"
objExcel.Cells(1, 6).Value = "Date Created"
objExcel.Cells(1, 7).Value = "Date Modified"
End Sub
Sub ExcelAutofit
'autofit cells'
Set objRange = objExcel.Range("A1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
Set objRange = objExcel.Range("B1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
Set objRange = objExcel.Range("C1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
Set objRange = objExcel.Range("D1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
Set objRange = objExcel.Range("E1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
Set objRange = objExcel.Range("F1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
Set objRange = objExcel.Range("G1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()
End Sub
David Hood

Accessing Excel through automation is bvery slow no matter what tool you use.  Scanning a disk is very slow for all tools.
Since Vista all system have a search service that catalogues all major file itmes like size, extension, name and other attributes.  A search of a 1+Tb  volume can return in less that a second if you query the search service.
You can easily batch the result into Excel by writ4ing to a CSV and opening in Excel. Use a template to apply formats.
Example.  See how fast this returns results.
#The following will find all log files in a system that are larger than 10Mb
$query="SELECT System.ItemName, system.ItemPathDisplay, System.ItemTypeText,System.Size,System.ItemType FROM SystemIndex where system.itemtype='.log' AND system.size > $(10Mb)"
$conn=New-Object -ComObject adodb.connection
$conn.open('Provider=Search.CollatorDSO;Extended Properties="Application=Windows";')
$rs=New-Object -ComObject adodb.recordset
$rs.open($query, $conn)
do{
$p=[ordered]@{
Name = $rs.Fields.Item('System.ItemName').Value
Type = $rs.Fields.Item('System.ITemType').Value
Size = $rs.Fields.Item('System.Size').Value
New-Object PsObject -Property $p
$rs.MoveNext()
}Until($rs.EOF)
¯\_(ツ)_/¯

Similar Messages

  • PDF form that you can type in and save

    I am working to create forms that my student athletes will need to type into and save so that they can upload them to our online pre-participation site. Is there any special way I need to save my Adobe PDFs?  I saved them normally and one student had no problem with this task....I had another try this and it would not allow them to save the file. So after reading online I saved it as a Reader extended, enable more tools and then they could type and save the document. Is this the way to go?  I need them to type in the form, but not mess with the overall outline - just type in the blanks. Thanks

    If they're using the latest version of Reader (XI), then you don't need to do anything else. Earlier versions require that you apply the Reader Extended Rights in Acrobat for the file to be savable in Reader. This also has legal implications as to the number of replies you may collect (500).

  • Edit e-signature and save results

    Greetings
    While using Adobe Reader XI and signing documents:
    The saved image of the signature has a very heavy line-thickness and is in black
    Currently, once the signature is placed, I can change the line thickness and color
    Is there a way to edit the signature to reflect the proper line thickness and change the color of the signature to blue, and finally, save the edited signature so it is preserved, (in a thinner line thickness and in blue)?

    There is a share menu in the Adobe Reader that allows you to "email" the file to others or to "Open In" another app for sharing (as well as uploading the document to Echosign for signature).
    This menu item is the square with the arrow in it in the top toolbar. You can get the toolbar to show by tapping once on your document.
    Pat

  • Search and related results popups on photos

    The past week or so, I have noticed that a black search box is popping up on photos in Firefox. When I mouse over it, a "related results" box pops up. There are also popups in a new window of advertisements. Is this a virus, a known issue, or just some annoying new addition to Firefox?

    I think that might have done it. So weird, all the extensions looked like things that I use on a regular basis (Hootsuite, Amazon, Swagbucks). The only ones I didn't recognize were Java Quickstarter and Microsoft.NET Framework Assistant. The issue is sporadic, though, so I may just be in a "down" moment. I'll update if it comes back. Thanks!

  • Context Type Search returning wrong results with "ME" in the SEARCH

    CREATE TABLE "TEST"
    id NUMBER(19) NOT NULL,
    "TESTDATA" CLOB NOT NULL ENABLE
    CREATE INDEX IX_testdata ON test (testdata) INDEXTYPE IS CTXSYS.CONTEXT ONLINE
    PARAMETERS ('TRANSACTIONAL MEMORY 500M SYNC(ON COMMIT) section group ctxsys.xmlpathgroup')
    PARALLEL 4
    insert into test values (1, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <user>
    <givenname>victor</fn>
    <surname>frandenstein</sn>
    </user>
    select * from TEST
    where
    contains(testdata,
    'me inpath(/user/givenname) &(victor inpath(/user/givenname))') > 0
    This should not result in any results but it does show the record out.
    What is it we have to do deal with the word "ME". It works fine for any other values.

    Since "me" is a default stopword, searching for "me" and "Victor" is like just searching for "Victor", so it returns the row with "Victor" in it. If you want to be able to search for "me", then you need to either remove "me" from your existing ctxsys.default_stoplist using ctx_ddl.remove_stopword or specify another stoplist during index creation that does not contain me or an empty stoplist. You will need to drop and recreate your index after changing or modifying stoplists in order for the changes to take effect. Please see the demonstration below. I have added a couple of rows so that it is clearer what is and is not returned. You can check the token_text column of your dr$...$i index to see what it is tokenized, indexed, and searchable.
    SCOTT@10gXE> -- test environment:
    SCOTT@10gXE> CREATE TABLE "TEST"
      2  (
      3  id NUMBER(19) NOT NULL,
      4  "TESTDATA" CLOB NOT NULL ENABLE
      5  )
      6  /
    Table created.
    SCOTT@10gXE> insert into test values (1, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      2  <user>
      3  <givenname>victor</fn>
      4  <surname>frandenstein</sn>
      5  </user>
      6  ')
      7  /
    1 row created.
    SCOTT@10gXE> insert into test values (2, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      2  <user>
      3  <givenname>me victor</fn>
      4  <surname>frandenstein</sn>
      5  </user>
      6  ')
      7  /
    1 row created.
    SCOTT@10gXE> insert into test values (3, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      2  <user>
      3  <givenname>naren</fn>
      4  <surname>frandenstein</sn>
      5  </user>
      6  ')
      7  /
    1 row created.
    SCOTT@10gXE> exec ctx_ddl.create_section_group ('xmlpathgroup', 'PATH_SECTION_GROUP')
    PL/SQL procedure successfully completed.
    SCOTT@10gXE> -- reproduction:
    SCOTT@10gXE> CREATE INDEX IX_testdata ON test (testdata) INDEXTYPE IS CTXSYS.CONTEXT
      2  PARAMETERS
      3    ('TRANSACTIONAL MEMORY 500M
      4        SYNC(ON COMMIT)
      5        section group xmlpathgroup')
      6  PARALLEL 4
      7  /
    Index created.
    SCOTT@10gXE> SELECT token_text FROM dr$ix_testdata$i
      2  /
    TOKEN_TEXT
    FRANDENSTEIN
    NAREN
    VICTOR
    givenname
    surname
    user
    6 rows selected.
    SCOTT@10gXE> select * from TEST
      2  where
      3  contains(testdata,
      4  'me inpath(/user/givenname) &(victor inpath(/user/givenname))') > 0
      5  /
            ID
    TESTDATA
             1
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <user>
    <givenname>victor</fn>
    <surname>frandenstein</sn>
    </user>
             2
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <user>
    <givenname>me victor</fn>
    <surname>frandenstein</sn>
    </user>
    SCOTT@10gXE> -- solution:
    SCOTT@10gXE> drop index ix_testdata
      2  /
    Index dropped.
    SCOTT@10gXE> CREATE INDEX IX_testdata ON test (testdata) INDEXTYPE IS CTXSYS.CONTEXT
      2  PARAMETERS
      3    ('TRANSACTIONAL MEMORY 500M
      4        SYNC(ON COMMIT)
      5        section group xmlpathgroup
      6        stoplist ctxsys.empty_stoplist')
      7  PARALLEL 4
      8  /
    Index created.
    SCOTT@10gXE> SELECT token_text FROM dr$ix_testdata$i
      2  /
    TOKEN_TEXT
    FRANDENSTEIN
    ME
    NAREN
    VICTOR
    givenname
    surname
    user
    7 rows selected.
    SCOTT@10gXE> select * from TEST
      2  where
      3  contains(testdata,
      4  'me inpath(/user/givenname) &(victor inpath(/user/givenname))') > 0
      5  /
            ID
    TESTDATA
             2
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <user>
    <givenname>me victor</fn>
    <surname>frandenstein</sn>
    </user>
    SCOTT@10gXE>

  • Firefox is opening radom tabs that I do not want and chaging direction of websites when I do a search and open results in tabs to have the search results to go back easily without useing back how do I stop this from happing?

    The browser opens random tabs both while I am using and will start on a random tab while I do not have it running.

    With the multitude of issues you have I would take it to an Apple store or AASP and have them sort it out. Then I would sign up for Apple camp or one on one.

  • Open and Save Dialog Box Font Size

    Greetings. Does anyone know how to change the font and icon sizes in Open and Save Dialog boxes in OSX 10.8? Back in Snow Leopard days, the parameters were stored in the users .GlobalPreferences.plist. But they do not appear to be there - or at least I don't recognize them in OSX 10.8. I recently started using a 27 inch Cinema Display, and the fonts are a bit small for me.
    I appreciate any help anyone can offer.

    Good question!  Do submit feedback to Apple.  Maybe if enough of us complain about this fundamental issue, they'll finally listen!

  • Using search and comments on my own server

    Hi all,
    I have created a blog site and I use the search and comments features.
    I noticed that every time I publish my site to a folder (or to our internal server) instead to .Mac the functionality of the search and comments is gone.
    Is there a way to restore them on our internal server?
    Thanks,
    Ziv

    The search and comments features are part of dotMac.
    WOW there are a lot of websites out there using .mac I would never of guessed given that information...
    j/k
    irony; if you _search for search_ your may find what you're searching for
    Want someone to hold your hand?
    Comments
    C'mon Ziv search is your friend! Don't ask how to put it on your site if you don't know how to use it in the first place that's just hypocritical.

  • I need to be able to access a PDF document on my ipad when I am offline and save it to print later when I am connected to wi-fi. I can not figure out how to do this (to be accessible offline and saved). Please help.

    I type notes between therapy sessions and frequently do this in my car without wifi available.  I need a way to access PDF files that I can type in and save and be able to AirPrint from when I am connected to wifi at a later time,  I currently have these documents saved in Dropbox and open them on my ipad or iPhone in Adobe Reader but don't have a way to save and use offline. I tried iBooks but it doesn't allow me to edit.  I need specifics on how to do this please. I bought an ipad to make my mobile work easier but am still using my iPhone for everything because I can't figure how to easily access and edit PDF documents offline. Thanks in advance.

    search the app store for PDF Writer. I've found a lot that will convert documents to PDF, but none yet that will write within the PDF. One thing you want to avoid are cloud based apps. Any of them that talk about editing on the cloud, etc, aren't going to be as standalone as you want.
    It's possible, if you can take your template PDF, turn it into a word document that you can edit, you can then convert that to PDF...kinda a workaround way to do what you want. And apps that convert to PDF are much easier to find

  • How to hide the Save Results Layout checkbox on the Create Saved Search pop

    I need to hide the Save Results Layout checkbox on the Create Saved Search popup. Can anyone tell me how to do it?
    This popup is used when the user is on a query (rendered by the af:query component) and they select click the "Save..." button. The have three options, Set as Default, Run Automatically, and Save Results Layout. I have an implementation that supports everything except saving the layout. So I need to hide that checkbox.
    Thanks,
    Mike

    For anybody else who needs to do this, here is how I did it.
    Add this to your css
    /* This hides the Save Results Layout checkbox on the Create Saved Search screen */
    span[id$='saveLayout'] {
    visibility: hidden;
    }

  • How to create URL link for telephone number ,open to account search page and account result page ?

    Hi Experts,
    Bussines role - ZCC_ICAGENT 
    If user open this bussiness role and open Account page ,user enter telephone number and enter search account ,then result will be displayed.Instead of 3 clicks ,user click direct URL link ,telephone number is parameter,account Search and account result  page will be opened direct link.
    So how to do it..could you please provide me step by step...what are the steps wee need to follow for creating URL ..how to do it..Please help..
    Thanks
    Kalpana

    Hi kalpana,
    You dont need to do any setting for this.
    Following URL will be used as per your requirement.
    http://rrnewcrm.ril.com:8000/sap(bD1lbiZjPTI0MiZkPW1pbg==)/bc/bsp/sap/crm_ui_start/default.htm
    ?sap-system-login-basic_auth=X&sap-system-login=onSessionQuery&saprole=ZCC_ICAGENT&
    sap-phoneno=9999999999
    Here parameter sap-phoneno will contain the number you want to search for.
    In component ICCMP_BP_SEARCH, go to view BuPaSearchB2B. write below code in its inbound plug IP_INBOUNDPLUG-
    DATA: lt_ivr_url_param TYPE tihttpnvp,
             ls_ivr_url_param TYPE ihttpnvp,
             lr_searchcustomer TYPE REF TO if_bol_bo_property_access,
             ls_searchcustomer TYPE crmt_bupa_il_header_search.
    CALL METHOD cl_crm_ui_session_manager=>get_initial_form_fields
           CHANGING
             cv_fields = lt_ivr_url_param.
    lr_searchcustomer ?= me->typed_context->searchcustomer->collection_wrapper->get_current( ).
         CHECK lr_searchcustomer IS BOUND.
    READ TABLE lt_ivr_url_param INTO ls_ivr_url_param WITH KEY name = 'sap-phoneno'.
    IF ls_ivr_url_param-value IS NOT INITIAL.
             ls_searchcustomer-telephone = ls_ivr_url_param-value.
       CALL METHOD lr_searchcustomer->set_properties( EXPORTING is_attributes = ls_searchcustomer ).
             eh_onsearch( ).
        ENDIF.
    Thanks & Regards
    Richa

  • How to calculate and save planning data in bex input-ready query using keyfigures for calculation from different infoproviders

    Hi Dear All,
    We have two real time infocubes and two aggregation levels based on these cubes in one multiprovider
    first cube1 is like
    char1| char2| keyfig_coefficient(single value for each combination of char1 and char2)
    same aggregation level1
    (we have input query to fill coefficients by one responsible user)
    second cube2 is like
    char1| char2| keyfig_quantity| keyfig_result
    same aggregation level2
    Input ready query should be like (for all other users of different org units)
    char1|char2|keyfig_coeff| keyfig_quant(for input) | keyfig_result = keyfig_coeff*keyfig_quant(calculated value, should be saved to cube2)
    And we don't have pregenerated lines in cube2, users have to add new lines themselves by wad.
    Question is, what is the optimal (easiest) way to make calculation and save result data to cube2 where keyfigures for calculation should be used from different infoproviders. I need just a hint.
    Appreciate any help.
    Nadya.

    I found decision, agregation levels sould be based on multiprovider, not included.

  • Lucene search and order by Date attribute

    Hello,
    We have a requirement where we have to search assets and sort assets via some date attribute (Article Publication Date) using Lucene Search. There is no issue in searching and displaying results in any order we want.
    Problem occurs when some assets don't have "Article Publication Date" value as it is optional and hence, we don't know how the sorting is decided of assets is decided when the output comes after lucene search? Can anyone suggest?
    Regards,
    Guddu

    user11268895 wrote:
    ... you are in an PL/SQL forum not in a mysql forum.
    if you want we can translate your query in a Oracle DB query...Well... MySql is an Oracle Database...
    to the op:
    If you want to order then you need an ORDER BY clause at the end of your statement.
    Instead of date_format you can use TO_DATE if dealing if strings. If it is a datatype date, then there is no need of a conversion.
    group by T.ARRIVAL_DATE, T.foreign_network_id
    order by t.arrival_date descyou could also group on the day or the month if that is what you want.
    day groups
    select trunc(T.ARRIVAL_DATE), ...
    group by trunc(T.ARRIVAL_DATE), T.foreign_network_id
    order by trunc(T.ARRIVAL_DATE) desc;
    month groups
    select trunc(T.ARRIVAL_DATE,'mm'), ...
    group by trunc(T.ARRIVAL_DATE,'mm'), T.foreign_network_id
    order by trunc(T.ARRIVAL_DATE,'mm') desc;
    boy groups
    select trunc(T.ARRIVAL_DATE,'boy'), ...
    group by trunc(T.ARRIVAL_DATE,'boy'), T.foreign_network_id
    order by trunc(T.ARRIVAL_DATE,'boy') desc;
    /* Ok, ignore the last one, I was just testing if you read until the end. */ Edited by: Sven W. on Aug 26, 2010 2:25 PM

  • Is there a way to open Excell file from the server and display in the UI and save it back on to the

    Hello there,
    Is there a way to open Excell file from the server and display in the UI and save it back on to the server? (like showing xell file as a datagrid - add rows, columns etc.)

    Hi Mike,
    Welcome you to the forum.
    You may try:
    SELECT * FROM MyDBNameHere.dbo.OUSR T0
    Thanks,
    Gordon

  • Search c:\ drive and return file path for winword.exe and save as variable

    Hi all, here is what I'm trying to do;
    1. Search C:\ drive for winword.exe
    2. take the file path and save it as a variable.
    3. Then based on the path value, use the switch statement to run "some command" 
    Essentially I'm trying to find what the file path for winword.exe is, then run a command to modify the registry.  I already have the script that will modify the registry like I want but the problem it, the path is hard coded in the script, I want to
    now look for all versions of word and set the right file path so I can make the right registry changes.

    This should get you started:
    http://ss64.com/ps/get-childitem.html
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

Maybe you are looking for