Last active
April 20, 2023 15:48
-
-
Save mirontoli/fc1149a50e6621791a6b6946f99609af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "This will show the Path column to your view" | |
Write-Host "To do, please copy the edit view you want to update." | |
Write-Host "Here is how it can look: " | |
Write-Host "https://contoso.sharepoint.com/sites/site/_layouts/15/ViewEdit.aspx?View=%7B6987F436%2DA89E%2D4F96%2DA791%2D02D6988EE09B%7D&List=%7BFE190210%2D2EA0%2D4A69%2DB3F4%2D9CE412F154F1%7D&Source=%2Fsites%2FSE%2D000858%2FUE%2FForms%2FPlatt%20vy%2Easpx" | |
$link = Read-Host "Please paste the edit view" | |
Write-Host "Great, this is an early version and it has no validation, neither checks it whether the Path is already shown or not" | |
Write-Host "Feel free to reach out to @mirontoli to give feedback or contribute" | |
$site = $link.Split("/_layouts/15")[0] | |
Connect-PnPOnline $site -Interactive | |
$params = $link.Split("?")[1] | |
$decoded_params = [System.Web.HttpUtility]::UrlDecode($params) | |
$pairs = @{} | |
$decoded_params.Split("&") | ForEach-Object { | |
$a = $_.Split("=") | |
$pairs.Add($a[0], $a[1]) | |
} | |
$viewId = $pairs["View"] | |
$listId = $pairs["List"] | |
$view = Get-PnPview -List $listId -Identity $viewId | |
$viewFields = @() | |
$view.ViewFields | ForEach-Object { | |
$viewFields += $_ | |
} | |
$viewFields += "Path" | |
Set-PnPView -List $listId -Identity $viewId -Fields $viewFields |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment