Open pedrr opened 4 years ago
This would be really usefull
Check out the development branch. With the move to MSAL we now offer other options besides username/password. It will move to master soon.
There is a much simpler thin. I will publish it in a few days. You can use the new Microsoft.Graph module which is much better and supports everything. I only continue to use the module here to encrypt the pfx password, so probably the module could just be reduced to create the correct object.
$UserPfx = New-IntuneUserPfxCertificate -PathToPfxFile "$($env:ProgramData)\baseVISION-SMIME\temp\cert.pfx" -PfxPassword $Password -ProviderName "Microsoft Software Key Storage Provider" -KeyName "SMIME" -IntendedPurpose SmimeSigning -UPN $Upn
# creating hashtable as an object is not working
$UserPfxBody = @{
CreatedDateTime = $UserPfx.CreatedDateTime
EncryptedPfxBlob = $UserPfx.EncryptedPfxBlob
EncryptedPfxPassword = $UserPfx.EncryptedPfxPassword
ExpirationDateTime = $UserPfx.ExpirationDateTime.DateTime
IntendedPurpose = $UserPfx.IntendedPurpose
KeyName = $UserPfx.KeyName
LastModifiedDateTime = $UserPfx.LastModifiedDateTime.DateTime
PaddingScheme = $UserPfx.PaddingScheme
ProviderName = $UserPfx.ProviderName
StartDateTime = $UserPfx.StartDateTime.DateTime
Thumbprint = $UserPfx.Thumbprint
UserPrincipalName = $UserPfx.UserPrincipalName
}
Write-Log -Message "Start uploading cert to Intune" -Type Debug
New-MgDeviceManagementUserPfxCertificate -BodyParameter $UserPfxBody
Please add the functionality to authenticate with the application itself and not delegated permissions. This will enable authentication via certificate instead of username/password.