User Profile
adrianhalid
Copper Contributor
Joined 6 years ago
User Widgets
Recent Discussions
Re: onedrive list of admin
Lisa Gentry Where ever you see a Write-Host you could just output to a file on your disk. Try using Add-Content or Out-File. Add-Content (Microsoft.PowerShell.Management) - PowerShell | Microsoft Docs Out-File (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs8.1KViews0likes0CommentsHow frequent does onedrive sync PST files?
The documentation states "Outlook .PST files are supported. However they are synced less frequently compared to other file types to reduce network traffic." How frequently are PST files synced? Is it possible to remove this restriction, so they sync when a change occurs? https://support.microsoft.com/en-us/office/restrictions-and-limitations-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa?ui=en-us&rs=en-us&ad=us#invalidblockedfiletypes I use the Safe PST backup software nightly to copy my archived pst file into a OneDrive folder to be stored in the cloud for DR backup purposes. The problem is that by the next morning, the backup file has not synced in OneDrive. I just recently moved from Dropbox to Onedrive and never had this issue with pst files and Dropbox.2.4KViews1like0CommentsRe: onedrive list of admin
Alex Carlock Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking $AdminAccount = "administrator@company.com" $AdminCenterURL = "https://company-admin.sharepoint.com/" #Connect to SharePoint Online Admin Center Connect-SPOService -Url $AdminCenterURL #Get All OneDrive for Business Sites in the Tenant $OneDriveSites = Get-SPOSite -Limit ALL -includepersonalsite $True -Filter "Url -like '-my.sharepoint.com/personal/'" #Loop through each OneDrive Site Foreach($Site in $OneDriveSites) { Write-host "Scanning site:"$Site.Url -f Yellow try{ $checkadmin = Get-SPOUser -Site $Site.Url | Where {$_.IsSiteAdmin -eq $true -and $_.LoginName -eq $AdminAccount} $setAdmin = $false; #Add Temp Site Admin if($checkadmin.Count -eq 0){ #Write-host "Add Temp Admin:"$Site.URL -f Gray Set-SPOUser -Site $Site -LoginName $AdminAccount -IsSiteCollectionAdmin $True | Out-Null $setAdmin = $true } }catch{ #Write-Host "Error:" $_.Exception.Message if($_.Exception.Message -like "Access is denied*"){ #Write-host "Add Temp Admin:"$Site.URL -f Gray Set-SPOUser -Site $Site -LoginName $AdminAccount -IsSiteCollectionAdmin $True | Out-Null $setAdmin = $true } } #Get All Site Collection Administrators $SiteAdmins = Get-SPOUser -Site $Site.Url | Where {$_.IsSiteAdmin -eq $true -and $_.LoginName -ne $AdminAccount -and $_.LoginName -ne $Site.Owner} if($SiteAdmins.Count -gt 0){ #Iterate through each admin Foreach($Admin in $SiteAdmins) { Write-host "Found other Admin:"$Admin.LoginName -f Blue } } #Remove Temp Site Administrator if added if($setAdmin -eq $true){ #Write-host "Remove Temp Admin:"$Site.URL -f Gray Set-SPOUser -site $Site -LoginName $AdminAccount -IsSiteCollectionAdmin $False | Out-Null } }8.8KViews0likes3CommentsRe: Profile Photo Sync SPO
I thought this might help others. Based on a previous post I created this script to work with O365 with MFA enabled. This PowerShell script will allow you to sync a user profile photo from Exchange Online to Sharepoint Online. You can select a single email address or choose "All" EDIT: Added Try-Catch block around section for some error handling. #Add references to SharePoint client assemblies and authenticate to Office 365 site – required for CSOM Add-Type -AssemblyName System.Drawing Function UploadImage () { Param( [Parameter(Mandatory=$True)] [String]$SiteURL, [Parameter(Mandatory=$True)] [String]$SPOAdminPortalUrl, [Parameter(Mandatory=$True, HelpMessage="Enter user email address or All for all mailboxes")] [String]$UserEmail ) #Defualt Image library and Folder value $DocLibName ="User Photos" $foldername="Profile Pictures" Connect-ExchangeOnline $siteConnection = Connect-PnPOnline -Url $SiteURL –Interactive -ReturnConnection #NOTE: there is a bug in Set-PnPUserProfileProperty in which the ConnectPnPOnline must connect with the UseWebLogin option # https://github.com/pnp/powershell/issues/277 $adminConnection = Connect-PnPOnline -Url $SPOAdminPortalUrl –UseWebLogin -ReturnConnection $spoimagename = @{"_SThumb" = "48"; "_MThumb" = "72"; "_LThumb" = "200"} $allUserMailboxes = Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox Foreach($mailbox in $allUserMailboxes) { if(($mailbox.PrimarySmtpAddress -eq $UserEmail) -or ($UserEmail -eq "All")){ Write-Host "Processing " $mailbox.PrimarySmtpAddress try{ #Download Image from Exchange online $photo = Get-UserPhoto -Identity $mailbox.Identity Write-Host "Exchange online image downloaded successful for" $mailbox.PrimarySmtpAddress $username = $mailbox.PrimarySmtpAddress.Replace("@", "_").Replace(".", "_") $Extension = ".jpg" Foreach($imagename in $spoimagename.GetEnumerator()) { #Covert image into different size of image $ms = new-object System.IO.MemoryStream(,$photo.PictureData) $img = [System.Drawing.Image]::FromStream($ms) [int32]$new_width = $imagename.Value [int32]$new_height = $imagename.Value $img2 = New-Object System.Drawing.Bitmap($new_width, $new_height) $graph = [System.Drawing.Graphics]::FromImage($img2) $graph.DrawImage($img, 0, 0, $new_width, $new_height) #Covert image into memory stream $stream = New-Object -TypeName System.IO.MemoryStream $format = [System.Drawing.Imaging.ImageFormat]::Jpeg $img2.Save($stream, $format) $streamseek=$stream.Seek(0, [System.IO.SeekOrigin]::Begin) #Upload image into sharepoint online $FullFilename=$username+$imagename.Name+$Extension Add-PnPFile -Connection $siteConnection -Folder "User Photos/Profile Pictures" -FileName $FullFilename -Stream $stream } Write-Host "SharePoint online image uploaded successful for" $mailbox.PrimarySmtpAddress #Change user Profile Property in Sharepoint onlne $PictureURL=$SiteURL+$DocLibName+"/"+$foldername+"/"+$username+"_MThumb"+$Extension Set-PnPUserProfileProperty -Connection $adminConnection -Account $mailbox.PrimarySmtpAddress -PropertyName PictureURL -Value $PictureURL Set-PnPUserProfileProperty -Connection $adminConnection -Account $mailbox.PrimarySmtpAddress -PropertyName SPS-PicturePlaceholderState -Value 0 Set-PnPUserProfileProperty -Connection $adminConnection -Account $mailbox.PrimarySmtpAddress -PropertyName SPS-PictureExchangeSyncState -Value 0 Set-PnPUserProfileProperty -Connection $adminConnection -Account $mailbox.PrimarySmtpAddress -PropertyName SPS-PictureTimestamp -Value 63605901091 Write-Host "Image processed successfully and ready to display for" $mailbox.PrimarySmtpAddress }catch{ $ErrorMessage = $_.Exception.Message Write-Host "Failed to process " $mailbox.PrimarySmtpAddress -ForegroundColor red Write-Host $ErrorMessage -ForegroundColor red } } } } #Input parameter $siteUrl="https://company-my.sharepoint.com/" $SPOAdminPortalUrl = "https://company-admin.sharepoint.com/" uploadimage -SiteURL $siteUrl -SPOAdminPortalUrl $SPOAdminPortalUrl20KViews1like3CommentsRe: Profile Photo Sync SPO
Be careful when you do the All option, as I haven't put error handling in the code. So exceptions will occur if the Exchange Online mailbox does not have a profile picture. As I don't reset any of the variables in the for loop, you might accidentally have the previous person photo applied to the user without the profile picture in Exchange Online.20KViews0likes0CommentsRe: Create a meeting in a 365-Group calendar without inviting the whole team? Question and critic!
DanielNiccoli I believe this PowerShell command will do what is needed. # Set the team name to target $Team = "TeamName" # This will ensure when new members are added to the team they do not subscribe to calendar events Set-UnifiedGroup $Team -AlwaysSubscribeMembersToCalendarEvents:$false # Get all the current members in a Team $Members = Get-UnifiedGroupLinks -LinkType Members -Identity $Team # Loop over all the members Foreach ($M in $Members){ #Remove the team member from the "Subscribers" Link type using their email address. Remove-UnifiedGroupLinks -Identity $Team -LinkType Subscribers -Links $M.PrimarySmtpAddress }8.3KViews3likes0CommentsRe: seach-mailbox group mailbox
VasilMichev Thanks. Just had a look athttps://gsexdev.blogspot.com/2015/05/using-office-365-groups-within-ews.htmlbut it seems to be referencing Microsoft.Exchange.WebServices.Data.Groups.RequestedUnifiedGroupsSet I have installed the Microsoft Exchange Web Services Managed API 2.2 https://www.microsoft.com/en-us/download/details.aspx?id=42951 But can't find that Groups Library. https://docs.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data?view=exchange-ews-api I can find in the open source library https://github.com/OfficeDev/ews-managed-api/tree/master But I don't think is been implemented in 2.2. I will continue to read the documentation1.6KViews0likes0CommentsRe: seach-mailbox group mailbox
VasilMichev Is this what you a referring to when you say EWS-based scripts? https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/explore-the-ews-managed-api-ews-and-web-services-in-exchange I am currently looking through the documentation trying to figure out how to get the mailbox or folder. I have tried the select and delete all using the desktop and web client but it doesn't seem to do anything thing when I click delete all. I can delete in batches on what is displayed on the screen. But it a tedious repetitive process. I would just like a script I can run that deletes all.1.6KViews0likes2CommentsRe: seach-mailbox group mailbox
VasilMichev I have the eDiscovery Administrator role. Is there a way to batch delete emails from a group mailbox. I have a testing application that has sent a lot of emails to that group mailbox. I wish to empty the entire group mailbox. Whats the best way to do this?1.7KViews0likes4Commentsseach-mailbox group mailbox
ow do you search a group mailbox. Search-Mailbox -Identity "groupbox@mail.com" -SearchQuery 'Subject:"Hello"' -TargetMailbox me@mail.com -TargetFolder "Inbox" When I try to search the group mailbox I get the error message. The operation couldn't be performed because object 'groupbox@mail.com' couldn't be found on 'xxxxxx.PROD.OUTLOOK.COM'. But when I search for the mailbox I can find it. Get-Mailbox -GroupMailbox -Identity "groupbox@mail.com" Is it because it is a group mailbox? How do you search a group mailbox?1.7KViews0likes6Comments
Recent Blog Articles
No content to show