New Starters Script RRS feed

  • Question

  • I need to add a log file to the end of this script that i have created

    i am fairly new to Powershell and need some assistance 


    Import-Module activedirectory

    $users = Import-Csv -Path $csvfile

    foreach ($user in $users)
    {  #$Displayname = $user.lastname + "," + $user.Firstname
       $GivenName = $user.Firstname
       $Sn = $user.Lastname
       $Name = "$($user.Lastname), $($user.Firstname)"
       $SamAccountName = "$($user.Firstname).$($user.Lastname)"
       $UserPrincipalName = $UserPrincipalName = $User.Firstname + "." + $User.Lastname + "" #Adds User Principle Name which was missing from previous script
       $ProfilePath = $user.ou #user will be placed into the USERS ou on AD i will move them across manually
       $Description = $user.Description
       $password = $user.Password1

       #creates new users
       New-ADUser -DisplayName $Name -givenname "$GivenName" -Surname "$SN" -Name "$name" -SamAccountName "$samaccountname" -UserPrincipalName "$userprincipalname" -ProfilePath "$profilepath" -Description "$description" -Enabled $false
       Add-ADGroupMember -identity Personal Folders and Desktop on Storm -Members $SamAccountName #adds the groups
       Add-ADGroupMember -identity Internet User -Members $SamAccountName


    • Edited by Jon Gomes Tuesday, April 9, 2019 8:53 AM
    • Moved by Bill_Stewart Monday, July 29, 2019 8:13 PM This is not "fix/debug/rewrite script for me" forum
    Monday, April 8, 2019 3:29 PM

All replies