How to check if a Site Column is being used before deleting

Hi All,
Before deleting a SharePoint Online site column I would like to check to see if it is being used by any list or library. I know how to do this when the site is on
premise using a PowerShell script.
$web
= Get-SPWeb
http://”sitecollectionurl”
$column
= $web.Fields[“Column Display Name”]
$column.ListsFieldUsedIn()
but I am having problems doing it on a SharePoint Online site. I know how to connect to the site, but I can not find any information on getting the field details,
like above.
if ((Get-ModuleMicrosoft.Online.SharePoint.PowerShell).Count
-eq0) {
Import-Module
Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$username
= "[email protected]"
$url
= "https://mySite.sharepoint.com/sites/Dev"
Write-Host
"Connecting to SharePoint Online, URL = $url"
try
Connect-SPOService
-Url $url /
-credential $username
Write-Host "Successfully connected.."
-ForegroundColor Green
$web =
Get-SPOSite -Identity
https://mySite.sharepoint.com/sites/Team1
$column
= $web.Fields[“Column Display Name”]
$column.ListsFieldUsedIn()
=
$web.Fields[“Page Content”]
catch
Write-Error "Failed to connect to
$url - check the credentials and URL!"
$_
Write-Host
"Disconnecting from SharePoint Online, URL =
$url"
Disconnect-SPOService
Write-Host
"Successfully disconnected.."
-ForegroundColor Green
Does any know what I am doing wrong, or does anyone have a script examples.
Many thanks
Colin

Hi Colin,
Unfortunately the Get-SPOSite doesn't return a fully fledged SPWeb object like you're used to in On-Prem PowerShell.
The only way to get at particular objects like this is to use CSOM in PowerShell, however even then it doesn't return quite the same object that you see on prem. (In short, the method you want doesn't exist.. but I'll show you how to get there at least.)
You'll need the Microsoft.SharePoint.Client.dll installed (You can download the SharePoint 2013 Client SDK, just do a search for it.)
Once that's installed, then the following script will retrieve a single column which you can then run
$column | gm to see the available properties.
$siteCollectionURL = "https://<tenantname>.sharepoint.com/sites/etc"
$Credentials = Get-Credential -UserName "[email protected]" -Message "Enter the password for $AdminUser"
##Then we'll establish a ClientContext for CSOM.
$scContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteCollectionURL)
$SPOcredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credentials.UserName, $Credentials.Password)
$scContext.Credentials = $SPOcredentials
$web = $scContext.Web
$siteCols = $web.Fields
$column = $sitecols.GetByInternalNameOrTitle("ColumnInternalName")
$scContext.load($web)
$scContext.load($siteCols)
$scContext.Load($column)
$scContext.ExecuteQuery()
Once you run that, $column contains as much info as you can get about the column.
Paul.
Please ensure that you mark a question as Answered once you receive a satisfactory response. This helps people in future when searching and helps prevent the same questions being asked multiple times.

