![]() For other Office 365 connections, like Connect-AzureAD, a PowerShell module named “CredentialManager” can be used.Īfter installing the module, the cmdlet Get-StoredCredential can be used to retrieve a credential object. PnP PowerShell has native support for the Windows Credential Manager as described here. ![]() It is recommended to name the files differently than “username.txt” and “password.txt”, but for the intend of better understanding this blog post, they are called this way in the sample code above. $credential = New-Object -TypeName '' -ArgumentList $username,$password $password = Get-Content -LiteralPath 'D:\PowerShell\password.txt' | ConvertTo-SecureString Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File -LiteralPath 'D:\PowerShell\password.txt'Ī credential object is now created with the following code: $username = Get-Content -LiteralPath 'D:\PowerShell\username.txt' ![]() The following code creates the files on disc: Read-Host | Out-File -LiteralPath 'D:\PowerShell\username.txt' With file storage, one file can be used, but using two files is more straightforward. In other words, some form of credential (username / password) storage is required. It may no longer be relevant.īeing able to automate tasks for Office 365 with PowerShell without any form of user intervention requires a PowerShell script to be able to authenticate by itself.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |