@@ -22,7 +22,7 @@ function New-AADUser {
22
22
param (
23
23
[parameter (Mandatory = $false , ValueFromPipelineByPropertyName = $true ,
24
24
HelpMessage = " Controls whether the new user account is created enabled or disabled. The default value is true." )]
25
- [string ]
25
+ [bool ]
26
26
$accountEnabled = $true ,
27
27
28
28
[parameter (Mandatory = $true , ValueFromPipelineByPropertyName = $true ,
@@ -47,7 +47,7 @@ function New-AADUser {
47
47
48
48
[parameter (Mandatory = $false , ValueFromPipelineByPropertyName = $true ,
49
49
HelpMessage = " Controls whether the new user will be required to change their password at the next interactive login. The default value is true." )]
50
- [string ]
50
+ [bool ]
51
51
$forceChangePasswordNextLogin = $true ,
52
52
53
53
[parameter (Mandatory = $false , ValueFromPipelineByPropertyName = $true ,
@@ -147,12 +147,6 @@ function New-AADUser {
147
147
[string ]
148
148
$telephoneNumber ,
149
149
150
- [parameter (Mandatory = $false , ValueFromPipelineByPropertyName = $true ,
151
- HelpMessage = " A thumbnail photo to be displayed for the user." )]
152
- [alias (" Photo" )]
153
- [byte []]
154
- $thumbnailPhoto ,
155
-
156
150
[parameter (Mandatory = $false , ValueFromPipelineByPropertyName = $true ,
157
151
HelpMessage = " Not sure what this is :)." )]
158
152
[string ]
@@ -178,8 +172,10 @@ function New-AADUser {
178
172
if ($key -eq " city" -or $key -eq " country" -or $key -eq " department" -or $key -eq " dirSyncEnabled" -or $key -eq " facsimileTelephoneNumber" -or `
179
173
$key -eq " givenName" -or $key -eq " jobTitle" -or $key -eq " mail" -or $key -eq " mobile" -or $key -eq " otherMails" -or `
180
174
$key -eq " passwordPolicies" -or $key -eq " physicalDeliveryOfficeName" -or $key -eq " postalCode" -or $key -eq " preferredLanguage" -or `
181
- $key -eq " state" -or $key -eq " streetAddress" -or $key -eq " surname" -or $key -eq " telephoneNumber" -or $key -eq " thumbnailPhoto" -or $key -eq " usageLocation" ) {
182
- Add-Member - InputObject $newUser –MemberType NoteProperty –Name $key –Value $value
175
+ $key -eq " state" -or $key -eq " streetAddress" -or $key -eq " surname" -or $key -eq " telephoneNumber" -or $key -eq " usageLocation" ) {
176
+ if ($value -ne " " -and $value -ne $null ){
177
+ Add-Member - InputObject $newUser –MemberType NoteProperty –Name $key –Value $value
178
+ }
183
179
}
184
180
}
185
181
@@ -337,12 +333,6 @@ function Set-AADUser {
337
333
[string ]
338
334
$telephoneNumber ,
339
335
340
- [parameter (Mandatory = $false ,
341
- HelpMessage = " A thumbnail photo to be displayed for the user." )]
342
- [alias (" Photo" )]
343
- [byte []]
344
- $thumbnailPhoto ,
345
-
346
336
[parameter (Mandatory = $false ,
347
337
HelpMessage = " Not sure what this is :)." )]
348
338
[string ]
@@ -358,7 +348,7 @@ function Set-AADUser {
358
348
$key -eq " city" -or $key -eq " country" -or $key -eq " department" -or $key -eq " dirSyncEnabled" -or $key -eq " facsimileTelephoneNumber" -or `
359
349
$key -eq " givenName" -or $key -eq " jobTitle" -or $key -eq " mail" -or $key -eq " mobile" -or $key -eq " otherMails" -or `
360
350
$key -eq " passwordPolicies" -or $key -eq " physicalDeliveryOfficeName" -or $key -eq " postalCode" -or $key -eq " preferredLanguage" -or `
361
- $key -eq " state" -or $key -eq " streetAddress" -or $key -eq " surname" -or $key -eq " telephoneNumber" -or $key -eq " thumbnailPhoto " -or $key -eq " usageLocation" ) {
351
+ $key -eq " state" -or $key -eq " streetAddress" -or $key -eq " surname" -or $key -eq " telephoneNumber" -or $key -eq " usageLocation" ) {
362
352
Add-Member - InputObject $updatedUser - MemberType NoteProperty - Name $key - Value $value
363
353
}
364
354
}
@@ -371,4 +361,36 @@ function Set-AADUser {
371
361
372
362
Set-AADObject - Type users - Id $Id - Object $updatedUser
373
363
}
374
- }
364
+ }
365
+
366
+ function Set-AADUserThumbnailPhoto {
367
+ [CmdletBinding ()]
368
+ param (
369
+ [parameter (Mandatory = $true ,
370
+ ValueFromPipeline = $true ,
371
+ HelpMessage = " Either the ObjectId or the UserPrincipalName of the User." )]
372
+ [string ]
373
+ $Id ,
374
+
375
+ # cmdlet allows multiple ways to specify the thumbnail photo, using parameter sets.
376
+ [parameter (Mandatory = $true ,
377
+ HelpMessage = " File path of the thumbnail photo of the user." ,
378
+ ParameterSetName = ' FilePath' )]
379
+ [ValidateScript ({ Test-Path $_ })]
380
+ [string ]
381
+ $ThumbnailPhotoFilePath ,
382
+
383
+ [parameter (Mandatory = $true ,
384
+ HelpMessage = " Byte array representation of the thumbnail photo of the user." ,
385
+ ParameterSetName = ' ByteArray' )]
386
+ [byte []]
387
+ $ThumbnailPhotoByteArray
388
+ )
389
+ PROCESS {
390
+ $value = $null
391
+ if ($PSBoundParameters.ContainsKey (' ThumbnailPhotoFilePath' )){$value = [System.IO.File ]::ReadAllBytes($ThumbnailPhotoFilePath )}
392
+ else {$value = $ThumbnailPhotoByteArray }
393
+
394
+ Set-AADObjectProperty - Type " users" - Id $Id - Property " thumbnailPhoto" - Value $value - IsLinked $false - ContentType " image/jpeg"
395
+ }
396
+ }
0 commit comments