Posts

Showing posts from June, 2024

Export user Permissions from SharePoint Online sites into CSV file

 # Import the SharePoint Online Management Shell Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking # Connect to SharePoint Online $UserCredential = Get-Credential Connect-SPOService -Url "https://YourTenant-admin.sharepoint.com" -Credential $UserCredential # Define the path for the CSV export $csvPath = "C:\\Path\\To\\Export\\UserPermissions.csv" # Function to export user permissions Function Export-SPOUserPermissions {     param (         [Parameter(Mandatory=$true)] [string]$SiteUrl     )          # Connect to the SharePoint site     $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)     $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserCredential.UserName, $UserCredential.Password)          # Load the web and its role assignments     $Web = $Ctx.Web     $Ctx.Load($Web)...

export all Active Directory (AD) security groups along with their members and owners into a CSV file using PowerShell

 # Import the Active Directory module Import-Module ActiveDirectory # Define the path for the CSV export $csvPath = "C:\\Path\\To\\Export\\ADGroups.csv" # Create a custom object for each group with its members and owner $groupsInfo = Get-ADGroup -Filter * -Properties ManagedBy | ForEach-Object {     $group = $_     $members = Get-ADGroupMember -Identity $group -Recursive | Select-Object -ExpandProperty Name     $owner = (Get-ADUser -Identity $group.ManagedBy).Name     foreach ($member in $members) {         [PSCustomObject]@{             GroupName = $group.Name             MemberName = $member             OwnerName = $owner         }     } } # Export the information to a CSV file $groupsInfo | Export-Csv -Path $csvP ath -NoTypeInformation

Power shell script to get member names from AD security groups

 # Import the Active Directory module Import-Module ActiveDirectory # Define the security group name $GroupName = "YourSecurityGroupName" # Get the members of the security group $GroupMembers = Get-ADGroupMember -Identity $GroupName # Loop through each member and display the name foreach ($Member in $GroupMembers) {     Write-Output $Member.name }

Get the OneDrive status and data for all users from tenant.

 Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'" | Select-Object URL, Owner, StorageQuota, StorageUsageCurrent, LastContentModifiedDate $users = Get-Content -path "C:\Users.txt" Request-SPOPersonalSite -UserEmails $users Connect-SPOService -Url https://domain-admin.sharepoint.com

Teams details Owners and members

 # Install Microsoft Teams PowerShell Module if not already installed # Install-Module -Name MicrosoftTeams -Force -AllowClobber # Connect to Microsoft Teams Connect-MicrosoftTeams # Get all Teams groups $teamsGroups = Get-Team # Initialize an array to hold details $teamDetails = @() foreach ($team in $teamsGroups) {    $groupId = $team.GroupId    $teamName = $team.DisplayName    $privacy = $team.Visibility    # Get channels    $channels = Get-TeamChannel -GroupId $groupId    $standardChannelCount = ($channels | Where-Object {$_.MembershipType -eq 'standard'}).Count    $privateChannelCount = ($channels | Where-Object {$_.MembershipType -eq 'private'}).Count    $sharedChannelCount = ($channels | Where-Object {$_.MembershipType -eq 'shared'}).Count    # Get members and owners    $members = Get-TeamUser -GroupId $groupId    $owners = $members | Where-Object {$_.Role -eq 'Owner...

Get Shared Mailbox with delegation access.

 Connect-ExchangeOnline # Define the path for the CSV file $csvPath = "C:\Temp\SharedMailboxesWithDelegatedAccess.csv" # Function to get all shared mailboxes function Get-AllSharedMailboxes {    Write-Output "Retrieving all shared mailboxes..."    $sharedMailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited    Write-Output "Retrieved $($sharedMailboxes.Count) shared mailboxes."    return $sharedMailboxes } # Function to get delegated access permissions for a mailbox function Get-DelegatedAccessPermissions {    param (        [Parameter(Mandatory=$true)]        [string]$MailboxIdentity    )    Write-Output "Retrieving delegated access permissions for mailbox: $MailboxIdentity"    # Get Full Access permissions    $fullAccessPermissions = Get-MailboxPermission -Identity $MailboxIdentity | Where-Object {       ...

Get Group members & Owners from Azure

 Connect-AzureAD # Install AzureAD module if not already installed if (-not (Get-Module -Name AzureAD -ListAvailable)) {    Install-Module -Name AzureAD -Force -AllowClobber } # Import AzureAD module Import-Module -Name AzureAD # Connect to Azure AD Connect-AzureAD # Define the path to export the CSV file $exportPath = "C:\Temp\Groups_Details.csv" # Get all groups in Azure AD $groups = Get-AzureADGroup -All $true # Create an array to store group details $groupDetails = @() # Loop through each group foreach ($group in $groups) {    # Get group members    $members = Get-AzureADGroupMember -ObjectId $group.ObjectId | Select-Object -ExpandProperty DisplayName    # Get group owners    $owners = Get-AzureADGroupOwner -ObjectId $group.ObjectId | Select-Object -ExpandProperty DisplayName    # Determine group type    if ($group.SecurityEnabled) {        $groupType = "Security Group"    } else...