Last active
September 9, 2025 11:58
-
-
Save xnekv03/8c9b18a8aed73b84fea6045c52d9f7b0 to your computer and use it in GitHub Desktop.
Generate csv file to create Google Workspace user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Path to save CSV | |
| $csvFile = 'google_workspace_users.csv'; | |
| $domain = 'example.com'; | |
| $address = 'Example Street 25, Springfield'; | |
| // Define CSV headers exactly as required | |
| $headers = [ | |
| 'First Name [Required]', | |
| 'Last Name [Required]', | |
| 'Email Address [Required]', | |
| 'Password [Required]', | |
| 'Password Hash Function [UPLOAD ONLY]', | |
| 'Org Unit Path [Required]', | |
| 'New Primary Email [UPLOAD ONLY]', | |
| 'Status [READ ONLY]', | |
| 'Last Sign In [READ ONLY]', | |
| 'Recovery Email', | |
| 'Home Secondary Email', | |
| 'Work Secondary Email', | |
| 'Recovery Phone [MUST BE IN THE E.164 FORMAT]', | |
| 'Work Phone', | |
| 'Home Phone', | |
| 'Mobile Phone', | |
| 'Work Address', | |
| 'Home Address', | |
| 'Employee ID', | |
| 'Employee Type', | |
| 'Employee Title', | |
| 'Manager Email', | |
| 'Department', | |
| 'Cost Center', | |
| '2sv Enrolled [READ ONLY]', | |
| '2sv Enforced [READ ONLY]', | |
| 'Building ID', | |
| 'Floor Name', | |
| 'Floor Section', | |
| 'Email Usage [READ ONLY]', | |
| 'Drive Usage [READ ONLY]', | |
| 'Photos Usage [READ ONLY]', | |
| 'Storage limit [READ ONLY]', | |
| 'Storage Used [READ ONLY]', | |
| 'Change Password at Next Sign-In', | |
| 'New Status [UPLOAD ONLY]', | |
| 'Advanced Protection Program enrollment', | |
| 'Gemini Limit Status [READ ONLY]', | |
| ]; | |
| // user data | |
| $users = [ | |
| [ | |
| 'John', // First Name | |
| 'Lennon', // Last Name | |
| 'mh@'.$domain, // Email | |
| substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 8), // Password | |
| '', // Password Hash Function | |
| '/', // Org Unit Path | |
| '', // New Primary Email | |
| 'Active', // Status | |
| '', // Last Sign In | |
| '', // Recovery Email | |
| '', // Home Secondary Email | |
| '', // Work Secondary Email | |
| '+420123456789', // Recovery Phone | |
| '', // Work Phone | |
| '', // Home Phone | |
| '+420123456789', // Mobile Phone | |
| $address, // Work Address | |
| '', // Home Address | |
| '', // Employee ID | |
| '', // Employee Type | |
| '', // Employee Title | |
| '', // Manager Email | |
| '', // Department | |
| '', // Cost Center | |
| '', // 2sv Enrolled | |
| '', // 2sv Enforced | |
| '', // Building ID | |
| '', // Floor Name | |
| '', // Floor Section | |
| '', // Email Usage | |
| '', // Drive Usage | |
| '', // Photos Usage | |
| '--', // Storage limit | |
| '0.0GB', // Storage Used | |
| 'TRUE', // Change Password at Next Sign-In | |
| '', // New Status | |
| 'FALSE', // Advanced Protection Program enrollment | |
| '-', // Gemini Limit Status | |
| ], | |
| ]; | |
| // Open CSV for writing | |
| $fp = fopen($csvFile, 'w'); | |
| // Write headers | |
| fputcsv($fp, $headers); | |
| // Write each user | |
| foreach ($users as $user) { | |
| fputcsv($fp, $user); | |
| } | |
| // Close file | |
| fclose($fp); | |
| echo "CSV file '$csvFile' created successfully.\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment