Forum Widgets
Latest Discussions
I want to create Sharepoint Verisoning Report on my Tenant
I have created a script, but dont seem to be able to find out how many file versions there are , Config Variables $TenantAdminURL = "https://admin.sharepoint.com" $CSVFilePath = "C:\Temp\RESTART.csv" #Get the Root Web #$Web = Get-PnpWeb #$versions = Get-SPOListItemVersion -ListItem $listItem #Get the Site Title Write-host -f Green $Web.Title #Connect to Admin Center using PnP Online Connect-PnPOnline -Url $TenantAdminURL -ClientId “cabf4-cc9b-4dcf-807b-8af94c3c4333" -Interactive -ForceAuthentication #Delete the Output Report, if exists if (Test-Path $CSVFilePath) { Remove-Item $CSVFilePath } #Get All Site collections - Exclude: Seach Center, Redirect site, Mysite Host, App Catalog, Content Type Hub, eDiscovery and Bot Sites $SiteCollections = Get-PnPTenantSite | Where { $.URL -like '/sites' -and $.Template -NotIn ("SRCHCEN#0", "REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")} #Get All Large Lists from the Web - Exclude Hidden and certain lists $ExcludedLists = @("Form Templates","Site Assets", "Pages", "Site Pages", "Images", "Site Collection Documents", "Site Collection Images","Style Library") $SiteCounter = 1 #Loop through each site collection ForEach($Site in $SiteCollections) { #Display a Progress bar Write-Progress -id 1 -Activity "Processing Site Collections" -Status "Processing Site: $($Site.URL)' ($SiteCounter of $($SiteCollections.Count))" -PercentComplete (($SiteCounter / $SiteCollections.Count) * 100) #Connect to the site Connect-PnPOnline -Url $Site.URL -Interactive #Get all document libraries $DocumentLibraries = Get-PnPList | Where-Object {$_.BaseType -eq "DocumentLibrary" -and $_.Hidden -eq $False -and $_.Title -notin $ExcludedLists -and $_.ItemCount -gt 0} $ListCounter = 1 $ItemsColl = $List2.Items #Iterate through document libraries ForEach ($List in $DocumentLibraries) { $global:counter = 0 $FileData = @() Write-Progress -id 2 -ParentId 1 -Activity "Processing Document Libraries" -Status "Processing Document Library: $($List.Title)' ($ListCounter of $($DocumentLibraries.Count))" -PercentComplete (($ListCounter / $DocumentLibraries.Count) * 10) #Get All Files of the library with size > 100MB $Files = Get-PnPListItem -List $List -Fields FileLeafRef,FileRef,SMTotalFileStreamSize -PageSize 500 -ScriptBlock { Param($items) $global:counter += $items.Count; Write-Progress -Id 3 -parentId 2 -PercentComplete ($global:Counter / ($List.ItemCount) * 10) -Activity "Getting List Items of '$($List.Title)'" -Status "Processing Items $global:Counter to $($List.ItemCount)";} | Where {($_.FileSystemObjectType -eq "File") -and ($_.FieldValues.SMTotalFileStreamSize/1MB -gt 100)} #Collect data from each files ForEach ($File in $Files) { $FileData += [PSCustomObject][ordered]@{ Site = $Web.url Library = $List.Title FileName = $File.FieldValues.FileLeafRef URL = $File.FieldValues.FileRef Size = [math]::Round(($File.FieldValues.SMTotalFileStreamSize/1MB),2) } } #Export Files data to CSV File $FileData | Sort-object Size -Descending $FileData | Export-Csv -Path $CSVFilePath -NoTypeInformation -Append $ListCounter++ #Write-Progress -Activity "Completed Processing List $($List.Title)" -Completed -id 2 } $SiteCounter++ }NightWing2099Feb 06, 2025Copper Contributor4Views0likes0CommentsSearch-UnifiedAuditLog limitation on number of results
Hi, I need to extract PowerBI audit logs in order to get some valuable information. So, I'm using Search-UnifiedAuditLog command, which according to the documentation could parse 50.000 records. But in fact using the switch "-SessionCommand ReturnLargeSet" still returns 100 records. If I use the switch "-ResultSize 5000" then I can get 5.000 records. But I've made that search on the compliance portal and I've got about 110k results. So how can I get this 110k results via the Search-UnifiedAuditLog command? Anyone faced a similar issue? Documentation link: https://learn.microsoft.com/en-us/powershell/module/exchange/search-unifiedauditlog?view=exchange-ps ThanksSolveddmarquesgnFeb 05, 2025Iron Contributor3.7KViews0likes8CommentsError PowerShell 30015-1015 (80)
Hello, using P.Shell for office installation, with ODT, it gives me the following error shown in the photo, or opening the console in any folder with the right mouse button "open the P.S. window here" gives an error: Missing termination character in the string: ". + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString or Set-Location : Impossibile trovare un parametro posizionale che accetta l'argomento 'Ripristino\Office\Office'. In riga:1 car:1 + Set-Location -literalPath D:\Ripristino\File Ripristino\Office\Office ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand While if I run the command on the desktop, the window opens normally! ThanksAlpha45Feb 05, 2025Brass Contributor18Views0likes1CommentBest way to remove UseClientIntegration from each role definition (SharePoint Online)
I've created a PS script that removes Use Client integration from each permission level (role definition). This works, but as a side effect it gives the custom role definitions a new id. This can cause issues further down the line. Here is the part of the script which replaces the existing permission levels (role defs): #Install App to the Site Install-PnPApp -Identity $App.Id # Get all existing role definitions $roleDefinitions = Get-PnPRoleDefinition foreach ($role in $roleDefinitions) { # Create a new custom role definition by copying the existing one $newRoleName = "Custom_" + $role.Name # Clone the existing permission levels excluding Client Int.: Add-PnPRoleDefinition -RoleName $newRoleName -Clone $role -Exclude UseClientIntegration # Remove the original role definition Remove-PnPRoleDefinition -Identity $role.Name -Force } # Get the new role definitions: $newRoleDefinitions = Get-PnPRoleDefinition # Rename each permission to remove the "Custom_" foreach ($newRole in $newRoleDefinitions) { Set-PnPRoleDefinition -Identity $newRole.Name -NewRoleName $newRole.Name.TrimStart("Custom_") } # Remove the erroneously created permission levels: if($role.Name -eq "Custom_Limited Access" -or "Custom_Web-Only Limited Access" -or "Custom_Full Control") { Remove-PnPRoleDefinition -Identity "Custom_Limited Access" -Force Remove-PnPRoleDefinition -Identity "Custom_Web-Only Limited Access" -Force Remove-PnPRoleDefinition -Identity "Custom_Full Control" -Force Set-PnPRoleDefinition -Identity "ntribute" -NewRoleName "Contribute" #Not sure why earlier in the script it changes Contribute to "ntribute" but i'm having to rename it here. } I need a better way to do this, as you can see it's an amateur effort. I need someway to remove UserClientIntegration from each permission level but keep the original permission level role def id.CardinalNightFeb 05, 2025Brass Contributor14Views0likes0CommentsI want to change auto aftandend number using powershell
Hello, i want to create a powershell script where i can change the Auto attendant of the teams admin so that users can change the phone number of the after hours without having a teams admin license, does anyone know how i can change the number of the Auto attendants using powershell? Its in Auto attendants -> your Auto attendant -> Call flow for after hours -> Call routing options - > redirect call -> phone number that i want to change using powershell.SolveddanikoershuisFeb 04, 2025Copper Contributor74Views0likes8CommentsI tried to make a script to change a phone number in auto attendent teams
Hello, i want to create a powershell script where i can change the Auto attendant of the teams admin so that users can change the phone number of the after hours without having a teams admin license, does anyone know how i can change the number of the Auto attendants using powershell? Its in Auto attendants -> your Auto attendant -> Call flow for after hours -> Call routing options - > redirect call -> phone number that i want to change using powershell. I made a script but it does not seem to work. could someone please tell me what is wrong with it? # connect with teams Connect-MicrosoftTeams # Set up variable $AutoAttendantId = "3d7ff2b0-1b1e-4bd8-92c3-cb4e3316d6be" $NewPhoneNumber = "+31625450875" # Get auto attendant $AA = Get-CsAutoAttendant -Identity $AutoAttendantId if (-not $AA) { Write-Host "Auto Attendant not found. Please check the ID." -ForegroundColor Red Exit } # Go to after hours $AfterHoursCallFlow = $AA.CallFlows | Where-Object { $_.Name -like "*After hours*" } if (-not $AfterHoursCallFlow) { Write-Host "After Hours Call Flow not found. Please check the settings." -ForegroundColor Red Exit } # go to menu screen of phone number $AfterHoursCallFlow.CallRouting | ForEach-Object { if ($_.Type -eq "PhoneNumber") { $_.PhoneNumber = $NewPhoneNumber } } # Update de Auto Attendant with new settings Set-CsAutoAttendant -Instance $AA # Show tekst that its completed Write-Host "Phone number updated successfully to $NewPhoneNumber" -ForegroundColor GreendanikoershuisFeb 03, 2025Copper Contributor24Views0likes1CommentNew-MgBookingBusinessService CustomQuestions
Hi! I'm working my way though BookingBusiness with PowerShell, so please forgive me if this is obvious. I've tried combing documentation but nothing seems to work. I have this script, and first, I think I have to create the customQuestions and have done so successfully and have the reference IDs for the questions to use in the New-MgBookingBusinessService script. I cannot seem to get the customQuestion piece to work. I'm first getting the available business staff and the custom questions I've already created. Everything works until I try the CustomQuestions piece. Here is what I have if you could please provide any assistance or guidance. Thank you! # Define the Booking Business ID $bookingBusinessId = "SCRUBBED" # Path to your CSV file $csvFilePath = "SCRUBBED" # Import CSV file $staffEmails = Import-Csv -Path $csvFilePath # Retrieve all staff members for the booking business Write-Host "Fetching all staff members for booking business ID: $bookingBusinessId" $allStaff = Get-MgBookingBusinessStaffMember -BookingBusinessId $bookingBusinessId # Ensure $allStaff is not null or empty if (-not $allStaff) { Write-Error "No staff members found for the booking business ID: $bookingBusinessId" return } # Debugging: Display all staff members retrieved (with Email and ID) Write-Host "Staff members retrieved (Email and ID):" -ForegroundColor Green $allStaff | ForEach-Object { $email = $_.AdditionalProperties["emailAddress"] $id = $_.Id $displayName = $_.AdditionalProperties["displayName"] Write-Host "DisplayName: $displayName, Email: $email, ID: $id" -ForegroundColor Yellow } # Retrieve all custom questions for the booking business Write-Host "Fetching all custom questions for booking business ID: $bookingBusinessId" $allCustomQuestions = Get-MgBookingBusinessCustomQuestion -BookingBusinessId $bookingBusinessId # Ensure $allCustomQuestions is not null or empty if (-not $allCustomQuestions) { Write-Error "No custom questions found for the booking business ID: $bookingBusinessId" return } # Debugging: Display all custom questions retrieved (with ID and DisplayName) Write-Host "Custom questions retrieved (ID and DisplayName):" -ForegroundColor Green $allCustomQuestions | ForEach-Object { $id = $_.Id $displayName = $_.DisplayName Write-Host "ID: $id, DisplayName: $displayName" -ForegroundColor Yellow } # Loop through each staff member in the CSV and create an individual service for them Write-Host "Creating individual booking services for each staff member..." $staffEmails | ForEach-Object { $email = $_.staffemail.Trim().ToLower() # Find the matching staff member by email $matchingStaff = $allStaff | Where-Object { $_.AdditionalProperties["emailAddress"] -and ($_.AdditionalProperties["emailAddress"].Trim().ToLower() -eq $email) } if ($matchingStaff) { $staffId = $matchingStaff.Id Write-Host "Match found: Email: $email -> ID: $staffId" -ForegroundColor Cyan # Create the booking service for the matched staff member try { $serviceParams = @{ BookingBusinessId = $bookingBusinessId DisplayName = "$($matchingStaff.AdditionalProperties["displayName"]) Family Conference" StaffMemberIds = @($staffId) # Create a service only for this staff member DefaultDuration = [TimeSpan]::FromHours(1) DefaultPrice = 50.00 DefaultPriceType = "free" Notes = "Please arrive 10 minutes early for your booking." CustomQuestions = $allCustomQuestions | ForEach-Object { @{ Id = $_.Id IsRequired = $true # or $false depending on your requirement } } } # Log the parameters being sent Write-Host "Service Parameters for $($matchingStaff.AdditionalProperties["displayName"]):" -ForegroundColor Blue $serviceParams.GetEnumerator() | ForEach-Object { Write-Host "$($_.Key): $($_.Value)" } New-MgBookingBusinessService @serviceParams Write-Host "Booking service successfully created for $($matchingStaff.AdditionalProperties["displayName"])!" -ForegroundColor Green } catch { Write-Error "Failed to create booking service for $($matchingStaff.AdditionalProperties["displayName"]): $_" } } else { Write-Warning "No match found for email: $email" } }AP_TC_ECASDFeb 03, 2025Copper Contributor84Views0likes8CommentsPowershell error when using install-module
Hello ! when I use Install-Module -Name ExchangeOnlineManagement I get the following error : Install-Package: The module 'ExchangeOnlineManagement' cannot be installed or updated because the authenticode signature of the file 'ExchangeOnlineManagement.psd1' is not valid. I use powershell 7.5.0 Any help is welcome. best regardsSolvedplopsplJan 30, 2025Copper Contributor61Views0likes2CommentsInternal Server Error when Setting Mailbox properties
I have a Power shell script to setting Mailbox properties below Notes, Mail Tip, Seniority Index, etc It always run good, but today shows the error below >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> You want to perform this operation? User ID: "MB001.onmicrosoft.com" Y(Yes) You want to perform this operation? User ID: "MB001.onmicrosoft.com" Y(Yes) MB001.onmicrosoft.com Resource setting completed. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> You want to perform this operation? User ID: "MB002.onmicrosoft.com" Y(Yes) You want to perform this operation? User ID: "MB002.onmicrosoft.com" Y(Yes) MB002.onmicrosoft.com Resource setting completed. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> loop.......... >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Then I check all the Mailbox properties, the all settings is correct looks no problem. What kind of error could be possible? Is there any solutions? Any information will be appreciated!JasonPPFJan 29, 2025Copper Contributor67Views0likes2CommentsMgBookingBusiness - Customer information questions
I'm wondering if there's a way to mark the Customer information questions as enabled/disabled and conversely, required, or not, using PowerShell? I would figure it would be somewhere in the params of New-MgBookingBusinessService, but cannot find anything with traction in their lovely documentation. Thank you for any assistance you can offer!AP_TC_ECASDJan 28, 2025Copper Contributor21Views0likes2Comments
Resources
Tags
- Windows PowerShell1,148 Topics
- powershell335 Topics
- office 365270 Topics
- azure active directory137 Topics
- sharepoint127 Topics
- Windows Server127 Topics
- windows97 Topics
- azure94 Topics
- exchange88 Topics
- Community54 Topics