#CSVファイルを展開し、変数に取得 $CSVPath = $PSScriptRoot + "\ADUserAccout.csv" #Write-Output $CSVPath $SetUserInfo = Import-Csv -Path $CSVPath -Encoding Default #Write-Output $SetUserInfo #ドメイン情報 $DCPath = ",DC=local,DC=mitsushima,DC=work" Write-Output 'ADユーザーを一括登録中です。コマンド完了までお待ちください。' $i = 0 #CSVファイル内のユーザーを一括登録(パスワード無期限) foreach($info in $SetUserInfo){ $OUPath = $Info.Path + $DCPath New-ADUser -Name $info.Name ` -Surname $info.Surname ` -GivenName $info.GivenName ` -Displayname $info.Displayname ` -Description $info.Description ` -UserPrincipalName $info.UserPrincipalName ` -SamAccountName $info.SamAccountName ` -AccountPassword (ConvertTo-SecureString $info.AccountPassword -AsPlainText -Force) ` -Path $OUPath ` -PasswordNeverExpires $True ` -Enabled $True $i += 1 Write-Output $i'件登録完了' } Write-Output 'ADユーザー一括登録完了 ' Write-Output $i'件登録実施しました。'