Tag Info

New answers tagged

0

Try "Here-Strings" Using Windows PowerShell “Here-Strings”


0

This is what we use. Under the task options for Action choose "Start a program". Program/Script: "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" Add Arguments: -command "& 'C:\Pscripts\MyScript.ps1'" You could also try to log something in your script so that you can see if it is being run or failing etc. I use this function to Log ...


0

Please ensure you are following the steps mentioned here for scheduling your task. Looking at history of the scheduled task doesn't ensures that the powershell has executed successfully. Even if the powershell is returning an error, the scheduler history will show as "running successfuly".


0

Try this $web = Get-SPWeb http://devintranet.tokiomillennium.com/operations/claims $startDate = [datetime]::ParseExact("10/03/14", "dd/MM/yy", $null) $endDate = [datetime]::ParseExact("10/05/14", "dd/MM/yy", $null) ForEach($list in $web.Lists) { ForEach($item in $list.Items) { ForEach($version in $item.Versions) { ...


7

AS PER MSDN SPList.ItemCount: The value of the ItemCount property includes folders within a document library, as well as files within subfolders. The value of the Count property of the SPListCollection class does not include folders. SPListItemCollection.Count: Gets the number of list items in the collection, excluding folders. BUT Although it's ...


0

$list.itemcount counts the folders also while $items.count counts the list items


0

