User Profile
AHun78
Copper Contributor
Joined 4 years ago
User Widgets
Recent Discussions
Re: PnP PowerShell Check if items exists in List
Thanks for the reply... 🙂 I tried doing that but it doesn't resolve the issue... The item always get's created as a new item rather than updating existing item # Connect to Microsoft 365 Connect-PnPOnline -Url "https://<tenant>.sharepoint.com" -Interactive # Get all sites $sites = Get-PnPTenantSite -Template "GROUP#0" $SiteDirectoryURL = “https://<tenant>.sharepoint.com/sites/SPOSiteProvisioning” Connect-PnPOnline -Url $SiteDirectoryURL -Interactive $ListName = “Site Directory” # Site Directory list name foreach ($site in $sites) { # Connect to the site $siteConnect = Connect-PnPOnline -Url $site.Url -Interactive -ReturnConnection # Get the root web with "created" property $Web = Get-PnPWeb -Includes Created -Connection $siteConnect # Get site details if ($site.Template -like "GROUP*") { # Get Group Owners $GroupOwners = (Get-PnPMicrosoft365GroupOwners -Identity $site.GroupId.Guid -Connection $siteConnect | Select-Object -ExpandProperty Email) -join "; " } else { $GroupOwners = $site.Owner } # Prepare item values $itemValue = @{ "GUID" = $site.GroupId; "Title" = $site.Title; "URL" = $site.Url; "SiteDescription" = $site.Description; "SiteTemplate" = $site.Template; "SiteOwner" = $GroupOwners; "PrivacySetting" = $site.Visibility; # Privacy setting "ExternalSharing" = $site.SharingCapability; # External sharing capability "CreatedOn" = $web.Created.ToString("dd/MM/yyyy HH:mm:ss") # Site creation date } # Check if an item with the same URL exists in the list $listItem = Get-PnPListItem -List $ListName -Query "<View><Query><Where><Eq><FieldRef Name='URL' /><Value Type='Text'>${site.Url}</Value></Eq></Where></Query></View>" # If the item exists, update the other fields if ($listItem) { Set-PnPListItem -List $ListName -Identity $listItem -Values $itemValue Write-Host "Updated item with title: $($itemValue.Title)" -ForegroundColor Yellow } # If the item does not exist, create a new item else { Add-PnPListItem -List $ListName -Values $itemValue Write-Host "Created new item with title: $($itemValue.Title)" -ForegroundColor Green } }6.1KViews0likes1CommentPnP PowerShell Check if items exists in List
Hi All, I have the following script that checks to see if a Site exists in a SPO list and either updates or adds the item to the list. For some reason it never updates the list items... It just keeps adding new list item entries? I am using the Site.URL as my unique ID # Add or update item in the list $listItem = Get-PnPListItem -List $ListName -Query "<View><Query><Where><Eq><FieldRef Name='URL' Type='Text'/><Value Type='Text'>${site.Url}</Value></Eq></Where></Query></View>" if ($null -ne $listItem) { # Update item Set-PnPListItem -List $ListName -Identity $listItem.Id -Values $itemValue Write-Host "Updated site: $Title" -ForegroundColor Yellow } else { # Add item Add-PnPListItem -List $ListName -Values $itemValue Write-Host "Added site: $Title" -ForegroundColor Green } }7.1KViews0likes3CommentsAzure Function - PnP.Powershell stable version?
Hi All, I am hoping someone can assist with an Azure Function I am using to provision sites using PnP.PowerShell. I am having a huge issue trying to find a stable build of PnP.Powersion 2.xxx that runs on Powershell 7.0. Does anyone have any experience with this that can perhaps point me in the right direction?372Views0likes0CommentsAutomate update of Office 365 Targeted Release via Powershell
Hi All, I was wondering if anyone new if it is possible to update a users releasetrack via Powershell? We have a Dynamic Office 365 group that contains a set of users we would like to provide access to the Targeted Release track within M365 Organisation settings. I can see it is possible to use Get-MSOLUser to return the releasetrack property for a user. Get-MsolUser | Where-Object {$_.ReleaseTrack -eq "StagedRolloutOne"} | FL DispalyName, ReleaseTrack I cannot see a property within Set-MSOLUser to manually set the ReleaseTrack property. Is this possible and if so how do I achieve this? It would be very nice if the ReleaseTrack supported groups and not just users. 🙂1.3KViews0likes0CommentsSite Design Not Appearing when provisioning new site?
Hi All, I have recently created a new Site Script and associated it to a Site Design on my Dev Tenant and for some reason I cannot see the site design when I go to provision the site from https://<tenant>.sharepoint.com/_layouts/15/sharepoint.aspx? It has been 15 hours since I created the site design, does anyone know why this doesn't appear? Also related to this... How do you hide or delete the Microsoft Site Templates now available to users from the Settings > Apply a Site Template menu item on an existing site? I only want to show the templates available "From my organization". Thanks for any advise! 🙂507Views0likes0Comments
Recent Blog Articles
No content to show