Similar Messages

  • How to check if an SQL profile is being used or not?

    Hi,
    We have a couple of SQL profiles and outlines in the database. There has been a couple of code changes and it is now difficult to keep track if an SQL profile or an Outline is still being used? Is there any way to find that?
    Thanks in advance

    Find the entry corresponding to the SQL statement you are reviewing in V$SQL. Look at OUTLINE_CATEGORY and SQL_PROFILE columns. NULL indicates that no Outline/Profile was used.

  • How to check if a database was not being used since past 90 days ?

    Team ,
    Thanks for your help in advance  !
    I'm looking out for some pointers to determine if a database was NOT BEING Used since last 90 days so that we can decommission them .
    Rajkumar Yelugu

    My personal method which I apply after mailing to all users and managers and after using methods fellow answeres have given
    Take database offline or in a single user mode and keep it like that for 15-20 days if someone is using it they would surely ping you or mail you. Please mail to all repective persons and app owners before taking it offline. As you said you want to decommission
    it so i assume server will be less utilized itself.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • How to check the resolution of a pdf file using Acrobat 9 pro?

    How to check the resolution of a pdf file using Acrobat 9 pro?

    PDF files don't have one resolution, but may have none or many different resolutions, one per image. You can check the maximum/minimum resoluion with preflight in Acrobat Pro, but not in Adobe Reader.

  • How to check status of a particular port by using netstat command?

    How to check status of a particular port by using netstat command?
    I want to check  port 443 in my server is open or not, is there any other way to check port via commandline?

    Hi,
    You can run the below command in an administrator command prompt on the server:
    netstat -ano|findstr ":443"
    -TP

  • I lost the ability to order and hide site columns if i use custom content type with a custom Create Form

    I have a team site collection and I want to add a new App of type Issue Tracking list. so I did the following:-
    From the site collection I created a new App of type issue tracking.
    Then from the site collection I created a new Content type named “CustomIssue” which has its parent as “Issue” content type.
    I went to the Issue tracking list and I changed the default content type from Issue , to the new “CustomeIssue” content type.
    I open the site collection using SP designer and I created a new Create form for my Issue tracking list based on the "CustomIssue" content type and I select to have the Create form as the default form when creating an item.
    Everything till this point worked well. But when I open the “customIssue” content type , and I re-order the columns and I hide some columns, this was not reflected inside the custom Create form …
    although when using the default content type and the default create form you can control the order of the fields and to specify if certain fields hold be hidden inside the Create form.. so can anyone advice on this please?

    Hi,
    According to your post, my understanding is that you lost the ability to order and hide site columns if i use custom content type with a custom Create Form.
    I try to reproduce the issue, the result is the same as yours.
    As a workaround, if I modify the custom content type form the site setting, and then change the NewForm as the default form, it will change the column orders.
    However, if I use the new created form as the default form, it will remain the original orders.
    I recommend that you modify the custom content type form the site setting, and then reset the NewForm as the default form.
    The result is as below:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support
    ok thanks for the explanation ,, but what if i want to change the order and hidde some fields in the future ,, do i have to chnage the defualt create form again ...

  • How do you set the setting in iPhoto to ask before deleting a picture?

    How do you set the setting in iPhoto to ask before deleting a picture?

    If you delete a picture, it sends it to iPhoto trash (left column), there you can permently delete using the empty trash with the icon in the upper right corner. It will come up with a warning if you want tp permently delete trash (photos).  It the iPhoto trash you can drag them back out, once you empty the trash, they are gone.
    You can also go to finder preferences>advanced, and unclick secyre empty trash, and make sure show warning before empting trash is clicked.

  • HT4211 how can you find out what kb are being used by what apps

    how can you find out what kb are being used by what apps there is always alot of kb being used even when I don't use my phone

    Go into settings , general, usage and it tells you what the apps use. If your refering to the memory storage of the apps.

  • How to know the full path which is being used in the dataconnection .

    How to know the full path which is being used in the dataconnection without going and looking into coding.
    I am new to crystal reports.
    Plz advice.Thanks in advance
    Jay

    This forum is dedicated to topics related to custom application development or deployment with Crystal Reports in .Net. This includes full versions of Crystal Reports as well as those versions of Crystal Reports bundled with Microsoft Visual Studio .Net.
    As you do not want to do any coding, this query is in the wrong forum. However, in most versions of Crystal Reports, you can look up the database connection information by simply opening the report in the CR designer. Then go to the database menu and select "Set Datasource Location..."
    Ludek

  • How to programmatically create a site column and a content type

    Hello,
    I'd like to create a site column (let's say a field text) and a content type, only  using c#  -i.e. I don't want to add new item/column and then xml. This code will be added to a FeatureActivated.My code is :
    public override void FeatureActivated(SPFeatureReceiverProperties properties) {SPWeb rootweb = (SPWeb) properties.Feature.Parent;
    SPFieldText field = new SPFieldText(SPfiledscollection???, "field1");
    if (field != null)
    rootweb.Fields.Add(field)
    rootweb.Update();
    }   SPContentType newContentType = new SPContentType(spcntenttypeId??, SPContentTypeCollection ??, "content1");
       rootweb.ContentTypes.Add(newContentType);
       rootweb.Update();
    Are there any sample codes out there? I've only found samples using xml - which has an irritating "feature"
    Thank you
    Christos

    Nice code and it helped me understand. Some small questions. I'm trying to make all the "data" for a (sub)web site.
    So, I think, my steps are:
    1. create site columns+content type
    2. create  list
    3. create a lookup site column that uses the list on <2>
    4. create content type that uses the site column on <3>
    5. Create the list for the content type on <4>
    My confusion is: should I use one feature for everything? Your code is using scope=site, so i need to "hardcode" the web site's name. I don't mind doing that , I just don't know how to use scopes in features for creating data.
    Thank you
    Christos

  • How can I update a Site Column with the content of an array with javascript CSOM?

    I'm relative new to Sharepoint 2013, I'm trying to update the content of a Site column with the content of an array, I can retrieve and visualize the content of my site column, the user is able to change and save the necessary part and the changes are
    saved into an array, now I have to update the content of the site column with the content of the array, but for some kind of reasons I can't accomplish that, any suggestion/example? This is my code so far to retrieve, visualize the site column and store the
    mofication into my array.
        <body>
                <select id="dropdown" name="dropdown" onchange="optSelect()">
                    <option value="EngineType_Cylinders">EngineType_Cylinders</option>
                    <option value="EngineType_EngineCycle">EngineType_EngineCycle</option>
                    <option value="EngineType_EngineFamily">EngineType_EngineFamily</option>
                    <option value="EngineType_Euro">EngineType_Euro</option>
                    <option value="EngineType_FamilyEvolution">EngineType_FamilyEvolution</option>
                    <option value="EngineType_GasEmissionLevel">EngineType_GasEmissionLevel</option>
                    <option value="EngineType_Power">EngineType_Power</option>
                    <option value="EngineType_PowerSupply">EngineType_PowerSupply</option>
                    <option value="EngineType_Use">EngineType_Use</option>
                </select><br />
                <textarea id="textareadisplay" rows="25" cols="23"></textarea><br />
                <input type ="button" value="Update values" onclick="addItemsToColumns()" />
            </body>
    My Javascript
        $(function () {
            SP.SOD.executeOrDelayUntilScriptLoaded(Function.createDelegate(this, function () {
               var select = document.getElementById('dropdown').value;
                console.log(select);
                getSiteColumns(select);
            }), 'SP.js');
        var fieldChoice;
        var choices;
        var addFields = [];
        var slc;
        var clientContext;
        function optSelect() {
            slc = document.getElementById('dropdown').value;
            getSiteColumns(slc);
        function getSiteColumns(selection) {
           clientContext = SP.ClientContext.get_current();
            if (clientContext != undefined && clientContext != null) {
                var web = clientContext.get_web();
                fieldChoice = clientContext.castTo(web.get_availableFields().getByTitle(selection), SP.FieldChoice);
                clientContext.load(this.fieldChoice);
                clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed));
        function OnLoadSuccess(sender, args) {
            choices = fieldChoice.get_choices();
            var textarea = document.getElementById("textareadisplay");
            textarea.value = choices.join("\n");
        function OnLoadFailed(sender, args) {
            alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
        function addItemsToColumns() {
            clientC = SP.ClientContext.get_current();
            var arrayForUpdate = $('#textareadisplay').val().split('\n');
            fieldChoice.set_item(, arrayForUpdate);
            fieldChoice.update();
            clientContext.executeQueryAsync(function () { }, function () { });
        function OnUpdateSuccess(sender, args) {
            var newchoices = fieldChoice.get_choices();
    My problem is on the function addItemsToColumns() please help! Thanks in advance.

    Let's look at your stylesheet -
    <style type="text/css">
    body {
    background-image: url(assets/images/Business%20Men%20In%20Reception%20Col.2.jpg);
    background-repeat: no-repeat;
    background-color: #003;
    margin-left:auto;
    margin-right:auto;
    position: relative;
    width: 960px;
    It's a good idea not to use spaces or any punctuation in your filenames when working for the web.
    #header {
    margin-left:auto;
    margin-right:auto;
    position: relative;
    width: 960px;
    #heading {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 36px;
    font-style: italic;
    font-variant: normal;
    margin-left:auto;
    margin-right:auto;
    There's no need to specify the default values (font-variant:normal) or to specify auto margins for any block element without an explicitly defined width. And wouldn't it make more sense to put the font style on the body tag, where it will inherit into the rest of the page than to restate it as you have done in the next rule?
    #bodytext {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 18px;
    line-height: 25px;
    font-variant: normal;
    width: 300px;
    #container {
    width: 960px;
    position: relative;
    margin-left:auto;
    margin-right:auto;
    .rightimg {
    float: right;
    margin-left: auto;
    padding-right: 40px;
    #heading #navbar ul li {
    padding: 30px;
    </style>
    Margin-left:auto can't work without knowing what the width of the element is....  Keep your CSS lean and targeted - it will help you to debug your layouts.

  • How to check if the site studio site is in contribution mode?

    Is there a function or global variable using which we can check if the site studio site is in contribution mode?
    Regards,
    Pratap

    Yes, please look into Site Studio Technical refrence guide.
    I think variable name is 'SSContributor'
    regards,
    deepak
    Edited by: r.dipk on Oct 1, 2010 2:09 AM

  • Creating a new Column for my list Versus adding it from existing site columns, when to use each approach

    I have created a new issue tracking list inside SharePoint 2013 team site. And it comes with predefined columns, some of them are useful while the other are not . Can anyone help me in figuring out the following:-
    The list come with a field named “Assigned To”, while in my case I want a column named “Approver”. So what is preferred , to re-name the “Assumed to ”column to “Approver”, or create new field name “Approver”.?.
    If I rename an existing column, could this be overridden in any future updates for my SharePoint server?
    Now we want to add a column named “Office location”.so I need to create a new field for this. But seems there are two ways to do so either to add a new Site Column at the site level and then assign it to the list as follow :- 
    , or to directly adding a column to the list, even if it is not available in the site columns , as follow:-
    So what are the differences between the two approaches ? .if I am not wrong defining a site column will allow me to re-use it in another list , but defining the column at the list level, will allow me to add a column even if it is already defined as site
    column.
    So can anyone advice on my three questions please? Thanks

    1) 'Assigned to' has a different meaning then 'Approver' , it will be better if you create a new field for 'Approver'. Assigned to is a Site Column which has managed property for search, so it will be confusing type of data it will return from search in
    future. 
    2) Any rename of fields should not / and will not get modified in SharePoint updates. So, you can rename is without any issue since the internal name will remain the same. But its always better to create your own custom column for business use.
    3) Creating a site column or not depends upon your need, If you create a Site Column - in whole site collection you will be able to add this field in any list - It will be crawled, SharePoint will automatically provide managed property for site column and
    you will be able to get this value via search. These things will not be present in list column, you will need to do specific settings in case its required.
    If these things are needed then you can go for Site Column, usually its good to create a Site Column and use it.
    For Site Columns you can check following links 
    Introduction to Columns
    From site column to managed property - What's up with that?
    Create a site column
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.
    thanks a lot for your reply it is really helpful. so as i understand that using site columns will be better in most cases, and there is not any specific reason for not using it? is this right ?
    Second question, do u mean that if i have a list column named "Serial number", then this column will not be searched ? For example if i have serial number such as "12345" and i try searching this text "12345" i will not get
    the item in my search ?
    Thanks

  • How to check which is th best method to use in LSMw and the file

    Hi all,
    I am new to LSMW,
    Can know me when i get the file , how to check the which is the Best method ( Batch input, Direct input,BAPI, IDOC)  have to use in LSMW .
    How to check the input file is completely filled and how to check whether it is correct and also how to Prevalidation check has to be done fior the file before uploading.
    Can you provide any documents LSMW also Apprecited.
    Regards,
    Madhavi

    Hi Madhavi,
    To check Correctness & completeness of the file:
    1. The input file structure should be same as source structure what you defined whicle creating LSMW.
    2. Check the following steps to assure the field mapping is done correctly.
    a) Maintain field mapping & conversion rule
    b) Check 'Display Read data'
    c) Check ' Display Converted data''
    Please note LSMW is a tool, which will simply upload the data whatever you are providing. So you need to be careful while making your file and validate it outside SAP ( before upload start)
    Pradeep D

  • How to analyse the number of open cursors being used by each program?

    Hi,
    I am getting an error "ORA:1000 Maximum Open Cursors Exceeded" in my
    application. I want to analyse and monitor that how many cursors are
    being used  by each program running in a particular session. I have
    already set the Open Cursors Count double of the recommended for my
    application, yet I am getting this error.
    Is there any tool to analyse and monitor the number of cursors being
    used by each DB call?
    I have installed SAP NW 7.0 and Using Oracle 10g as DB.
    Your immediate help will be greatly appreciated.
    Best Regards,
    Smriti.

    You can list the open cursors per session and check which one uses the most with sqlplus:
    SQL> select a.value, s.username, s.sid, s.serial#
    from v$sesstat a, v$statname b, v$session s
    where a.statistic# = b.statistic#  and s.sid=a.sid
    and b.name = 'opened cursors current';
    Values over 300 are unusual.
    It is quite possible, that you see several workprocesses using a lot, because workprocesses are kind of shared sessions.
    Cheers Michael
    Edit: ah, our posts crossed, obviously there is no workprocess in the java world

Maybe you are looking for