Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Username = "name@company.com"
- $PasswordPath = "c:\scripts\password.txt"
- # Read the password from the file and convert to SecureString
- Write-Host "Getting password from $passwordpath"
- $SecurePassword = Get-Content $PasswordPath | ConvertTo-SecureString
- # Build a Credential Object from the password file and the $username constant
- $Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword
- # Open a session to O365
- $O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
- import-pssession $O365session
- # Recurse through the Projects Public Folder and mail-enable those that aren't currently mail enabled, and mail-disable the top level folders.
- $folders = get-publicfolder "\TEST" -recurse -resultsize unlimited
- foreach($folder in $folders)
- {
- $owners = Get-PublicFolderClientPermission -identity $folder.identity | ? {$_.accessrights -eq "Owner" }
- foreach($owner in $owners)
- {
- Remove-PublicFolderClientPermission -Identity $folder.identity -user "$($owner.user)" -confirm:$false
- Add-PublicFolderClientPermission -Identity $folder.identity -user "$($owner.user)" -AccessRights CreateItems,ReadItems,CreateSubfolders,FolderOwner,FolderContact,FolderVisible,EditOwnedItems,EditAllItems
- }
- }
- Remove-PSSession $O365Session
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement