Warning: The magic method InvisibleReCaptcha\MchLib\Plugin\MchBasePublicPlugin::__wakeup() must have public visibility in /home/xs980796/nagare-yama.com/public_html/wp-content/plugins/invisible-recaptcha/includes/plugin/MchBasePublicPlugin.php on line 37
PowershellでCSV読み込み | 個人的IT戦略

PowershellでCSV読み込み

PowershellでCSV読み込み

class ADUser {
[string]$ID
[string]$Name
[string]$Email
}

try {
$CsvFilePath=”C:\Users\管理者\Desktop\powershell\ユーザー一覧.csv”
$CsvData=Import-Csv -Path $CsvFilePath -Encoding UTF8
}catch{
Write-Error “CSVファイルの読み込みに失敗しました:$($_.Exeption.Message)”
exit 1
}

$ADUsers=@()

foreach($Row in $CsvData){
$User=[ADUser]::new()
$User.ID=$Row.ID
$User.Name=$Row.Name
$User.Email=$Row.Email
$ADUsers+=$User
}

$ADUsers

タイトルとURLをコピーしました