Untitled
unknown
plain_text
a year ago
781 B
8
Indexable
# Set path to the CSV file
$csvPath = "C:\temp\user.csv"
# Import the CSV file
$users = Import-Csv -Path $csvPath
# Group users by 'Functie'
$groupedUsers = $users | Group-Object -Property Functie
# Iterate over each group
foreach ($group in $groupedUsers) {
# Calculate 10% of users for the current function
$totalUsers = $group.Count
$percent10 = [math]::Ceiling($totalUsers * 0.1)
# Select random 10% of users from the current function
$selectedUsers = $group.Group | Get-Random -Count $percent10
# Update 'Retea_test' column for the selected users
foreach ($user in $selectedUsers) {
$user.Retea_test = "ok"
}
}
# Export the updated users back to CSV
$users | Export-Csv -Path $csvPath -NoTypeInformation
Editor is loading...
Leave a Comment