none
Powershell CSV RRS feed

  • Question

  • I'm running into a road block (but still researching as I submit this).

    I am looking to have powershell read a CSV file and create a file using column1 while using data

    from column 2

    --------------------

    Sample from CSV file:

    testShare_users$,D:\userDirectory

    --------------------

    So, the file that would be created would be called "testShare_users$". The contents of that

    file would be a script that ran again "D:\usersDirectory"

    I know what the end result is supposed to look like, but I'm stuck on getting leach line for the

    CSV to read.

    Any help is appreciated!!

    #Extract Column 2 and output to temp file Import-Csv D:\data.csv -Header (1..10) | Select -ExpandProperty '2' set-content D:\testOutput.csv Get-ChildItem D:\ -recurse | Select FullName, CreationTime, LastWriteTime, @{N="Owner";E={$_.GetAccessControl().Owner}} | sort FullName |Export-Excel D:\test.xls


    Thursday, September 29, 2016 3:27 PM

Answers

  • Import-Csv D:\data.csv -Header (1..10) |
    	ForEach-Object{
    		$_.2 | Out-File $_.1
    	}
    


    \_(ツ)_/

    • Marked as answer by djfrost2004_ja Thursday, September 29, 2016 5:16 PM
    Thursday, September 29, 2016 3:41 PM

All replies

  • Import-Csv D:\data.csv -Header (1..10) |
    	ForEach-Object{
    		$_.2 | Out-File $_.1
    	}
    


    \_(ツ)_/

    • Marked as answer by djfrost2004_ja Thursday, September 29, 2016 5:16 PM
    Thursday, September 29, 2016 3:41 PM
  • THANKS!!!!!!!!!!!!!!!!!!!!!!
    Thursday, September 29, 2016 5:16 PM
  • Import-Csv D:\FS41Quotas.csv -Header (1..10) |
    	ForEach-Object{
            Get-ChildItem $_.2 -recurse |
            Select FullName, CreationTime, LastWriteTime, @{N="Owner";E={$_.GetAccessControl().Owner}} |
            Export-Csv -NoTypeInformation D:\$_.1
            
    	}
    

    I'm having just a tad bit more trouble. I'm gonna try to figure this out..
    Monday, October 3, 2016 8:37 PM