Help with Simple Home Dir Script

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Jack Neff Jack Neff 1 year, 10 months ago.

  • Author
    Posts
  • #22391
    Profile photo of Thomas Farley
    Thomas Farley
    Participant

    Below is an unsuccessful script to create home directories, using a CVS file containing multiple Logon Names. Being a newbie to PS, I can't see my error as to why the scripts only creates a home directory called "Logon Name" I goal was to create a script that would subsitute the $_.Logon Name so that each user would be entered to create the home directory. Any help would be GREATLY appreciated.

    import-csv 'C:\cvstest2.csv' | `
    ForEach-Object { `
    -Logon Name $_.'Logon name' `
    mkdir "z:\home\'logon name'" `}

  • #22392
    Profile photo of Jack Neff
    Jack Neff
    Participant

    Welcome to PoSH! Try this

    Import-Csv 'c:\cvstest2.csv' | ForEach-Object { New-Item -TypeName Directory -Path "Z:\Home\$($_.LogonName)" }

You must be logged in to reply to this topic.