diff --git a/scripts/powershell/create_users_csv.ps1 b/scripts/powershell/create_users_csv.ps1 index 7f1782a..7b38a20 100644 --- a/scripts/powershell/create_users_csv.ps1 +++ b/scripts/powershell/create_users_csv.ps1 @@ -19,6 +19,8 @@ $delimiter = [string]$meta.delimiter if ([string]::IsNullOrWhiteSpace($delimiter)) { $delimiter = ',' } $hasHeader = [bool]($meta.has_header -as [bool]) $dryRun = [bool]($meta.dry_run -as [bool]) +$defaultOu = [string]$meta.default_ou + if (-not (Test-Path -Path $csvFile)) { Write-Output (@{ success = $false; message = "CSV file not found: $csvFile" } | ConvertTo-Json -Compress) @@ -60,6 +62,11 @@ foreach ($row in $items) { $ou = $row.ou $groups = $row.groups + if ([string]::IsNullOrWhiteSpace($ou) -and -not [string]::IsNullOrWhiteSpace($defaultOu)) { + $ou = $defaultOu + } + + if ([string]::IsNullOrWhiteSpace($sam) -or [string]::IsNullOrWhiteSpace($pass)) { $results += @{ sam = $sam; success = $false; message = 'Missing samaccountname or password' } $failCount++