Created
July 1, 2022 13:27
-
-
Save JeffWouters/117c06313f45cd11a0b4a816ef1be7b3 to your computer and use it in GitHub Desktop.
Friducation
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
| <# | |
| .SYNOPSIS | |
| A function to create a user. | |
| .DESCRIPTION | |
| A function to create a user on the AzureAD. | |
| .PARAMETER FirstName | |
| Provide the first name of the user to be created. | |
| .PARAMETER LastName | |
| Provide the last name of the user to be created. | |
| .EXAMPLE | |
| New-MthsUser -First 'Jeff' -Last 'Wouters' | |
| .EXAMPLE | |
| New-MthsUser 'Jeff' 'Wouters' | |
| .EXAMPLE | |
| Import-Csv -Path .\users.csv | ForEach-Object {New-MthsUser -First $_.First -Last $_.Last} | |
| .EXAMPLE | |
| Import-Csv -Path .\users.csv | New-MthsUser | |
| .NOTES | |
| Customer : KPN | |
| Company : Methos | |
| Author : Jeff Wouters | |
| #> | |
| function New-MthsUser { | |
| param ( | |
| [parameter( | |
| Mandatory=$true, | |
| Position=0, | |
| ValueFromPipeline=$true, | |
| ValueFromPipelineByPropertyName=$true | |
| )] | |
| [Alias('First')] | |
| [string]$FirstName, | |
| [parameter( | |
| Mandatory=$true, | |
| Position=1, | |
| ValueFromPipeline=$true, | |
| ValueFromPipelineByPropertyName=$true | |
| )] | |
| [Alias('Last')] | |
| [string]$LastName | |
| ) | |
| begin { | |
| } | |
| process { | |
| try { | |
| New-Item -ItemType File -Name "$FirstName-$LastName" | |
| } | |
| catch { | |
| $_ | Write-Error | |
| } | |
| } | |
| end { | |
| } | |
| } | |
| Import-Csv -Path .\users.csv | New-MthsUser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment