Hi,
There was a requirement of deleting list column using PnP Powershell
For this, I have written the PnP PowerShell script to take column name from xml and web urls from csv as below.
Please make sure to have all the files are in the same folder
//RemoveListColumnInputs.xml
<Inputs>
<ConnectSPOnline UserName="username" Password="password" RemoveColumnName="Phase"></ ConnectSPOnline>
</Inputs>
//RemoveListsColumnInputs.csv
SiteCollectionUrl,WebUrl, ListTitle,ListUrl, ContentTypeName,ContentGroup
sitecollectionurl,weburl, listrelativeurl, contenttypename, contenttypegroup
//RemoveListsColumnScript.ps1
############################## ############################## ## Logging ############################## ###########
$date= Get-Date -format MMddyyyyHHmmss
start-transcript -path .\Log_$date.doc
############################## ##################### Get input parameters from XML ############################## #
# Get content from XML file
[xml]$xmlData = Get-Content ".\RemoveListColumnInputs.xml"
# ConnectSPOnline node
[System.Xml.XmlElement]$ connectSPOnline = $xmlData.Inputs. ConnectSPOnline
$userName=$connectSPOnline. UserName
$password=$connectSPOnline. Password
$removecolumnname=$ connectSPOnline. RemoveColumnName
$weburlinputs= Import-CSV .\RemoveListsColumnInputs.csv
function RemoveListsColumn()
{
try
{
}
catch
{
write-host $_.Exception.Message;
}
}
############################## ############################## ##### Initiate ############################## #######
function Initiate()
{
write-host -ForegroundColor Green "Initiating the script.................. "
RemoveListsColumn
Disconnect-PnPOnline
write-host -ForegroundColor Green "Completed!!!!"
}
############################## ############################## ############################## #######################
Initiate
Stop-Transcript
Thanks & Regards,
Naga Sudheer M
No comments:
Post a Comment