I tested a number of different options I found online including an attempt to do concurrent background processing as well as batch requests and the following worked best for me. I did not want to delete the list itself. Param( $listname, $url=$env:SPSITE #an env variable set at system level ) Add-PSSnapin Microsoft.SharePoint.PowerShell ...


-1

To change the farm account you need to use stsadm, still. stsadm –o updatefarmcredentials –userlogin DOMAIN\username –password password


0

Issue is solved, I found the bug. All Active directory users was created with all kind of signs which shouldn't be there. Our server provider created these users. Script is running normal now


0

Encountered the same error as above in my case the cause was an orphaned item in the content-database. I was restoring a root site collection. After a detach and attach of the database I was able to restore the site. So another option to check when you encounter the error.


1

Ok, I got it ! I need to do this : $myfolder = $library.Folders | ?{$_.Name -eq "My Folder"} $sBytes = $Item.OpenBinary() $newfile = $myfolder.Folder.Files.Add($myfolder.Url + "/" + $Item.Name, $sBytes, $true) And this works.


0

Although the approach suggested by @Karthik Jaganathan definitely works, I would prefer a try/catch based solution, as it has no sence executing further steps in the loop after a former step has already failed See the PowerShell error handling strategies on MSDN #save actual preference $errpref = $ErrorActionPreference $ErrorActionPreference = "stop" ...


0

@kosikovec i doubt it is possible through powershell if you are looking at sharepoint online.There are no powershell scripts for app deployment to sharpeoint online


0

To set the account associated with a particular Service Instance using Windows PowerShell we simply get the ProcessIdentity property of the Service Instance and set its Username property. Once set we call Update() to update the Configuration Database and then Deploy() to push the change out to all Service Instances. $pi = $svc.Service.ProcessIdentity if ...


1

You can try changing the value of the $ErrorActionPreference variable: $errpref = $ErrorActionPreference #save actual preference $ErrorActionPreference = "silentlycontinue" ... your code ... $ErrorActionPreference = $errpref #restore previous preference Source


1

You won't have the luxury of the commandlets like *-SP*, but all of the managed code libraries will be at your disposal by means of reflection: [reflection.assembly]::load* methods will come handy.


0

If you have a newer SP version (2010 or 2013) you could automate the process via iterating through the SiteUsers collection and call the Move-SPUser PowerShell CmdLet on each of them, but in 2007 it is not available. So if your question relates to the same SharePoint 2007 as your former question, then the answer is no, you cannot use Move-SPUser unless you ...


0

Yes you can enable PowerShell http://blogs.technet.com/b/praveenh/archive/2013/01/22/running-powershell-on-moss-2007.aspx PowerShell by default comes with Windows Server 2008, however it doesn’t come with Windows Server 2003 and my guess is that if you’re still running SharePoint 2007 you’re probably still running Server 2003. If you are among this group, ...


2

Permissions are on items, and there is a file behind the item. Try this: $siteCollUrl = http://mysharepointsite $LibraryName = "Reports" $spSourceWeb = Get-SPWeb $siteCollUrl; $list = $spSourceWeb.Lists[$LibraryName] foreach ($item in $list.Items) { $item.BreakRoleInheritance($true) } $spSourceWeb.Dispose()


0

Use the -NoLogFile parameter. Import-SPWeb -Identity http://site -Path //server/share/file.cmp -NoLogFile


0

The profiles are based on your Azure AD Users so you have to start there. The username has to be part of the registered domain. Like bob@tenant.onmicrosoft.com if you are not using a custom domain, if you use a custom domain then use that. Create a CSV file with the columns necessary (listed below in the loop). Create new users with MSOL PowerShell. After ...


1

As you said, you already created a new Site Collection and trying to overwrite with root level site collections. In this case you have two choices. Method: 1 Create a new Content Database restore the site collection to newly created Database(using the database parameter of Restore command). You can not restore a site collection two times in a content ...


1

Did you remove the original root site collection before running the Restore-SPSite? If not, you also need to specify a new Content database for the Site Collection. The Restore-SPSite cmdlet performs a restoration of the site collection to a location specified by the Identity parameter. A content database may only contain one copy of a site ...


0

When you export a site / web, it created one or multiple CMP files depend upon the Size of Site and value of FileMaxSize By default, the .cmp files are limited to 24 MB in size, although you can change this value using the FileMaxSize property. If set to zero, the value resets to the default. When site data exceeds the specified limit, site data ...


0

In SharePoint 2010 or later, the Folder content type has ItemChildCount and FolderChildCount columns that can be sorted or filtered by in a view or by an SPQuery <Where/> clause. That way you don't have to write any PowerShell at all to find the empty ones - just look for 0 in both columns, that's all. Later on you can write a simple JavaScript do ...


2

This one provides a little more info than Mike's (again, replace web URL and list name). I'm outputting to a text file because you said there's 32000 folders, I doubt you want to scroll through 32000 lines of window buffer: $TestSPSnapin = get-pssnapin | ? { $_.Name -eq "Microsoft.SharePoint.Powershell"} if($TestSPSnapin -eq $null){ add-pssnapin -Name ...


0

Try this script, replacing the listname and weburl : Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue $web = Get-SPWeb http://sharepoint/sitecoll/web $list = $web.Lists["List Name"] foreach($folder in $list.Folders) { if($folder.Folder.SubFolders -eq $null) { Write-Host Empty folder at ...


0

When I need to do this in powershell (hide output), I usually test these three ways, but I cannot try it right now : [void]Import-SPWeb ... at the beginning of the line could work Import-SPWeb ... > $null at the end of the line Import-SPWeb ... | Out-Null Please give feedback about results.


0

I had the same problem with SharePoint 2013 Sp1. Used the following command with a -Force parameter: Register-SPWorkflowService -SPSite "http://yoursite/" -WorkflowHostUri "http://yoursitecollection:port" -AllowOAuthHttp -Force


1

Try this script, i tested and it works. All you need to run this script is an O365 tenant, the SharePoint client components SDK installed on the machine running the script - http://www.microsoft.com/en-us/download/details.aspx?id=35585 and to update the $User, $SiteURL, $DocLibName (name of the destination Document library) and $Folder (path to the local ...


3

Something like this: $w = get-spweb "<webURL>" $list = $w.Lists.TryGetList("<Title of the list>") if($list -ne $null) { # The list already exists } Replace <webURL> and <Title of the list> with your actual values


0

Open sharepoint management shell as administrator then execute the command , it is working for me.


0

For each field you should identify the default term name. Then to get the Unique ID, you need to iterate through the term store as below $session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site) $termStore = $session.TermStores[0] $group = $termStore.Groups["GroupName"] $termSet = $group.TermSets["TermsetName"] $terms = ...


1

You can export the SQL data using SQL management tools and Trim data using PowerShell. Another option is using PowerShell to archive and Trim as explained here I found below script from here Below script will export audit data into a CSV file $tabName = "AuditLog" #Create Table object $table = New-Object system.Data.DataTable “$tabName” #Define Columns ...


0

To back up: It's part of the Content database, only supported solution is to backup the content database. You can enable trimming to trim the audit log: Configure audit log trimming On the Site actions menu Site Actions Menu, click Site settings. If you are not at the root of your site collection, under Site Collection Administration, click Go to top ...


1

You should use RemoveWorkflowFromListItem from site.WorkflowManager


0

If their is no site subscription then you will get bunch of zero. SiteSubscriptionId ------------------ 00000000-0000-0000-0000-000000000000 But you need the following permissions(few you already have) farm admin group SPShellAdmin DBO rights on the Content Databases I would run the command under the farm admin account( the account which run the ...


1

Below Code Reads the SiteUrls from Text file called SiteUrls.txt, and add library called "Oct Invoicing 2014" to the Wikipage called "Billing_Req.aspx" Here we are taking variable i to check for the library already present on the page, if present we are incrementing i to 1 and else its default value =0 If i=0 means webpart is not present on the page and it ...


0

Please try the below code from Using SharePoint 2013 Workflow Services JS API. You may have to tweak it according to your requirement. (function () { // Getting client context and loading the current web var context = SP.ClientContext.get_current(); var web = context.get_web(); context.load(web); // Workflow Services API entry point - ...


2

Try setting the property to 1 $column.FriendlyDisplayFormat = 1. This is enumeration type as we can see here: SPDateTimeFieldFriendlyFormatType enumeration


1

Use SharePoint Manager 2010 from CodePlex and you can browse through your sites and track down where it has reference. Directly deleting data from DB will put you in unsupported. also check this one http://leonidius2010.wordpress.com/2011/09/13/sharepoint-2010-finding-missingsetupfile/ Another method is using the powershell: ...


1

EPPlus EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx). Below solution is not tested You can copy over the Excel InterOp dll's and then execute PowerShell referencing the Excel functions that are available in the interop. For example: You can create a new excel file using below statements ...


0

This will work. $content = ([Microsoft.SharePoint.Administration.SPWebService]::ContentService) $appsetting =$content.DeveloperDashboardSettings $appsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On $appsetting.Update()


0

You can remove app using following powershell command $instances = Get-SPAppInstance -Web <URL> $instance = $instances | where {$_.Title -eq '<app_title>'} Uninstall-SPAppInstance -Identity $instance replace <URL> with site collection url and <app_title> with title of the app you want to remove


0

Please try the below script. I have tried to get the listitem object out of the url. A check is necessary if your Urls contain relative urls as well. Thanks, Aravind. $site = New-Object Microsoft.SharePoint.SPSite($listURL) $web = $site.OpenWeb() $listitem=$web.GetListItem($listURL); "Output with list url-" $site.url $web.url $listitem.ParentList.Title ...


0

There IS a way to get rid of those GUID names for the application pools, and it works, too, although this is a hacky way of doing it; I don't know if anyone else does this, and you certainly do it at your own risk. Most of the time, these GUID names are created by Sharepoint's managed services. If you look in IIS, you will see under "Sites" a site called ...


1

I think better solution is to get filtered and sorted items from list using CAML query: $qry = New-Object Microsoft.SharePoint.SPQuery; $qry.Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>440-10011</Value></Eq></Where><OrderBy><FieldRef Name='Modified' Ascending='TRUE' ...


0

You can use Sort-Object -Property for sorting the result $spSourceList.Items | where {$_['Title'] -eq '440-10011'} | Sort-Object -Property Modified ....


0

Use $ClientContext.Load($list.Views)syntax in PowerShell to load Views collection, for example: $list = $Context.Web.Lists.GetByTitle($ListTitle) $Context.Load($list) $Context.Load($list.Views) $Context.ExecuteQuery() if ($list.IsObjectPropertyInstantiated('Views') -eq $true) { Write-Host "Views collection has been loaded" }



Top 50 recent answers are included