Skip to main content

Posts

Showing posts with the label PowerShell

PowerShell - CSOM code to get SharePoint Online Sites Permission Report

#sharepoint online powershell permissions report Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"          $AdminSiteURL="https://m365x067565-admin.sharepoint.com/"   #Connect to SharePoint Online Admin Write-host "Connecting to Admin Center..." -f Yellow Connect-SPOService -url $AdminSiteURL -Credential (Get-Credential) #Get each site collection and users $Sites = Get-SPOSite -Limit ALL Foreach($Site in $Sites) { $SiteURL=$Site.Url   } #To call a non-generic method Load Function Invoke-LoadMethod() {     param(             [Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"),             [string]$PropertyName       ...

Powershell Script to get Report Group-enabled SharePoint sites Get all sites with the Office 365 Group template

<# .NOTES      =========================================================================================================================================   Author: Kamal Pandey         DESCRIPTION : Report Group-enabled SharePoint sites Get all sites with the Office 365 Group template  #> $siteUrl = Read-Host  "Enter SharePoint Admin Center Url" try {     Set-ExecutionPolicy RemoteSigned     $Cred = Get-Credential     $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection     Import-Module (Import-PSSession $Session -Allowclobber) -Global      Connect-MsolService -Credential $Cred     Connect-SPOService -Url $siteUrl -credential $Cred } catch {     write-host "Failed to connect to SharePoint online site at " $siteUrl -ForegroundColor R...

PS script to generate reports of the guest users last login information from the Office 365 tenant.

 Dear All,  As you know office 365/ SharePoint has a profound impact on the collaboration space where we collaborate with external users or business partner to work together sometimes we need to audit our platform such as how many guest users present on our tenant, I am posting a script that helps you to generate a report out of it.  The script is below you may copy create a PS file to run from your machine. if need any help please reach out to me at kamal_pandey@outlook.com I would be very happy to help.  <# .NOTES  DESCRIPTION: This script will generate guest users' last login information from the Office 365  tenant.  #> #Import SharePoint Online Management Shell Import-Module Microsoft.Online.Sharepoint.PowerShell -DisableNameChecking   #Config Parameters $AdminSiteURL="https://cpsgpartners-admin.sharepoint.com" $ReportOutput ="C:\Temp\ExternalUsersRpt.csv"   #Get Credentials to connect $Cred = Get-Credential   #Connect to Share...

PowerShell CSOM code to export term set from SharePoint online

 #Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"     #Variables for Processing $AdminURL = "https://abc-admin.sharepoint.com" $ReportOutput="C:\Temp\TermStoreData.csv"   Try {     #Get Credentials to connect     $Cred = Get-Credential     $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)     Connect-SPOService -Url https://mmibi-admin.sharepoint.com #-Credential $Creds      Connect-MsolService #-Credential $Creds       #Setup the context     $Ctx = N...

Create multiple SharePoint site collections from .csv file

 <# .NOTES  DESCRIPTION : Using the Script SharePoint admin will be able to Create Multiple Site Collections in Bulk from a CSV File using PowerShell  #> #Config Parameters $TenantUrl = Read-Host  "Enter SharePoint tenant admin URL" $CSVPath = "C:\Temp\SiteCollections.csv" #Connect to Tenant Connect-PnPOnline -url $TenantUrl -Credentials (Get-Credential) #or -UseWebLogin for MFA   Try {     #Get Site Collections to create from a CSV file     $SiteCollections = Import-Csv -Path $CSVPath       #Loop through csv and create site collections from each row     ForEach ($Site in $SiteCollections)     {         #Get Parameters from CSV                  $Title = $Site.Title         $Url = $Site.Url         $Owner =$Site.Owner         $Template = $Site.Template       ...

Powershell Script to get all SharePoint wsp solutions

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $dirName = "C:\WSP" if (!(Test-Path -path $dirName)) { New-Item $dirName -type directory } Write-Host Exporting solutions to $dirName foreach ($solution in Get-SPSolution) {     $id = $Solution.SolutionID     $title = $Solution.Name     $filename = $Solution.SolutionFile.Name     Write-Host "Exporting ‘$title’ to …\$filename" -nonewline     try {         $solution.SolutionFile.SaveAs("$dirName\$filename")         Write-Host " – done" -foreground green     }     catch     {         Write-Host " – error : $_" -foreground red     } } Note: If need any help please reach out to me at kamal_pandey@outlook.com.  I would be very happy to help. 

Apply Branding on SharePoint 2019 without updating master page

Hello Everyone, I am pleased to inform you that, using blog code you will be able to apply branding on your SharePoint 2019 SharePoint Site without updating master page and layout page. Using this code you don’t have update or modify anything on you site just upload this code file to Style library and set css link to your site, supper easy.  Download this copy CSS and create css file. Upload css file to your SharePoint style library Go to Site setting > Look and Feel > Master page >click on Alternate CSS URL> select “Specify a CSS file to be used by this site and all sites that inherit from it:” > click on Browse > select your css file > Click OK You are done.  Enjoy  SharePointing  ********************************CODE******************************************** /* Left navigation(begin) */ .ms-core-listMenu-verticalBox UL.root > LI > .menu-item{     background-color:#f3f3f3; ...