Configure site auditing in sharepoint online using powershell or Client object model
Is the any way to configure site collection audit settings in sharepoint online programmatically or using powershell.
Hi Bhism,
The solution given in the article is for sharepoint 2010, i want to enable site auditing in Sharepoint 2013.
When i tried using that for sharepoint 2013 making he neccessary changes required for sharepoint 2013 i got an error :
Unable to find type [Microsoft.SharePoint.SPAuditMaskType]: make sure that the
assembly containing this type is loaded.
I think the assembly is for SP2010, is there anything like that for SP2013
Thanks in Advance.
Similar Messages
-
Migrating on premise site collections to SharePoint online using powershell
Hi folks,
Intention:-migrating on premise site collection to SharePoint online.
Is there any power-shell script or list availabe products.
Please give idea and let me know that script.
Thanks,Hi Jio333,
This issue has been discussed in Sharepoint forum:
SharePoint 2013 - Migrate
from SharePoint 2013 On Premise to SharePoint 2013 Cloud
To complete this kind of Migration task, we usually use 3rd party tools because they have some complex migration requirements.
If there is anything else regarding this issue, please feel free to post back.
If you have any feedback on our support, please click here.
Best Regards,
Anna Wang
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Hello All -
I am trying to add a user to a SharePoint site using PowerShell like below:-
New-SPUser -UserAlias MyDomain\jan20a -Web http://SPServer/sites/MySite
If I execute the above more than once, SharePoint does not throw that user already exists or something. This is not the same behavior in AD/Exchange PowerShell cmdlets.
Also, even the client object model behaves the same way.
Another interesting thing I noticed, I tried to remove a user from group in which the user was not part of it at all and still no error..!!
Looks like SharePoint does not care of invalid input and just ignores it.
Can anyone please confirm this and also the reason behind it ?It's not really invalid input, since the user exists and that is how SharePoint behaves (will behave same way in browser). Try to input a user that and misspell the name, e.g. say you didn't have a MyDomain\Jan21a, then try to use same script above,
only with invalid data. It will bark at you. Or try using a web that it cannot find, one that does not exist. You'll get what I like to call, the red badge of courage if you enter invalid data.
you can test that sharepoint will let you enter a user twice in the browser, and nothing bad comes from it. Powershell is just unable to tell that the user was not in the site, when you removed it the second time.
Hope that confirms it, if it does please mark this reply accordingly. thanks
Stacy Simpkins | MCSE SharePoint | www.sharepointpapa.com -
Having trouble uploading sub folders to Sharepoint online using PowerShell
Hi there,
I have been attempting to upload folders and files to a document library on Sharepoint Online. I can upload the top-level folder and the files in that folder but when i comes to the sub folders i get this message:
New-Object : Exception calling ".ctor" with "2" argument(s): "Access to the path
'C:\FilePath\TestFolder\TestFolder1' is denied."
At C:\FilePath\ImportFiles_Test1.ps1:54 char:29
+ $FileStream = New-Object IO.FileStream($File.FullName,[System.IO.F ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
I'm running as an Administrator so I have full access to the folders
here's my code so far
#Specify tenant admin and site URL
$User = "[email protected]"
$SiteURL = "https://company.sharepoint.com/sites/TestSite"
$Folder = "C:\Users\user\Documents\SharepointTestFolder"
$DocLibName = "Admin"
#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
#Bind to site collection
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
$Context.Credentials = $Creds
#Retrieve list
$List = $Context.Web.Lists.GetByTitle($DocLibName)
$Context.Load($List)
$Context.ExecuteQuery()
Function ImportFiles()
#Get name of folder
$NewFolder = Split-Path $Folder -Leaf
#upload folder to sharepoint
$UploadFolder = $List.RootFolder.Folders.Add($NewFolder) #this may not upload folders within folders.
$Context.Load($UploadFolder)
$Context.ExecuteQuery()
$FilesInFolder = Get-ChildItem $Folder | ? {$_.PsIsContainer -eq $False}
#Loop Through Folder
Foreach ($File in (dir $Folder))
#If file
If($File)
#Upload file to Sharepoint
$FileStream = New-Object IO.FileStream($File.FullName,[System.IO.FileMode]::Open)
$FileCreationInfo = New-Object Microsoft.SharePoint.Client.FileCreationInformation
$FileCreationInfo.Overwrite = $true
$FileCreationInfo.ContentStream = $FileStream
$FileCreationInfo.URL = $File
$Upload = $UploadFolder.Files.Add($FileCreationInfo)
$Context.Load($Upload)
$Context.ExecuteQuery()
Else
recurse ImportFiles
ImportFiles
If anyone could help me I'd be so grateful!!
Thanks!!
Dearbhla BradleyThe exception is pretty clear. for some reason the script is not able to open the folder TestFolder1 on the local hard drive.
I noticed in the script you have specified the $Folder variable to be "C:\Users\user\Documents\SharepointTestFolder" while the exception is for "C:\FilePath\TestFolder\TestFolder1"
Will you please help me understand this difference?
Also, sorry I'm not familiar with the "recurse" calling method. I'm suspecting you're telling it to call the ImportFiles() function again, though if this is the case it looks to me that it's reusing the same $Folder variable that was defined at the start,
rather than using the folder object you have just identified.
Jason Warren
@jaspnwarren
jasonwarren.ca
habaneroconsulting.com/Insights -
How can I get a list of OOB Site from a SharePoint WebApplication using Powershell Script
Hi,
Could anybody help on this?
Thanks,
Srabon
srabonYou can include the WebTemplate parameter in the select, from that you will get the template ID for all sites.
I am sure you know the custom template IDs then just filter / use if else to get the desired results.
check this blog, track inventory session.
http://sharepointpromag.com/sharepoint-2010/inventorying-sharepoint-using-powershell
Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog -
Download RSS feed as xml file from Sharepoint Online using PowerShell
Hello
Our company sharepoint (Office 365) contains also several RSS feeds.
How it is possible to download xml file out of this feed (website) using PowerShell?
I can authenticate with sharepoint using CSOM but do not what to do next.
As service user is not administrator I cannot use "SPOService".
This script works OK for standard website, but not for Sharepoint.
$doc = New-Object System.Xml.XmlDocument
$doc.Load("http://www.{CompanySite}.com/feed/")
$doc.save("C:\temp\feed.xml")
I am getting this error when using for company Sharepoint:
"The remote server returned an error: (403) Forbidden."
Thanks for your time considering this question.
JozinHi Scott,
thanks for advice.
Combination of WebClient and Sharepoint Credentials is working OK:
$client = New-Object System.Net.WebClient
$client.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User, $SecurePassword)
$client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
$client.DownloadFile($SiteURL, $file) -
Fetching file size using CAML query in Javascript client object model
Hi,
I am using the Javascript client object model to retrieve contents of a document library.
I have a document library, which contains a folder "Folder1" . "Folder1" has a zip file. I would like to get the file size of the zip file.
I have tried the below code, but not sure, how to fetch the file size.
function FetchImage() {
var clientcontext = new SP.ClientContext.get_current();
var oweb = clientcontext.get_web();
var olibrary = oweb.get_lists().getByTitle(DocLibrary);
var query = new SP.CamlQuery();
query.set_folderServerRelativeUrl("Lists/DocLibrary/folder1/");
folder = olibrary.getItems(query);
clientcontext.load(folder, 'Include(Title,ContentType, FileLeafRef,FileDirRef,File)');
clientcontext.executeQueryAsync(Function.createDelegate(this, this.RenderDataOnSuccess), Function.createDelegate(this, this.RenderDataOnFailure));
function RenderDataOnSuccess() {
var ListEnumerator = this.folder.getEnumerator();
while (ListEnumerator.moveNext()) {
var currentItem = ListEnumerator.get_current();
if (_contentType.get_name() != "Folder") {
var File = currentItem.get_file();
if (File != null) {
// Fetch file size
How to fetch the file size?
Thanks<script>
function getSize()
var myFSO = new ActiveXObject("Scripting.FileSystemObject");
var filepath = document.upload.file.value;
var thefile = myFSO.getFile(filepath);
var size = thefile.size;
alert(size + " bytes");
</script>
http://social.msdn.microsoft.com/Forums/en-US/e5d2ff3d-01c7-4cc0-a081-29a4dfbb0fad/getting-the-sharepoint-list-attachment-size-using-javascript?forum=sharepointcustomizationlegacy -
Hi,
I am using the Javascript Client object model.
I have a custom list and a custom document library.
Custom list contains 2 columns - dlName , dlValue
The document library contains 2 folders - "folder1" , "folder2" and contains some images.
The image name starts with the "dlValue" available in the custom list
I am using a visual webpart and using javascript client object model.
I am trying to achieve the below functionality:
1) Load a dropdown with the custom list.
2) set the image based on the value in dropdown.
I have achieved the first option, I have set the dropdown, but not sure how to query the folder and set the image.
Below is the code i have used so far:
//In Visual webpart
<select id="ddlTest" >
</select>
<br/>
<div id="PreviewLayer">
<img id="imgPlaceHolder" runat="server" alt="Image" title="imgPlaceHolder" src=" " />
</div>
// In Javascript file
function RenderHtmlOnSuccess() {
var ddlTest = this.document.getElementById("ddlTest");
ddlTest.options.length = 0;
var enumerator = this.customListItems.getEnumerator();
while (enumerator.moveNext()) {
var currentItem = enumerator.get_current();
var dropdownValue = currentItem.get_item("dlValue");
ddlTest.options[ddlTest.options.length] = new Option(currentItem.get_item("dlName"), dropdownValue);
setImage(dropdownValue); // Not sure how to query the folder and set the image based on value.
// Also if dropdown value is changed, corresponding image should be shown
How to query the folder and based on dropdown value, show the image? Also, how to handle the dropdown value change?
ThanksHi,
Here are two links for your reference:
Example of how to Get Files from a Folder using Ecmascript \ Javascript client object model in SharePoint 2010
http://sharepointmantra.wordpress.com/2013/10/19/example-of-how-to-get-files-from-a-folder-using-ecmascript-javascript-client-object-model-in-sharepoint-2010/
SP2010 JSOM Client Object Model: How to get all documents in libraries including all folders recursively
http://sharepoint.stackexchange.com/questions/70185/sp2010-jsom-client-object-model-how-to-get-all-documents-in-libraries-including
In SharePoint 2013, we can also use REST API to achieve it.
http://msdn.microsoft.com/en-us/magazine/dn198245.aspx
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support -
Get current item id using JavaScript Client Object Model
I have a client query that query SharePoint list Items. Lets say it is a document library. I need to get the list item id of each.
I can query the Title of the document using this syntax.
ctx.CurrentItem['Title']
But when I try
ctx.CurrentItem['ID']
for list item ID, it does not give a value. How can I solve this?Hi Malin,
If you're using the JavaScript Client Object Model, try using the SPListItem.get_item('key') method as in the example below:
<script>
ExecuteOrDelayUntilScriptLoaded(function(){
var arrIds = [];
var clientContext = new SP.ClientContext();
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query></Query></View>');
var items = clientContext.get_web().get_lists().getByTitle("Your List Title Here").getItems(camlQuery);
clientContext.load(items);
clientContext.executeQueryAsync(Function.createDelegate(this,function(){
var itemEnumerator = items.getEnumerator();
while(itemEnumerator.moveNext()){
var itemId = itemEnumerator.get_current().get_item('ID');
arrIds.push(itemId);
alert(arrIds);
}), Function.createDelegate(this, function(){
alert("something went wrong");
},"SP.js");
</script> -
Assign Group permission to list item using client object model
Hi,
I am trying to add the list item and assign the permission to the list item by using SP 2010 client object model. The problem which i am facing that when i assign the group as a permission to the item, by automatically the limited access permission
is added to the group. Please find the steps which i have followed,
Step-1: Break role inheritance.
foreach (var item in _listItemCollection)
if (item["FileLeafRef"].ToString().ToLower() == "xxx")
item.BreakRoleInheritance(true, false);
_clientContext.Load(item.RoleAssignments);
_folderItem = item;
_clientContext.ExecuteQuery();
Step 2: Remove all permissions of the list item.
foreach (var assignment in _folderItem.RoleAssignments)
assignment.RoleDefinitionBindings.RemoveAll();
assignment.Update();
_clientContext.ExecuteQuery();
Step 3:
Add Group as a permission to the list item.
var role = _web.RoleDefinitions.GetByType(RoleType.Contributor);
var collRdb = new RoleDefinitionBindingCollection(_clientContext) { role };
Principal principal = _grp;
_folderItem.RoleAssignments.Add(principal, collRdb);
_folderItem.Update();
_clientContext.ExecuteQuery();
After adding the group successfully to the list item, i checked the group permission and it contains the value as "Contribute,Limited Access" to the site level and "Contribute" to the list item. Please guide me how to avoid to create Contribute,Limited
Access role.
BalajiHi Dmitry,
When I create the group and assign contribute permission, the group has the permission at the site level(to see the permission, click group and click view Group Permission). I have added the list item and break the role inheritance permission
and given the unique permission by providing group as a permission to the list item. After providing the permission, the group permission at the site level changed to "Contribute, Limited Access". I dont know how contribute permission changed to contribute,
limited access.
I found the workaround to fix this issue. I created the group and create the folder in the shared document library by using client object model. Due to facing some issue by providing the permission using client object model, i have created the event receiver
to the document library and using server object model, i can able to assign the approprate group permission.
Balaji -
Is it possible to use microsoft.sharepoint.client.search.analytics to report the monthly hit count of site collections on SharePoint Online.
GetHitCountForDay()
GetHitCountForMonth()
If yes, how can this be called and executed successfully from a Console application using the Client Object Model.
Reference:
http://download.microsoft.com/download/8/5/8/858F2155-D48D-4C68-9205-29460FD7698F/[MS-SPACSOM].pdf
http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/54310f5f-e8a3-469e-86a3-63781b91670d/how-to-get-analytics-reports-programmatically-in-sharepoint-2013?forum=sharepointdevelopmentCheck if this works in 2013 as well.
http://blogs.technet.com/b/sharepointdevelopersupport/archive/2012/10/04/how-to-retrieve-web-analytics-report-data-using-api.aspx
This post is my own opinion and does not necessarily reflect the opinion or view of Slalom. -
Building Site Collections in SharePoint Online
Hello all,
Please forgive me for this very basic question, but I was not able to find the info online.
Background info: I have a great deal of experience with SharePoint administration on-prem but not much experience with SharePoint Online. My current organization has O365 and wants to build a collaboration environment and an Intranet. I understand the information
architecture practices that would have been common for this for an on-prem environment, and I understand that those have changed with 2013 and SharePoint Online due to the new practice of organizing everything under one web app.
Between reading some articles and using my experience with on-prem, I am trying to design an organized information architecture that will facilitate both environments and the permissions structures they require. My tentative plan was to build one site collection
for the Intranet under https://mycompany.sharepoint.com/sites (under which subsites would be built for various Intranet divisions), and then a number of individual site collections for the collaboration environment under https://mycompany.sharepoint.com/teams
(/hr, /finance, etc., so that content owners and users could work in their own site collection without affecting a site collection belonging to someone else).
This is the article that initially caused me to believe that this is possible/a good idea: http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2014/09/01/sharepoint-online-information-architecture-considerations.aspx.
"For [managed paths] you get the root, /search (explicit managed path), /sites (wildcard managed path), and /teams (wildcard managed path)."
However this article leads me to believe that I will not be allowed to create any site collections at all, only subsites: https://support.office.com/en-us/article/Plan-sites-and-manage-users-8e568d8d-3d65-42c4-99fa-f7285c9db842.
"You cannot create additional site collections in SharePoint Online for Office 365 for Small Business."
I understand the answer to this may depend on what version of O365 we have, and I am working to find that out.
My understanding is that I cannot be made a SharePoint Online administrator without being a global O365 administrator: http://blogs.technet.com/b/lystavlen/archive/2012/06/14/understanding-the-administrator-role-in-sharepoint-online.aspx.
"You cannot separate the roles of Office 365 global administrator and SharePoint Online Administrator."
Thus, I don't currently have the level of access I need to browse around the administration area and find the answers to my questions that way. When the time comes, I will likely be given temporary access or will be working with an O365 global administrator
to build.
Main question: Will I be allowed to build site collections under managed paths?
Larger question: How are others managing the information architecture for an Intranet and a Collaboration environment in SharePoint Online, especially if the answer to the prior question is no?
Thanks in advance for any insight you can offer.
ShaeHi,
According to the error message, the Microsoft.Online.SharePoint.Client.Tenant.dll seems not been loaded.
You can find it in the path below:
C:\Program Files\SharePoint Client Components\Assemblies
A code snippet about how to retrieve a list of site collections in a tenant for your reference:
const string username = "[email protected]";
const string password = "password";
const string tenantAdminUrl = "https://yourdomain-admin.sharepoint.com/";
var securedPassword = new SecureString();
foreach (var c in password.ToCharArray()) securedPassword.AppendChar(c);
var credentials = new SharePointOnlineCredentials(username, securedPassword);
using (var context = new ClientContext(tenantAdminUrl))
context.Credentials = credentials;
var tenant = new Tenant(context);
SPOSitePropertiesEnumerable spp = tenant.GetSiteProperties(0, true);
context.Load(spp);
context.ExecuteQuery();
foreach (SiteProperties sp in spp)
Console.WriteLine(sp.Title);
Best regards,
Patrick
Patrick Liang
TechNet Community Support -
Backup - Restore process of a Site Collection in SharePoint Online
Hi, I have a couple of questions.
1) What do I have to do to get a backup-restore of a site collection in SharePoint Online?
2) Can I myself perform a backup-restore or just backup a site collection without using any 3rd party tool?
Any inputs on these will be helpful. Thanks in advance!Hi,
what you can instead of backup and restore site is to save it as template, check this thread
http://community.office365.com/en-us/f/154/t/203139.aspx
Kind Regards,
John Naguib
Technical Consultant/Architect
MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation
Please remember to mark your question as answered if this solves your problem -
Is there any REST API to get all the Site and site Collections from Sharepoint Online
Hi,
I have one SharePoint Online tenant. We are using REST API to integrate SharePoint to our internal System.
For my use case I need to get all the SharePoint sites ans Sitecollections. From each SiteCollection I need all the subsites under this.
I have used below REST Query
http://<Base site url>/_api/web
This doesn't give me all the Site collections
Could any one please give me some way to get all the Site collections and sites from my sharepoint tenant through REST API.
Thanks,Hi Abhiram,
There seems no such endpoint in SharePoint REST API can retrieve a list of site collections in a SharePoint Online tenant:
https://msdn.microsoft.com/en-us/library/office/jj860569.aspx#Reference
If Client Object Model can be an option for you, you can use Tenant object to achieve what you want:
http://social.technet.microsoft.com/wiki/contents/articles/24050.perform-basic-admin-operations-using-csom-in-sharepoint-online.aspx#Scenario_3_Fetch_All_Site_Collections
Anyway, I would suggest you submit a feedback to the Office Developer Platform if there any expectation about the future version of REST API of Office 365 SharePoint
Online:
http://officespdev.uservoice.com/
It
is a place for customers provide feedback about Microsoft Office products. What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft
Product Team will take it into consideration when designing the next version in the future.
Thanks
Patrick Liang
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
Authoring and Publishing site collection in SharePoint Online
Hi ,
Can we have multiple authoring and publishing site collection in SharePoint Online?
Thanks, Kaviya (Please remember to click “Mark as Answer” on the post that helps you)Yes you can use SharePoint 2013 cross-site publishing feature in SharePoint Online to support 1:1 and 1:n set up of authoring : publishing site-collections in SharePoint Online. The catch is that it all needs to be within same tenant.
http://technet.microsoft.com/en-us/library/jj635883(v=office.15).aspx
http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2013/04/01/cross-site-publishing-alternatives-in-sharepoint-online-office-365.aspx
Please mark the replies as answers if they help or unmark if not.
Maybe you are looking for
-
Help!!!! Is it possible to just submit a pdf form?
I have built an employee application so applicants can go onto our website, fill it out and send it via email. When you press "Submit by Email" Outlook opens and it sends the form FROM my email address. My main concern is what if a applicant isn't ho
-
Hi Experts I am using a SQL server .The XI server is conecting to teh SQL server through Receiver JDBC adapter. I am getting stuck with teh following information . JDBC Driver: com.microsoft.jdbc.sqlserver.SQLServerDriver Connection: jdbc:Microso
-
JMS consumer is not receiving any messages. am i missing something ?
Hi bellow is the consumer code, my consumer is not receiving any messages even though there are messages in the queue. I have tried to debug the code. but the consumer is not calling the onMessage() method even though there are messages in the queue.
-
IOS 8.1.1 Notification Center stretched out
Hello Apple Community!!! I've ran into an issue. I'm on my iPhone 6+ with iOS 8.1.1. My notification center has decided to stretch out and not display properly. If in portrait mode it looks as if it's in landscape mode and drops half way down the
-
Unable to login Windows Server 2012 after making local policy changes
Experts, we have modified the local policy setting on the windows server 2012 and badly it was domain controller now none of the users are able to login to the server. After entering the user name and password it will launch till welcome screen then